简体   繁体   English

如果在68k中声明

[英]If else statement in 68k

I need to write program that the user enters an unsigned number and the display will indicate if this number is odd, even or equal to zero 我需要编写程序,让用户输入一个无符号数字,并且显示屏将指示该数字是否为奇数,偶数或等于零

The problem I got is at any number it display Z in 7segment, which is not correct So, I do not where is the problem. 我遇到的问题是在7段显示Z的任何数字,这是不正确的,所以我不知道问题出在哪里。 Can any one help me to fix the problem. 谁能帮我解决问题。

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  

This: 这个:

BEQ     EVEN                      ; NUMBER IS ODD

Looks like it should be: 看起来应该是:

BEQ     ODD                      ; NUMBER IS ODD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM