Advertisement
CVSoft

Untitled

Dec 21st, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ParseString:
  2.  ld hl,Picture          ;the memory address at the start of our thingy
  3.  ld bc,1200             ;the number of bytes we are going to read
  4.  ld de,0                ;we can do a 16-bit compare
  5. ParseStringLoop:        ;the loop body
  6.  ld a,(hl)              ;put the byte currently being tested in accumulator for testing
  7.  cp 97                  ;is it the ASCII value for 'a'?
  8.  call z, aDetected      ;if it is, call this routine here
  9.  cp 98                  ;is it the ASCII value for 'b'?
  10.  call z, bDetected      ;if it is, call this routine here
  11.  inc hl                 ;we're done with the current byte so we go to the next
  12.  dec bc                 ;since we're done with the byte, we decrement the counter
  13.  ld a,b                 ;we are going to use a for a 16-bit compare, we can use a because we are done with the previous byte
  14.  or c                   ;a contains the bits in b. We now add the bits in c to the bits in a. if bc is 0, they will all remain 0. else, not zero
  15.  cp 0                   ;are they all zero? if so, bc is 0
  16.  jp nz, ParseStringLoop ;if bc is not zero, then we are not done reading/processing bytes, and we go back to the loop body
  17.  ret                    ;otherwise, we are done, and go back home.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement