Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Generic-swap/Z80-Assembly/generic-swap-1.z80
Normal file
4
Task/Generic-swap/Z80-Assembly/generic-swap-1.z80
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
push ix
|
||||
push iy
|
||||
pop ix ;the value that was once in IY is now in IX
|
||||
pop iy ;the value that was once in IX is now in IY
|
||||
8
Task/Generic-swap/Z80-Assembly/generic-swap-2.z80
Normal file
8
Task/Generic-swap/Z80-Assembly/generic-swap-2.z80
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
;8-bit swap using the stack.
|
||||
|
||||
ld a,(&C000)
|
||||
push af
|
||||
ld a,(&D000)
|
||||
ld (&C000),a ;store the byte at &D000 into &C000
|
||||
pop af ;now a = the byte at &C000
|
||||
ld (&D000),a ;now the byte at &D000 equals the byte that was originally at &C000
|
||||
5
Task/Generic-swap/Z80-Assembly/generic-swap-3.z80
Normal file
5
Task/Generic-swap/Z80-Assembly/generic-swap-3.z80
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;16-bit swap:
|
||||
ld hl,(&C000) ;load the byte at &C000 into L and the byte at &C001 into H.
|
||||
ld de,(&D000) ;load the byte at &D000 into E and the byte at &D001 into D.
|
||||
ld (&D000),hl ;store the contents of L into &D000 and H into &D001.
|
||||
ld (&C000),de ;store the contents of E into &C000 and D into &C001.
|
||||
4
Task/Generic-swap/Z80-Assembly/generic-swap-4.z80
Normal file
4
Task/Generic-swap/Z80-Assembly/generic-swap-4.z80
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
push hl
|
||||
ld h,d
|
||||
ld L,e ;store de into HL. This is much faster than "push de pop hl."
|
||||
pop de ;put old HL into DE
|
||||
20
Task/Generic-swap/Z80-Assembly/generic-swap-5.z80
Normal file
20
Task/Generic-swap/Z80-Assembly/generic-swap-5.z80
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
ld hl,&C000
|
||||
push bc
|
||||
ldi a,(hl) ;equivalent of "ld a,(hl) inc hl" but is faster than the two separately. Some assemblers call this "ld a,(hl+)"
|
||||
ld c,a
|
||||
ld a,(hl) ;we don't need to increment hl this time. There's no wasted time or bytecode if we did however.
|
||||
ld b,a ;on Zilog Z80 we would have just done "LD BC,(&C000)" but Game Boy can't do that.
|
||||
|
||||
; now we do the swap.
|
||||
ld hl,&D000
|
||||
|
||||
ld a,(hl) ;get the byte at &D000
|
||||
ld (&C000),a ;store it into &C000
|
||||
ld (hl),c ;store the old byte at &C000 into &D000
|
||||
|
||||
inc hl ;inc HL to &D001
|
||||
|
||||
ld a,(hl) ;get the byte at &D001
|
||||
ld (&C001),a ;store it at &C001
|
||||
ld (hl),b ;store the old byte at &C001 into &D001
|
||||
pop bc
|
||||
Loading…
Add table
Add a link
Reference in a new issue