Motorola 68HC11 Programming.

Thread Starter


Joined Mar 21, 2009
Hi all.

I've written the following programming:

Rich (BB code):
prb    equ    $1004    Peripheral Port B
ddrb    equ    $1006    Data direction register B

    org    $0000

hexpat    fcb    %00110    Barcode pattern 0
        fcb     %10001    Barcode pattern 1
    fcb    %01001    Barcode pattern 2
    fcb    %11000    Barcode pattern 3
    fcb    %00101    Barcode pattern 4
    fcb    %10100    Barcode pattern    5
    fcb    %01100    Barcode pattern 6
    fcb    %00011    Barcode pattern 7
    fcb    %10010    Barcode pattern 8
    fcb    %01010    Barcode pattern 9

NUMBER    fcc    '7348284923920#'    student number with EOD marker
EOD    equ    $23

    org    $00a0
start    jsr    INITIALISE    Goto the INITIALISE sub-routine.
    ldy    #number        Point index register Y to the first digit of the number.
    jsr    GETBYTE

HALT    clra
    staa    prb    Turn off LEDs.
    jmp    HALT    Halt.


        ldaa    $1F    Store 00011111 to AccA
        staa    ddrb    Sets pins 0-4 on Data Direction Register B to High (Output)
        rts        Return to main program

GETBYTE        ldab    0.y    Put the first digit into Acc B.
        staa    prb
        cmpb    #EOD    Compare with the EOD marker.
        beq    HALT    If this is the EOD, goto HALT.
        ldx    #hexpat    Load hexpat to Index Reg X.
        abx        Add the offset to index register X (add AccB to Index Reg X)
        ldaa    0,x    Get the barcode pattern into AccA
        staa    prb    Output to the LEDs
        iny        Increment Index Register Y to point to the next digit.
        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.


Joined 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...


Joined 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).


Joined 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.