EASy68K  
It is currently Tue Apr 25, 2017 2:28 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: LED display
PostPosted: Tue Apr 05, 2011 9:59 am 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
hi, i want to display the LED at address $E00010 by using easy 68k simulator. is not opening with me when i try to run the simulator !!

here is my instruct:

Code:
*----------------------------------------------------------
* Program    :PRiOG2.X68
* Written by :salim abdullah al-farsi
* Date       :05.04.2011
* Description:Displaying the results in binary numbers
*-----------------------------------------------------------
   ORG      $1000
START   LEA      List,A0 ;A0 is set to point at the lisrt
        MOVE.B   #5,D0   ;Use D0 as loop counter and set it to 5
        CLR.B    D1      ;Clear the total in D1 before we start
Loop    ADD.B    (A0),D1 ;Add the number pointed at by A0 to D1
        ADD.L    #1,A0   ;Point to the next number in the list
        SUB.B    #1,D0   ;Decrement the counter
        BNE      Loop    ;If we haven't reached zero go round again
        MOVE.B   D1,$E00010
        MOVE.B   #9,D0
        TRAP     #15       ;Halt Simulator
List    DC.B     1,4,3,6,7 ;here's the data to add
        END      START

[Edit Admin: Moved to this thread, formatted code block.
Corrected 1st line comment error]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 1:08 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Is the assembler giving an error?

If I fix the first line comment it works fine and displays $15 (00010101) in the 8 LED's.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 5:09 pm 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
but what is the error here that you found in the first command?
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 5:32 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
The way you cut-n-pasted the first comment line does not start with a '*'

Assembles and simulates without a problem here, single steps fine, I'm not sure I understand where/what the problem is.

Please restate your problem defining what is/is not happening, and what errors or warnings you get. Provide some annotated screen shots if you think that will help us understand the problem you are seeing.


Top
 Profile  
 
 Post subject: Run Program
PostPosted: Wed Apr 06, 2011 5:17 am 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
ok,thanks alot...for this program.is keep telling me that there is an error in line 38 and 40,but i cant identify what type of error. can you guide me to find the error?...thanks.






Code:
*-----------------------------------------------------------
* Program    :PROG5.X68
* Written by :salim abdullah al-farsi
* Date       :05.04.2011
* Description:Displaying the results in binary numbers
*-----------------------------------------------------------
   ORG      $1000
START   MOVE.B   #0,$E00010
        JSR      Delay
        LEA      List,A0 ;A0 is set to point at the lisrt
        MOVE.B   #5,D0   ;Use D0 as loop counter and set it to 5
        CLR.B    D1      ;Clear the total in D1 before we start
Loop    ADD.B    (A0),D1 ;Add the number pointed at by A0 to D1
        ADD.L    #1,A0   ;Point to the next number in the list
        SUB.B    #1,D0   ;Decrement the counter
        BNE      Loop    ;If we haven't reached zero go round again
        MOVE.B   D1,$E00010
        JSR      WORD2DEC
        MOVE.B   #9,D0
        TRAP     #15       ;Halt Simulator
List    DC.B     1,4,3,6,7 ;here's the data to add.
Delay   Move.L   #$1FFFFF,d7
Delay1  SUBI.L   #1,D7
        BNE      Delay1
        RTS
       
SS8     EQU      $E00000
WORD2DEC
        MOVE.B   #10,D3
        MOVEA.L  #SS8+2*0,A2
        JSR      Segment7
blank

        MOVEA.L  #SS8+2*1,A2
        JSR      Segment7
blank

        MOVEA.L  #SS8+2*2,A2
        JSR      Segment7
blank

        DIVU     #10000,D1
        MOVE.B   D1,D3
        MOVEA.L  #SS8+2*3,A2
        JSR      Segment7
       
        LSR.L    #8,D1
        LSR.L    #8,D1
         DIVU     #1000,D1
        MOVE.B   D1,D3
        MOVEA.L  #SS8+2*4,A2
        JSR      Segment7
       
        LSR.L    #8,D1
        LSR.L    #8,D1
         DIVU     #100,D1
        MOVE.B   D1,D3
        MOVEA.L  #SS8+2*5,A2
        JSR      Segment7
       
        LSR.L    #8,D1
        LSR.L    #8,D1
         DIVU     #10,D1
        MOVE.B   D1,D3
        MOVEA.L  #SS8+2*6,A2
        JSR      Segment7
       
        LSR.L    #8,D1
        LSR.L    #8,D1
        MOVE.B   D1,D3
        MOVEA.L  #SS8+2*7,A2
        JSR      Segment7
        RTS
       
*Seven Segment digital display conversion table       
*-----------------------------------------------------------
*         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 the respective digis character for LEDs wired as common cathode.
digits:                                            ;look-up table
   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  $00         digit off
   dc.b  $40         dash

   ds.w  0            force word boundary

*----------------------------------------------------------
* Display a digit on the 7-segment display
* Pre:  D3.B contains 1 digit to display
*       A2 points to 7-segment LED to use
* Post: A2 points to next 7-segment LED

segment7:
   movem.l   d3/a0,-(a7)      save registers
   lea digits,a0      bit pattern table
   and.l   #$00ff,d3
   move.b   (a0,d3),(a2)   display digit
   adda.l   #2,a2
   movem.l   (a7)+,d3/a0      restore registers
   rts
   
      END      START

[Admin: Added code format]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2011 12:45 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
This is different code.

The assembly problem is the term "blank", this is being treated as a label because it's not a valid instruction, and you use it 3 times. What do you think it should be doing? Why did you put it there? I'd guess but there are no comments.

Edit : WORD2DEC makes more sense with the formatting, I see what you are doing with the quotient/remainder now.


Last edited by clive on Wed Apr 06, 2011 3:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: easy68k
PostPosted: Wed Apr 06, 2011 2:33 pm 
Offline

Joined: Sun Mar 06, 2011 2:54 am
Posts: 15
Location: Malaysia
ok,thanks.

i was mistaken to put the word blank. now it is running. thanks for your advice.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2011 5:27 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
This should work also, and doesn't have leading zeros on the 7-segments

Code:
        ORG     $1000
START   MOVE.B  #0,$E00010
        LEA     List,A0         ;A0 is set to point at the lisrt
        MOVE.B  #5-1,D0         ;Use D0 as loop counter and set it to 5
        CLR.B   D1              ;Clear the total in D1 before we start
Loop    ADD.B   (A0)+,D1        ;Add the number pointed at by A0 to D1
        DBRA    D0,Loop         ;If we haven't reached zero go round again
        MOVE.B  D1,$E00010
        JSR     WORD2DEC
        MOVE.B  #9,D0
        TRAP    #15             ;Halt Simulator

List    DC.B    1,4,3,6,7       ;here's the data to add.

        ds.w    0               ;force word boundary

SS8     EQU      $E00000

WORD2DEC
        CLR.B   D3
        MOVEA.L #SS8,A2
        MOVE.B  D3,0(A2)        ; Clear Leading digits
        MOVE.B  D3,2(A2)
        MOVE.B  D3,4(A2)
        MOVE.B  D3,6(A2)
        MOVE.B  D3,8(A2)
        MOVE.B  D3,10(A2)
        MOVE.B  D3,12(A2)

        MOVEA.L  #SS8+7*2,A2    ; Seventh Digit

w2dloop DIVU    #10,D1          ; D1:LOW = D1/10, D1:HIGH = D1%10
        MOVE.L  D1,D3           ; Get remainder into D3
        SWAP.W  D3
        JSR     Segment7
        SUBA.L  #4,A2           ; Step back 1 digit, plus overcome advance by Segment7
        AND.L   #$FFFF,D1       ; Clear off remainder
        BNE     w2dloop         ; loop if more significant digits

        RTS

*Seven Segment digital display conversion table
*-----------------------------------------------------------
*         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 the respective digis character for LEDs wired as common cathode.
digits:                                            ;look-up table
        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    $00             digit off
        dc.b    $40             dash

        ds.w    0               force word boundary

*----------------------------------------------------------
* Display a digit on the 7-segment display
* Pre:  D3.B contains 1 digit to display
*       A2 points to 7-segment LED to use
* Post: A2 points to next 7-segment LED

segment7:
        movem.l d3/a0,-(a7)     save registers
        lea     digits,a0       bit pattern table
        and.l   #$00ff,d3
        move.b  (a0,d3),(a2)    display digit
        adda.l  #2,a2
        movem.l (a7)+,d3/a0     restore registers
        rts

        END     START


Top
 Profile  
 
 Post subject: Re: LED display
PostPosted: Sat Oct 12, 2013 11:30 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1036
Location: Monroe County Community College, Monroe Michigan, U.S.A.
The above code works. The results are displayed on the LEDs in the hardware window. The hardware window may be displayed by selecting Hardware from the View menu in the simulator. The hardware window may also be displayed programmatically with trap task 32, D1=0.

_________________
Prof. Kelly


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
Powered by phpBB® Forum Software © phpBB Group