Advertisement
Eeems

Untitled

Jul 7th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Returns the amount of Free RAM
  2. ; output    hl = Free RAM
  3. ReturnFreeRAM:
  4.     push af
  5.     push bc
  6.     push de
  7.     push ix
  8.     ld hl,UserRAM
  9.     ld bc,0
  10.     ld a,$FF
  11. _       cp (hl)
  12.             jr nz,_
  13.         inc hl
  14.         ld e,(hl)
  15.         inc hl
  16.         ld d,(hl)
  17.         push hl
  18.             ld h,b
  19.             ld l,c
  20.             add hl,de
  21.             ld b,h
  22.             ld c,l
  23.         pop hl
  24.         jr ++_
  25. _       inc hl
  26.         ld e,(hl)
  27.         inc hl
  28.         ld d,(hl)
  29. _       add hl,de       ; jump to next section
  30.         ld de,UserRAMEnd    ; get the end of UserRAM
  31.         sbc hl,de       ; compare
  32.         add hl,de
  33.         jr c,---_       ; loop again if hl < UserRAMEnd
  34.     pop ix
  35.     pop de
  36.     pop bc
  37.     pop af
  38.     ld h,b
  39.     ld l,c
  40.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement