Motorola 68HC11 Programming.

Discussion in 'Homework Help' started by Zaraphrax, May 30, 2009.

  1. Zaraphrax

    Thread Starter Active Member

    Mar 21, 2009
    Hi all.

    I've written the following programming:

    Code ( (Unknown Language)):
    2. prb    equ    $1004    Peripheral Port B
    3. ddrb    equ    $1006    Data direction register B
    5.     org    $0000
    7. hexpat    fcb    %00110    Barcode pattern 0
    8.         fcb     %10001    Barcode pattern 1
    9.     fcb    %01001    Barcode pattern 2
    10.     fcb    %11000    Barcode pattern 3
    11.     fcb    %00101    Barcode pattern 4
    12.     fcb    %10100    Barcode pattern    5
    13.     fcb    %01100    Barcode pattern 6
    14.     fcb    %00011    Barcode pattern 7
    15.     fcb    %10010    Barcode pattern 8
    16.     fcb    %01010    Barcode pattern 9
    18. NUMBER    fcc    '7348284923920#'    student number with EOD marker
    19. EOD    equ    $23
    22.     org    $00a0
    23. start    jsr    INITIALISE    Goto the INITIALISE sub-routine.
    24.     ldy    #number        Point index register Y to the first digit of the number.
    25.     jsr    GETBYTE
    28. HALT    clra
    29.     staa    prb    Turn off LEDs.
    30.     jmp    HALT    Halt.
    37. INITIALISE    clra
    38.         ldaa    $1F    Store 00011111 to AccA
    39.         staa    ddrb    Sets pins 0-4 on Data Direction Register B to High (Output)
    40.         rts        Return to main program
    42. GETBYTE        ldab    0.y    Put the first digit into Acc B.
    43.         clra
    44.         staa    prb
    45.         cmpb    #EOD    Compare with the EOD marker.
    46.         beq    HALT    If this is the EOD, goto HALT.
    47.         ldx    #hexpat    Load hexpat to Index Reg X.
    48.         abx        Add the offset to index register X (add AccB to Index Reg X)
    49.         ldaa    0,x    Get the barcode pattern into AccA
    50.         staa    prb    Output to the LEDs
    51.         iny        Increment Index Register Y to point to the next digit.
    52.         bra    GETBYTE    Keep repeating until EOD marker is reached.
    Basically, it grabs each of the digits in "number", matches it with the 5-bit binary pattern in hexpat and outputs the bits to 5 LEDs. It's supposed to keep repeating until it hits the "#", which is the EOD marker. But for some reason, it grabs the first digit every time and just sits there displaying a 0 over and over again (which is represented by 00110 on the LEDs). I followed the same method used in an experiment we did in class to grab each byte out of the string, and it worked fine then, but now it doesn't. What have I done wrong?

    Any help is appreciated.
  2. howartthou

    Active Member

    Apr 18, 2009
    Hmmmm, I haven't done any assembler programming for a long time, if thats the language you are using?

    All I can suggest is you put a line of code that displays the value of your variables after you update them and some other messages that state where you are in the code.

    I am assuming you know how to print a message on screen or in a file as the program runs?

    You could also try and use an interactive debugger if you have one? Otherwise just put display messages in each subroutine, the old fashioned way to debug.

    Sorry I can't help more but I really am out of touch with this programming language...
  3. Wendy


    Mar 24, 2008
    That is assembly, one step above the ML coding the CPU uses. In this case a 68HC11.

    I have done 6502 (and derivatives) and Z80, but not this CPU. Gave away an Altair 6800 not to long ago, but that don't count (it was dead).
  4. RiJoRI

    Well-Known Member

    Aug 15, 2007
    "The micro is faster than the eye."

    I'll bet that what is happening is that the program IS working, it just displays the digits to fast for us slow humans to see them.

    Try adding a delay loop just before the "INY" command.