Help! 5 hours and 19 errors. EASy68k coding Homework.

Thread Starter

EmonMaimon

Joined Dec 9, 2015
6
Hi, I am Emon and it is my first time using EASy68k for a subject this semester. I don't have any experience using this program except for the examples given by the lecturer.

I've tried hard (seriously my brain is about to explode) and I've spent more than 5 hours on this 1 question and after multiple trails and errors I still can't figure out the right coding. :(

Please help point out my mistakes. :oops:

ORG $1000
START: ; first instruction of program
MOVE.B #%00000000, $E00012

MULA
CMP.B #%00000000, $E00012
BEQ SAL_LOW
BNE SAL_HIGH

SAL_LOW
BEQ DISPLAY_NOTHING
BNE SAL_HIGH

DISPLAY_NOTHING
MOVE.B #%00000000, $E00000
BRA MULA

SAL_HIGH
CMP.B #%00000001, $E00012
AND.B #%11000000, $E00012
BEQ DISPLAY_RETRACT
BNE S
BRA SAL_HIGH

DISPLAY_RETRACT
CMP.B $%00000000, $E00000
MOVE.B $%00110001, D6
MOVE.B $%01111001, D5
MOVE.B $%00000111, D4
MOVE.B $%00110001, D3
MOVE.B $%01110111, D2
MOVE.B $%00111001, D1
MOVE.B $%00000111, D0

S
CMP.B #%00000001, $E00012
NOT.B #%11000000, $E00012
BEQ DISPLAY_OUT
BNE SS
BRA S

DISPLAY_OUT
CMP.B $%00000000, $E00000
MOVE.B $%00111111, D2
MOVE.B $%00111110, D1
MOVE.B $%00000111, D0

SS
CMP.B #%00000001, $E00012
ORI.B #%10000000, $E00012
BEQ DISPLAY_ERROR
BRA SS


DISPLAY_ERROR
CMP.B $%00000000, $E00000
MOVE.B $%01111001, D4
MOVE.B $%00110001, D3
MOVE.B $%00110001, D2
MOVE.B $%00111111, D1
MOVE.B $%00110001, D0
BEQ PB
BRA PB

PB
CMP.B #$00000000, $E00012
BEQ DISPLAY_NOTHING
BNE S


*-----------------------------------------------------------
* A
* -----
* F| |B
* | G |
* -----
* E| |C
* | D |
* ----- .H
*
* Bit Number 7 6 5 4 3 2 1 0
* Segment H G F E D C B A

* bit patterns to form digits on readout
digits:
dc.b $3F digit 0
dc.b $06 digit 1
dc.b $5B digit 2
dc.b $4F digit 3
dc.b $66 digit 4
dc.b $6D digit 5
dc.b $7D digit 6
dc.b $07 digit 7
dc.b $7F digit 8
dc.b $6F digit 9
dc.b $77 digit A
dc.b $7C digit B
dc.b $39 digit C
dc.b $5E digit D
dc.b $79 digit E
dc.b $71 digit F

ds.w 0 force word boundary

*----------------------------------------------------------
 

WBahn

Joined Mar 31, 2012
29,978
How do you get a 7-segment display to display text messages?

I know it is a contrived problem (which is fine), but the notion that an altitude sensor can tell you if you are flying or parking is ludicrous. A plane can be parked at a couple kilometers above sea level or it could be a couple kilometers above the ground. Normally WOW sensors (weight-on-wheels) are used.
 

WBahn

Joined Mar 31, 2012
29,978
Okay (and thanks). Is there a 7-seg pattern for every letter of the alphabet, or did they just get lucky? Since there are only 128 possible patterns and since most patterns are not going to be recognizable as a character, I'm guessing that there aren't 36 distinct patters (one for each letter and each digit) and that some are repeated, requiring the reader to be able to choose the correct ones from context.

(And I have the feeling that they are not actually supposed to do this, but that they are using a generic notion of a display.)
 

djsfantasi

Joined Apr 11, 2010
9,156
Like this, perhaps? Just picked this coding at random, but it makes my point.
7segment.png
Note that many are a stretch, but by choosing a method consistently (like M and W) and in context of the more obvious letters (A, C, F, H, J, L, O, P, S) , plus aided by lowercase - it can produce a semi-readable output.
 

Thread Starter

EmonMaimon

Joined Dec 9, 2015
6
How do you get a 7-segment display to display text messages?

I know it is a contrived problem (which is fine), but the notion that an altitude sensor can tell you if you are flying or parking is ludicrous. A plane can be parked at a couple kilometers above sea level or it could be a couple kilometers above the ground. Normally WOW sensors (weight-on-wheels) are used.
Well, its just a basic homework so I guess the question is fine. Plus this is not my core subject. :/
 

absf

Joined Dec 29, 2010
1,968
I put your program onto the 68K EDASM and I got 63 errors.:D

You have to put some comments on each of the lines so people can understand what you're trying to do...

I dont know what are these addresses $E00012 and $E00000 for. Can you elaborate a little bit?

Do you think the following codes

Code:
MOVE.B $%01111001, D4
MOVE.B $%00110001, D3
MOVE.B $%00110001, D2
MOVE.B $%00111111, D1
MOVE.B $%00110001, D0
is the same as

Code:
MOVE.B #%01111001, D4
MOVE.B #%00110001, D3
MOVE.B #%00110001, D2
MOVE.B #%00111111, D1
MOVE.B #%00110001, D0
Allen

[ps] I am not an expert on 68000. In fact, I've never used a 68k before.
 
Last edited:

Thread Starter

EmonMaimon

Joined Dec 9, 2015
6
I put your program onto the 68K EDASM and I got 63 errors.:D

You have to put some comments on each of the lines so people can understand what you're trying to do...

I dont know what are these addresses $E00012 and $E00000 for. Can you elaborate a little bit?

Do you think the following codes

Code:
MOVE.B $%01111001, D4
MOVE.B $%00110001, D3
MOVE.B $%00110001, D2
MOVE.B $%00111111, D1
MOVE.B $%00110001, D0
is the same as

Code:
MOVE.B #%01111001, D4
MOVE.B #%00110001, D3
MOVE.B #%00110001, D2
MOVE.B #%00111111, D1
MOVE.B #%00110001, D0
Allen

[ps] I am not an expert on 68000. In fact, I've never used a 68k before.
Okay I mixed up the # and $ sign. Thank you! :D
 

absf

Joined Dec 29, 2010
1,968
There is something wrong with your display routine too...

I read the "help" file of the simulator and the address of each digit to be displayed are in the range $E00000-$E0000E.

easy68k_hw.PNG

easy68k_hw_address.PNG

But in your program, you just put the digit to be displayed in the same address $E00000....

So I wrote this simple subroutine for you....

HTML:
DISPLAY     EQU $E00000         ;ADDRESS OF HARDWARE 7 SEG LED

LED:
    MOVE.B    D6,DISPLAY        ;First digit on the left
    MOVE.B    D5,DISPLAY+2
    MOVE.B    D4,DISPLAY+4
    MOVE.B    D3,DISPLAY+6
    MOVE.B    D2,DISPLAY+8
    MOVE.B    D1,DISPLAY+10
    MOVE.B    D0,DISPLAY+12     ;7th digit on the right
    RTS
Just link your program to this subroutine with the instruction

HTML:
   BSR   LED   ;to display what is in D0-D6
and you will get the messages that you want to see.

Allen
 

absf

Joined Dec 29, 2010
1,968
Of course, there are more logic problems in your program. One thing I am not sure is....

Are you using the switches in $E00012 as your sensors S1, S2 and the AL?

And if so, you have to state which bit is S1, and which bit is S2 ......... in your program. You cannot let people go guess when they are reading or marking your work.

And where is the PB? Was it not needed?

You dont seem to understand the use of CMP instruction. It just compares the source with destination, and then it changes the flags in status register without destroying the content of the source/destination as in CMP [BWL] s,d. Read the datasheet of 68000 and you'll understand better. The cheatsheet in the help PDF is only good for reference.

Allen
 
Last edited:

Thread Starter

EmonMaimon

Joined Dec 9, 2015
6
Of course, there are more logic problems in your program. One thing I am not sure is....

Are you using the switches in $E00012 as your sensors S1, S2 and the AL?

And if so, you have to state which bit is S1, and which bit is S2 ......... in your program. You cannot let people go guess when they are reading or marking your work.

And where is the PB? Was it not needed?

You dont seem to understand the use of CMP instruction. It just compares the source with destination, and then it changes the flags in status register without destroying the content of the source/destination as in CMP [BWL] s,d. Read the datasheet of 68000 and you'll understand better. The cheatsheet in the help PDF is only good for reference.

Allen
Thank you Allen for your input. I redo the coding last night and tweak a little bit this morning and I finally got it! :D

Will keep in mind to write the description for each line :D
 

Attachments

Top