在探索与 Z80 游戏的操纵杆连接时,我得到了这个代码,当我按向上、向左或向右时,它应该打印 1 个字母。但是由于某种原因,当我按左时它会打印lru,当我按右时它会打印ru,然后u按向上。
org 32768
loop ld bc,31 ; Kempston joystick port.
in a,(c) ; read input.
and 2 ; check "left" bit.
call nz,joyl ; move left.
in a,(c) ; read input.
and 1 ; test "right" bit.
call nz,joyr ; move right.
in a,(c) ; read input.
and 8 ; check "up" bit.
call nz,joyu ; move up.
in a,(c) ; read input.
and 4 ; check "down" bit.
halt
jp loop
joyl ld de,sl ; address of string
ld bc,eostrl-sl ; length of string to print
call 8252
ret
joyr ld de,sr
ld bc,eostrr-sr
call 8252
ret
joyu ld de,su
ld bc,eostru-su
call 8252
ret
sl defb "l"
eostrl equ $
sr defb "r"
eostrr equ $
su defb "u"
eostru equ $
具有唯一字符串长度标签的三个不同“变量”,但为什么调用joyl打印所有三个字母而不是一个?