ld bc,1000/2 ;we are only doing every other byte
ld hl,$8000 ;address to start at
ld de,$1234 ;what to write
loop:
ld (hl),d ;load $12 in
inc hl ;increase to next address
ld (hl),e ;load $34 in
inc hl ;increase to set up for next loop
dec bc ;decrease counter
jr nz,loop ;is bc=$0000 yet...if so we're done
ret ;done
Decreasing 16 bit register pairs (dec bc ) doesn't affect the
zero or carry flags. We can use Logical
Operators to see if any bits in either b or c
are set with or .
| ld bc,1000/2 ;we are only doing every other byte
ld hl,$8000 ;address to start at
ld de,$1234 ;what to write
loop:
ld (hl),d ;load $12 in
inc hl ;increase to next address
ld (hl),e ;load $34 in
inc hl ;increase to set up for next loop
dec bc ;decrease counter
ld a,b ;load accumulator with one part
; of address
or c ;are any bits in either b or c set?
jr nz,loop ;if there is a bit in either of
; them, the zero flag will be reset
; and we loop again
ret ;done
| |