EASy68K  
It is currently Fri Jun 05, 2020 3:51 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: testing the bit
PostPosted: Tue Aug 17, 2010 6:00 pm 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
I want to write a code to test every bits of the LED. the specification is that if any LEDs are ON except LED0, then it will display Door Open, if LED7 - LED1 are OFF and only LED0 is ON, then it will display Pass. example, if LED1 and LED0 are ON, then it will display Door Open. my code is as followed:

CLR.B D0
MOVE.B SWITCH,D0
NOT.B D0
MOVE.B D0,LED ; let's say only LED1 and LED0 are ON
MOVE.L D0,A3

MOVE.B #7,D2
DOPEN BTST D2,(A3)
BNE DOPEN_MSG ; display the msg 'Door Open'
SUB.B #1,D2
CMPI #0,D2
BEQ PASS_MSG ; display the msg 'Pass'
BRA DOPEN

my problem is, when LED1 and LED0 are ON, the desired answer is the program will display Door Open, but in this case, it displayed Pass. May i know why???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2010 7:09 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Your use of A3 and (A3) are not appropriate.

You load A3 with the bit vector sent to the LEDs, and then use it as an address from which to load a value in the bit test, rather than use the value itself.

Something like this would make more sense.

Code:
        CLR.B   D0
        MOVE.B  SWITCH,D0  ; Load Switch register
        NOT.B   D0  ; Invert
        MOVE.B  D0,LED  ; let's say only LED1 and LED0 are ON

        MOVE.B  #7,D2
DOPEN   BTST    D2,D0  ; Bit test data driving LED's
        BNE     DOPEN_MSG ; display the msg 'Door Open'
        SUB.B   #1,D2
        CMPI    #0,D2
        BEQ     PASS_MSG ; display the msg 'Pass'
        BRA     DOPEN


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 28, 2010 5:44 am 
Offline
User avatar

Joined: Mon Aug 16, 2010 3:16 pm
Posts: 22
thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group