简体   繁体   English

68K按钮

[英]Push Button on 68K

I want to Write a program to read a value from the push buttons and display that value on the LEDs. 我想编写一个程序来从按钮中读取一个值并在LED上显示该值。 The program should run continuously and as the push buttons are changed, the display changes. 该程序应连续运行,并且随着按钮的改变,显示也会改变。 I tried many ways but it does not show any thing in Could any one help me to know where is the problem. 我尝试了很多方法,但是它没有显示任何内容。有人可以帮助我知道问题出在哪里。

LEDS       EQU     $E00010                 ;LEDS adress
BUTTON     EQU     $E00014                 ;BUTTON address
           ORG     $400                    ;start of program area

START
Loop        MOVE.B  #2,D0                             
            MOVE.B  BUTTON,D1               ;move the value of button to D1   
            MOVE.B  D2,LEDS 
            NOT.B   D1                      ;take NOT to flip the value in order to present it in LEDS                                    
           MOVE.B  D1,D2                    ;move the value to LEDS                        
           SUB.B    #2,D0                   ; if D0 =0 then loop again
            BEQ     Loop                     



          SIMHALT       
            END     START

A few things are missing from this. 一些缺少的东西。

  1. A button is normally a single bit, not a whole byte, so there should be some form of mask applied to the button input. 按钮通常是单个位,而不是整个字节,因此应在按钮输入上应用某种形式的掩码。 Similarly setting an LED normally involves setting a single bit, not a byte, unless it is some form of multicolor LED. 同样,设置LED通常涉及设置一位而不是字节,除非它是某种形式的多色LED。 I am assuming you have 8 push buttons and 8 corresponding LEDs 我假设您有8个按钮和8个相应的LED

  2. The code you have illustrated will run continuously because you load D0 with 2 after the LOOP label, and at the end of the loop you subtract 2 from D0 (which has the value 2) and then loop if that result is equal to zero ie always. 您说明的代码将连续运行,因为在LOOP标签后将D2装入2,然后在循环结束时从D0中减去2(其值为2),如果结果等于零,则循环,即始终。 If you really want a continuous loop, there is no point in using D0 at all. 如果您确实想要连续循环,则根本没有必要使用D0。

     LEDS EQU $E00010 ;LEDS address BUTTON EQU $E00014 ;BUTTON address ORG $400 ;start of program area START LOOP MOVE.B BUTTON,D1 ; Read buttons NOT.B D1 ; LEDs are inverse of button MOVE.B D1,LEDS ; write to LEDs BRA.S LOOP ; do continously SIMHALT ; doesn't get here but still END START 

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

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