Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Repeat/Z80-Assembly/repeat-1.z80
Normal file
26
Task/Repeat/Z80-Assembly/repeat-1.z80
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
ld b,&05 ;load the decrement value into b
|
||||
ld hl,myFunc ;load the address of "myFunc" into HL
|
||||
|
||||
call repeatProcedure
|
||||
|
||||
forever:
|
||||
jp forever ;trap the program counter here
|
||||
|
||||
repeatProcedure: ;input: b = times to repeat, hl = which procedure to repeat
|
||||
call trampoline
|
||||
; the "ret" in myFunc will bring you here
|
||||
djnz repeatProcedure
|
||||
ret ;exit "repeatProcedure" and proceed to "forever"
|
||||
|
||||
trampoline:
|
||||
push hl
|
||||
ret
|
||||
;this is effectively a call to whatever is in HL, in this case "myFunc." The "ret" at the end of myFunc will return us to
|
||||
;just after the line "call trampoline"
|
||||
|
||||
|
||||
myFunc: ;this doesn't do anything useful but that's not the point
|
||||
push hl ;not needed for this routine but if it altered HL we would need this so that we come back here next time we loop
|
||||
or a
|
||||
pop hl
|
||||
ret
|
||||
2
Task/Repeat/Z80-Assembly/repeat-2.z80
Normal file
2
Task/Repeat/Z80-Assembly/repeat-2.z80
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
trampoline:
|
||||
jp (hl) ;despite the parentheses this does NOT dereference HL, it merely acts as "LD PC,HL".
|
||||
10
Task/Repeat/Z80-Assembly/repeat-3.z80
Normal file
10
Task/Repeat/Z80-Assembly/repeat-3.z80
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
LD HL,myFunc
|
||||
LD (repeatproc+1),HL
|
||||
LD B,5 ;repeat count
|
||||
CALL repeatProc
|
||||
|
||||
;somewhere far away from here:
|
||||
repeatProc:
|
||||
call &0000 ;gets overwritten with the address of MyFunc
|
||||
djnz repeatProc
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue