>Hi,
>I am new to 68000 assembly language and I was wondering if anyone could help
>me to understand the following few lines of code. It belongs to an app,
>which I am trying to make some changes in:
>
>I would really appreciate your help
>
>1652 pea -4608(a5)
>1656 pea -4628(a5)
These are two parameters that are being passed to some routine. They
appear to be the addresses of two global variables.
>165A pea 14(pc) ; 166A
>165E pea 4(pc) ; 1664
>1662 addi.l #54510,(a7)
>1668 rts
This sequence is how you can set up a long (> +/- 32K) jsr (jump to
sub-routine) to another routine within the same segment.
The first pea (push effective address) instruction sets up the return
address on the stack, which is 166A.
The second pea pushes the address of the "effective" address that
you're calling from. Then the linker adds a long constant (#54510, or
0xD4EE) to turn this into the address of the routine that you want to
call (0xEB52).
Finally, the rts (return from sub-routine) instruction pops this
calculated address off the stack and effectively jumps to it.
The reason this code looks so odd is that the compiler/linker are
trying to make the call without using any data/address registers,
which could potentially be used to pass arguments to the routine
you're calling.
>166A tst.b d0
>166C addq #8,a7
>166E bne $+102 ; 16D6
It looks like the routine being called returns a boolean result
(typically passed back in register d0). The result is being tested,
and if true, the code jumps to (relative) address 16D6.
If this is hand-generated 68K, then as you modify the app you'll need
to adjust the value of the offset (currently #54510), as the relative
location of the function being called will change.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/