Page 360 - Embedded Microprocessor Systems Real World Design
P. 360
programmed into the control store. Assemblers always allow you to insert comments into the
code to explain what you are doing. These may be preceded by a semicolon (;), double slash
(//) , or other characters.
Every microprocessor has a unique assembly language, although many manufacturers use
a common language across a family of processors. The following is an example of assembler
code and the corresponding machine code for an Atmel AVR series microcontroller:
Machine Code Assembler Code Comments
94fa Cli ; CLI disables interrupts
ecOc ldi accum,$cc ; Put CC (hex) into accum
bb05 out portc, accum ; Output accum to port C
efOf ser accum ; Set all the bits in the
; acm register to ones.
bb04 out ddrc, accum ; Set port C to outputs
98de cbi porta,6 ; Clear port A bit 6
0000 nOP ; Do nothing (delay)
coo2 rjmp clk-tach-on ; Jump to a label called; clk-tach-on
Finally, high-level languages provide a simpler means of programming microprocessors.
A high-level language such as C permits the programmer to write instructions that look like
this:
x = y + z; I/ Add two numbers
The compzhtranslates the instructions into machine code. Unlike assembly, there is not
one high-level language statement per machine instruction. One high-level line of code may
generate dozens of machine instructions. The preceding example might produce machine
code instructions that do the following:
move memory location y into Register 1
move memory location z into Register 2
Add Register 1 to Register 2, leaving the result in Register 1
Store the contents of Register 1 in memory location x
This simple C statement produced four lines of machine code. Using a high-level
language, the software engineer need not worry about the specifics of the machine language
or assembly language for the microprocessor. High-level languages permit better portability
of the code across different microprocessors.
With this overview, you should be ready to tackle the material in the book.
Appendix D 341