Advertisement
Runer112

Untitled

Jul 2nd, 2011
182
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. FTMLoop     cp (hl)
  10.         jr nz,FTMSkip
  11.         push hl
  12.         pop ix
  13.         call FreeMem
  14. FTMSkip     inc hl
  15.         ld e,(hl)
  16.         inc hl
  17.         ld d,(hl)
  18.         add hl,de       ; jump to next section
  19.         ld de,UserRAMEnd    ; get the end of UserRAM
  20.         sbc hl,de       ; compare
  21.         add hl,de
  22.         jr nc,FTMLoop       ; loop again if hl < UserRAMEnd
  23.     pop ix
  24.     pop hl
  25.     pop de
  26.     pop af
  27.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement