daily pastebin goal
7%
SHARE
TWEET

searchstr

Zeda Sep 24th, 2015 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. searchstr:
  2. ;BC points to input file
  3. ;IX points to malware code
  4. ;HL is the size of the file
  5. ;DE is the size of the malware code
  6. ;Output: nz if no match, else z. HL points to match+1
  7.  
  8.     or a
  9.     sbc hl,de
  10.     ret c
  11. ;swap HL and BC
  12.     ld a,b
  13.     ld b,h
  14.     ld h,a
  15.     ld a,c
  16.     ld c,l
  17.     ld l,a
  18. ;reformat counter DE
  19.     dec de
  20.     inc e
  21.     inc d
  22. ;begin search
  23. loop0:
  24.     ld a,(ix)
  25.     cpir
  26.     ret nz
  27.     jp po,compare
  28.     push hl
  29.     push de
  30.     push ix
  31.     call compare
  32.     pop ix
  33.     pop de
  34.     pop hl
  35.     ret z
  36.     jp loop0
  37. compare:
  38.     inc ix
  39.     ld a,(ix)
  40.     cp (hl)
  41.     ret nz
  42.     inc hl
  43.     dec e
  44.     jp nz,compare
  45.     dec d
  46.     jr nz,compare
  47.     ret
RAW Paste Data
Top