Computer Science 237 |
Lecture 7: Assembly Programming, More Addressing Modes
Date: September 23, 2005
A few things about our assembler:
Advice on approaching an assembly programming task:
.w
)
%d3
(%a3)
the effective address of the data is found in an address register; used for pointers
4(%a6)
the effective address of the data is the contents of the register plus an offset; used for fields in a structure.
4(%a4,%d1.w)
effective address is the address register plus the contents of the displacement register plus the displacement; useful for arrays
-(%a7)
that
is -(%sp)
Suppose you're manipulating data with n bytes (1=b,2=w,4=l)
Then
(%a7)+
that
is (%sp)+
Suppose you're manipulating data with n bytes (1=b,2=w,4=l)
Then
#4
We've seen and used this. There is no effective address.
0x4000
Better know what you're doing.
Danger:
4(%pc)
or loop
(a
label)
this allows relocatable code - jumps are relative to PC.
tar xvfz /usr/cs-local/share/cs237/examples/shell.tar.gz
mv shell multiply
Note you can see your registers.
BRK just stops the program
DEB n puts the value 0xDEB00000+n into D7 and stops
These are defined in the cs237.h file, a simpler way for you to get into the Palm debugger.
The values along the right are the contents of the stack - we'll worry about this later.