Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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

View 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

View 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.

View 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

View 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