我需要编写用户输入无符号数的程序,显示器将指示该数是奇数、偶数还是等于零
我遇到的问题是它在 7 段中显示 Z 的任何数字,这是不正确的所以,我不知道问题出在哪里。谁能帮我解决这个问题。
LEDS EQU $E00010 ;LEDS adress
SW EQU $E00012 ;switch address
BU EQU $E00014 ;button address
one EQU $E00000 ;7 segment display address 1
two EQU $E00002
three EQU $E00004
four EQU $E00006
five EQU $E00008
six EQU $E0000A
seven EQU $E0000C
eight EQU $E0000E
ORG $400 ;start of program area
START
Loop
MOVE.B D0,LEDS
MOVE.B SW,D1
MOVE.B BU,D2
MOVE.B #0,D3
MOVE.B #0,D0 ; LEDS is off
MOVE.B #0,one ;7 segment is off
MOVE.B #0,two
MOVE.B #0,three
MOVE.B #0,four
MOVE.B #0,five
MOVE.B #0,six
MOVE.B #0,seven
MOVE.B #0,eight
MOVE.B #%1101101,one ;display S on 7 segment
NOT.B D2 ; flip value of button
CMP.B #%00000001,D2 ;if the right button is clicked
BNE Loop
MOVE.B D1,D0 ;THEN MOVE SWICH VALUES ON LEDS
MOVE.B D0,LEDS
MOVE.B #0,one
CMP.B D1,D3
BEQ ZERO
DIVS.W #2,D1
CMP.B D1,D3 ;IF D1=D3 WHICH ZERO, THEN
BEQ EVEN ; NUMBER IS ODD
BRA ODD ; ELSE DISPLAY EVEM
EVEN MOVE.B #%1111001,one
ODD MOVE.B #%0111111,one
ZERO MOVE.B #%1011001,one
END START