Call a foreign-language function: Difference between revisions
m
→{{header|68000 Assembly}}
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 25:
(Technically, the 68000 isn't calling the function itself, since it doesn't understand Z80 code at all; rather, it's instructing the Z80 to call and execute the function on its behalf. But this is probably as close as we'll ever get.)
'''Z80 Code:'''
<lang z80>org &0000 ;execution resets here after the 68000 resets the Z80 and sends a bus request.
jr start
org &0038 ;in IM 1 mode, we jump here for an IRQ. But this isn't being used for this example, so we'll just silently return.
reti
org &0060
Line 35 ⟶ 38:
LD SP,&2000
main: ;hardware non-maskable interrupt (NMI) jumps here.
ld a,(&1F00) ;we'll only allow the 68000 to alter the contents of this memory address.
or a
jr z,main ;just keep looping until it's nonzero.
;by counting the bytes each instruction takes, it can be proven that this label points to &006C.
;The call
smc:
call &0000 ;we'll overwrite the operand at &006D-&006E with whatever function we want to call.
done:
|