Advertisement
Zeda

ChkFindVar

Jan 4th, 2012
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;===============================================================
  2. ChkFindVar:
  3. ;===============================================================
  4. ;Inputs:
  5. ;     OP1 contains the var name to search for
  6. ;Outputs:
  7. ;     A is the type
  8. ;     B is the flashpage
  9. ;     C is the name length
  10. ;     DE points to the size bytes
  11. ;     HL points to the symentry
  12. ;===============================================================
  13.      ld de,8478h
  14. ChkFindVarAtDE:
  15.      ld bc,9
  16.      ld a,(de)
  17.      and 1Fh
  18.      ld (de),a
  19.      ld hl,OP2-1
  20.      cp 5
  21.      jr nz,$+4
  22.      ld (hl),6
  23.      cp 6
  24.      jr nz,$+4
  25.      ld (hl),5
  26.      ex de,hl
  27.      ld a,b
  28.      push hl
  29.      cpir
  30.      jr z,$+3
  31.        dec c
  32.      ld a,7
  33.      sub c
  34.      ld (OP2-2),a
  35.      pop hl
  36.      rst 10h
  37.      ld hl,(9830h)
  38. CompareOverLoop:
  39.      ld de,8478h
  40. CompareLoop:
  41.      ld bc,(982Eh)
  42.      or a
  43.      sbc hl,bc
  44.      add hl,bc
  45.      ccf
  46.      ret z
  47.      ld a,(de)
  48.      ld bc,-6
  49.      cp (hl)
  50.      jr z,TypeMatch
  51.      ld a,(OP2-1)
  52.      cp (hl)
  53.      jr z,TypeMatch
  54.        add hl,bc
  55.        ld c,(hl)
  56.        inc c
  57.        inc b
  58.        or a
  59.        sbc hl,bc
  60.        jr CompareLoop
  61. NotMatch:
  62.    pop af
  63.    or a
  64.    sbc hl,bc
  65.    jr CompareOverLoop
  66. TypeMatch:
  67.      add hl,bc
  68.      push hl
  69.      ld a,(OP2-2)
  70.      ld c,(hl)
  71.      dec hl
  72.      inc b
  73.      cp c
  74.      jr nz,NotMatch
  75.      inc de
  76. CompareName:
  77.      ld a,(de)
  78.      inc de
  79.      cpd
  80.      jr nz,NotMatch
  81.      jp pe,CompareName
  82. FoundVar:
  83.      pop hl
  84.      ld c,(hl)
  85.      inc hl
  86.      ld b,(hl)
  87.      inc hl
  88.      ld d,(hl)
  89.      inc hl
  90.      ld e,(hl)
  91.      inc hl
  92.      inc hl
  93.      inc hl
  94.      ld a,(hl)
  95.      ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement