Assembly 试图从68hc11上的DIP开关向LCD显示两个数字

Assembly 试图从68hc11上的DIP开关向LCD显示两个数字,assembly,68hc11,Assembly,68hc11,我试图弄清楚如何在husky 11板上显示从双列直插式开关读取的两个十六进制数字。我们的实验室只要求我们显示1个数字,但我很好奇如何显示2个数字。我只想在我按下Pa0按钮时读取开关,就像在我的第一个实验室中一样。下面的代码在我按下Pa0按钮时显示这两个值,但最右边的lcd(显示较低的半字节)在我松开按钮后立即关闭。我该如何解决这个问题?我尝试过几次不同的延迟,但都不起作用。谢谢 ;Simple program written to displa

我试图弄清楚如何在husky 11板上显示从双列直插式开关读取的两个十六进制数字。我们的实验室只要求我们显示1个数字,但我很好奇如何显示2个数字。我只想在我按下Pa0按钮时读取开关,就像在我的第一个实验室中一样。下面的代码在我按下Pa0按钮时显示这两个值,但最右边的lcd(显示较低的半字节)在我松开按钮后立即关闭。我该如何解决这个问题?我尝试过几次不同的延迟,但都不起作用。谢谢

                          ;Simple program written to display in Hex the values of the upper 4 and lower for dipswitches on the built LCD's.
                  ;Only load values when button PA0 is pressed.

    REGBAS  EQU $1000   ;register block pointer, also represents address for PORT A
    PORTB   EQU     $1004   ;port B starting at $1004
    PORTD   EQU     $08     ;port D starting at $1008
    DDRD    EQU     $09     ;port direction for portd
    PORTC   EQU     $1003   ;dip switch

    ; the BCD codes for hexadecimal numbers 0 through F
    SEG     FCB     $3f, $06, $5b, $4f, $66, $6d, $7d, $07
FCB $7f, $67, $77, $39, $7c, $5e, $79, $71
    DIP     RMB     1       ;reserve space to store the 8-bit value read from the switch

ORG     $D000       ;user code stored starting at address $D000
LDX     #REGBAS         ;load IX with the address of PORT A
BSET    DDRD,X $0F      ;configure the data direction register of port D to use the lower 4-bits as output data
BSET    PORTD,X $3B     ;set bits 2-5 of port D (recall that they control the 4 seven segment displays)

    WAIT    LDAA    REGBAS          ;wait for PA0 to be press (if not pressed the DIP switch value will not be read)
ANDA    #$01
CMPA    #$00
BNE     WAIT
READ    LDAB    PORTC           ;Once PA0 is pressed read the DIP switch value
LDX     #DIP
STAB    0,X             ;store a copy of the read 8-bit value at the reserved memory location (DIP)
ANDB    #$0F            ;now that you have a copy of the read value in memory, modify the contents of ACC B
            ;so that lower nibble represents the 4-bit value read from lower switches (1-4)
    LDY     #SEG            ;prepare to read the BCD code of this lower 4-bit value from the switch
ABY
LDAA    0,Y
 ;Enable the rightmost seven segment display to display the value of the lower 4-bit of the switch
LDX     #REGBAS
BCLR    PORTD,X 4
BSET    PORTD,X 8
BSET    PORTD,X $10
BSET    PORTD,X $20
LDX     #PORTB          ;send the corresponding hexadecimal value of the nibble to port B for displaying
STAA    0,X
ldy    #$ff
delay   dey                     ;Delay to hold the LCD on
bne     delay
LDX     #DIP
STAB    0,X             ;store a copy of the read 8-bit value at the reserved memory location (DIP)
ANDB    #$F0            ;now that you have a copy of the read value in memory, modify the contents of ACC B
            ;so that lower nibble represents the 4-bit value read from lower switches (1-4)
    LDY     #SEG            ;prepare to read the BCD code of this lower 4-bit value from the switch
ABY
LDAA    0,Y
    LDX     #DIP
LDAB    0,X
LDY     #SEG            ;prepare to read the corresponding BCD code of this nibble from your BCD code table
ABY
LDAA    0,Y
LDX     #REGBAS
BSET    PORTD,X 4       ;setup the corresponding bits of PORT D that control the second from right seven segment display
BCLR    PORTD,X 8
BSET    PORTD,X $10
BSET    PORTD,X $20
LDX     #PORTB          ;prepare to send the BCD code for the upper nibble to PORT B (the seven segment display)
STAA    0,X
ldy     #$ff
bne     WAIT

BRA     READ

    END

您需要重构代码以使其更清晰。当X寄存器可用时(并产生更短/更快的指令),不需要使用Y寄存器。一个直接的逻辑错误出现在
LDY#$FF
末尾,然后是
BNE WAIT
,这可能是您的问题。但是,我没有对您的代码进行更深入的研究。您不需要通过寄存器X或Y访问
DIP
变量。您可以从它加载或直接存储到它。例如,您可以执行
LDAA-DIP