RosettaCodeData/Task/Higher-order-functions/6502-Assembly/higher-order-functions-2.6502
2023-07-01 13:44:08 -04:00

23 lines
605 B
Text

PrintOutput:
; prints the output of the function "foo" to the screen.
; input:
; A = input for the function "foo".
; z_L = contains the low byte of the memory address of "foo"
; z_H = contains the high byte of the memory address of "foo"
pha
LDA z_L
STA smc+1 ;store in the low byte of the operand
LDA z_H
STA smc+2 ;store in the high byte of the operand
pla
smc:
JSR $1234
;uses self-modifying code to overwrite the destination with the address of the passed function.
;assuming that function ends in an RTS, execution will return to this line after the function is done.
JSR PrintAccumulator
rts