Re: A86: data


[Prev][Next][Index][Thread]

Re: A86: data





>I'm new to assembly programming, and I'd like to know something:
>
>how would you read one byte at a time from something like this:
>
>stuff:
>     .db 0,1,3,2,1,5,4
>
>then compare it with a number (lets say 4), and if its 4, you end?
ld hl,stuff   ;Load the memory adress of first byte into hl
ld c,4        ;Load c with the value you want to break the loop
Loop:          ;Place to come back to if not the right value (Label)
ld a,(hl)     ;Load a with the byte stored at the adress hl
inc hl        ;increment the aderss to the next byte
cp c        ;compare the value in c with a, if the same set zero flag
jr nz,Loop    ;Go to the label Loop if the zero flag is not set

    Hope this helps.
                                       ~neophile_17
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com



Follow-Ups: