Advertisement
Runer112

Untitled

Jul 2nd, 2011
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Clears all memory accociated with a thread
  2. ; inputs    a  = Thread ID
  3. FreeThreadMem:
  4.     push af
  5.     push de
  6.     push hl
  7.     push ix
  8.     ld hl,UserRAM
  9.     xor a
  10. FTMLoop     cp (hl)
  11.         jr nz,FTMSkip
  12.         push hl
  13.         pop ix
  14.         call FreeMem
  15. FTMSkip     inc hl
  16.         ld e,(hl)
  17.         inc hl
  18.         ld d,(hl)
  19.         add hl,de       ; jump to next section
  20.         ld de,UserRAMEnd    ; get the end of UserRAM
  21.         sbc hl,de       ; compare
  22.         add hl,de
  23.         jr nz,FTMLoop       ; loop again if hl < UserRAMEnd
  24.     pop ix
  25.     pop hl
  26.     pop de
  27.     pop af
  28.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement