我需要编写用户输入无符号数字的程序,显示屏将指示此数字是否为奇数,偶数或等于零
我得到的问题是它在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
答案 0 :(得分:0)
此:
BEQ EVEN ; NUMBER IS ODD
看起来应该是:
BEQ ODD ; NUMBER IS ODD