100 likes | 181 Views
Homework Problem 2.6. By Valvano. Description of 2.6. Hand assemble the following program. Include the symbol table, the address and machine code in hexadecimal for each instruction. (hint: Use Program 2.2 and Example 2.2). Initialization.
E N D
Homework Problem 2.6 By Valvano
Description of 2.6 • Hand assemble the following program. Include the symbol table, the address and machine code in hexadecimal for each instruction. (hint: Use Program 2.2 and Example 2.2)
Initialization • The first several lines use the pseudo op equ to initalize the direction registers and the port addresses. • The symbol table begins with these values • DDRH--$0262 • DDRT--$0242 • PTH--$0260 • PTT--$0240
Initialization (cont.) • The pseudo op org indicates the start of the EEPROM information (at location $4000). • Main is the label for the first line of code so it is entered into the symbol table. • Main--$4000
Hand assembly • The next line is an instruction. • ldaa #$FF • The machine code for ldaa is $86 and the operand (immediate addressing) is found in the machine code word: $86FF (see page 50 and 51) and the Freescale CPU 12 manual.
Hand Assembly • staa DDRT • At the top of page 51, we see that the store accumulator function is extended addressing. • The machine code becomes $7A0242. • ldaa #$00 and staa DDRH are handled in a similar fashion.
Hand Assembly (cont.) • loop is then added to the symbol table. • loop--$400A • bra loop is discussed on page 51, and is said to be PC relative (PC = has already been incremented by two bytes at this time so its value is $4012 and if we add F8 to this we get $400A. • The code for bra is 20 and we have $20F8 for the machine code.
Final result • Symbol Table • DDRH-- $0262 • DDRT-- $0242 • Main-- $4000 • PTH-- $0260 • PTT-- $0240 • loop-- $400A
Final Result (cont.) • $0262 • $0242 • $0260 • $0240 • $4000 86FF • $4002 7A0242 • $4005 8600 • $4007 7A0262
Final Result (cont.) • $400A B60260 • $400D 7A0240 • $4010 20F8 • $FFFE • $FFFE 4000