keyport =1 ;key port
loop:
ld a,%11111110 ;row to check for
out (keyport),a ;send it out to get checked
in a,(keyport) ;collect results
rrca ;put down arrow's bit in
; the carry flag
jr nc,loop ;carry=held down
;if carry...continue
Absolute jumps are 2 clock cycles faster because
the z80 doesn't have to add relative addresses to the
program counter.
Also, by saving the Key
Port value in c , we can access it faster.
| keyport =1 ;key port
ld c,keyport ;faster access later
loop:
ld a,%11111110 ;row to check for
out (c),a ;send it out to get checked
in a,(c) ;collect results
rrca ;put down arrow's bit in
; the carry flag
jp nc,loop ;carry=held down
;if carry...continue
| |