RosettaCodeData/Task/Call-a-foreign-language-function/68000-Assembly/call-a-foreign-language-function-1.68000
2023-07-01 13:44:08 -04:00

30 lines
975 B
Text

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
start:
DI
IM 1
LD SP,&2000
main: ;hardware non-maskable interrupt (NMI) jumps here (address &0066)
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 opcode takes 1 byte and the operand that follows takes two bytes.
smc:
call &0000 ;we'll overwrite the operand at &006D-&006E with whatever function we want to call.
done:
jp done ;loop until next reset
ExampleFunction: ;ADDR: &0072($A00072)
ret ;for simplicity this does nothing but in reality you'd have it do something sound-related here.