EASy68K
http://easy68k.com/EASy68Kforum/

LED display
http://easy68k.com/EASy68Kforum/viewtopic.php?f=5&t=989
Page 1 of 1

Author:  salim [ Tue Apr 05, 2011 9:59 am ]
Post subject:  LED display

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]

Author:  clive [ Tue Apr 05, 2011 1:08 pm ]
Post subject: 

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.

Author:  salim [ Tue Apr 05, 2011 5:09 pm ]
Post subject: 

but what is the error here that you found in the first command?
thanks

Author:  clive [ Tue Apr 05, 2011 5:32 pm ]
Post subject: 

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.

Author:  salim [ Wed Apr 06, 2011 5:17 am ]
Post subject:  Run Program

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]

Author:  clive [ Wed Apr 06, 2011 12:45 pm ]
Post subject: 

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.

Author:  salim [ Wed Apr 06, 2011 2:33 pm ]
Post subject:  easy68k

ok,thanks.

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

Author:  clive [ Wed Apr 06, 2011 5:27 pm ]
Post subject: 

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

Author:  profkelly [ Sat Oct 12, 2013 11:30 am ]
Post subject:  Re: LED display

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/