Advertisement
Eeems

Untitled

Jul 2nd, 2011
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; rst 08h, macros kld, kcall, kjp
  2. ; Loads the correct address into
  3. ; executing programs at runtime
  4. rmacro:
  5.     push hl ; Save HL
  6.         inc sp
  7.         inc sp
  8.     pop hl ; Get the return address
  9.     dec hl
  10.     ld (hl), 0 ; Remove the rst
  11.     inc hl     ; Move to the load
  12.     dec sp
  13.     dec sp
  14.     push hl
  15.         inc hl      ; Move to the address
  16.         push de
  17.         push bc
  18.         push af
  19.             ld c, (hl)  ; Load the address to bc
  20.             inc hl
  21.             ld b, (hl)
  22.             dec hl
  23.             push hl     ; store it for later
  24.                     ld a,(CurrentThreadID)
  25.                     call GetThreadEntry ; get the thread entry
  26.                 inc hl          ; move to the executable address entry
  27.                 ld e,(hl)       ; load
  28.                 inc hl          ; it
  29.                 ld d,(hl)       ; into de
  30.                 ex de,hl        ; swap it into hl
  31.                 add hl,bc       ; add it to the address in bc
  32.                 ex de,hl        ; put it back into de
  33.             pop hl      ; get the address back
  34.             ld (hl), e  ; store the new adress
  35.             inc hl      ; into the old location
  36.             ld (hl), d
  37.         pop af
  38.         pop bc
  39.         pop de
  40.     pop hl  ; restore values
  41.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement