Advertisement
Eeems

rmacro

Jul 2nd, 2011
195
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.         push hl     ; push the original value to the stack
  20.             ld c, (hl)  ; Load the address to bc
  21.             inc hl
  22.             ld b, (hl)
  23.             dec hl
  24.             push hl     ; store it for later
  25.                     ld a,(CurrentThreadID)
  26.                     call GetThreadEntry ; get the thread entry
  27.                 inc hl          ; move to the executable address entry
  28.                 ld e,(hl)       ; load
  29.                 inc hl          ; it
  30.                 ld d,(hl)       ; into de
  31.                 ex de,hl        ; swap it into hl
  32.                 add hl,bc       ; add it to the address in bc
  33.                 ex de,hl        ; put it back into de
  34.             pop hl      ; get the address back
  35.             ld (hl), e  ; store the new adress
  36.             inc hl      ; into the old location
  37.             ld (hl), d
  38.         pop af
  39.         pop bc
  40.         pop de
  41.     pop hl  ; restore values
  42.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement