Motorola 68HC11 Programming - Strings.

Discussion in 'Programmer's Corner' started by Zaraphrax, May 26, 2009.

  1. Zaraphrax

    Thread Starter Active Member

    Mar 21, 2009
    Hi guys,

    I'm currently working on programming a 68HC11. Here is what I am trying to do.

    Imagine 5 LEDS (PB0 - PB4). And, an abitrary number (lets assume 123456789).

    Now, imagine that each number is represented by 5 bit binary:

    0 - 00000
    1 - 00001
    2- 00010
    3 - 00011


    So, expressed in code:

    Code ( (Unknown Language)):
    2. prb    equ    $1004      Peripheral Port B
    3. ddrb    equ    $1006    Data direction register B
    6.     org    $0000
    8. thepattern    fcb    %00000   pattern 0
    9.              fcb    %00001    pattern 1
    10.              fcb    %00010    pattern 2
    11.              fcb    %00011    pattern 3
    12.              fcb    %00100    pattern 4
    13.              fcb    %10101    pattern 5
    14.              fcb    %00110    pattern 6
    15.              fcb    %00111    pattern 7
    16.              fcb    %01000    pattern 8
    17.              fcb    %01001    pattern 9
    19. NUMBER    fcc    '123456789#'    number with END character
    Now, note at the end of number, I've appended a "#". This is to denote the end of the string. I know how this would work, I'd have the program check to see that the current characters ASCII code (as stored by FCC) is not equal to 23 (hexadecimal).

    What I do not understand is how I pick out each particular bit from the "NUMBER" string, and match it to it's binary pattern (obviously I need some form of a loop, and a test to check for what I outlined above, but the exact method is what I do not understand). Obviously then, since the 68HC11 uses memory addressed I/O, it's just a matter of storing the pattern to prb. How would I go about doing this? Any help is appreciated.
  2. Zaraphrax

    Thread Starter Active Member

    Mar 21, 2009
    Bump. Can anybody help me out here? Am I not being clear enough? Or, have I put this in the wrong section?
  3. nanobyte

    Senior Member

    May 26, 2004
    How are thre LEDs being used? Are you turning them on and off with switches or the code?
  4. Mark44

    Well-Known Member

    Nov 26, 2007
    I don't know 68HC11 assembly, but I know a little 68000 assembly and a lot of x86 assembly. You don't need to pick out the digits in NUMBER bit by bit - they are character data stored in 8-bit bytes. When you start out, the offset of NUMBER is stored in some register, and you add the current value of some index register to get you to a particular byte, then read the byte into memory. After that, compare the byte you just read to 23 (your end of string character). If equal, you're at the end of the string, so you can probably exit your loop. If not equal, do your conversion to a 5-bit quantity that you send to the LEDs, and then increment your index register so that in the next loop iteration you're ready to read the next byte.