Motorola 68HC11 Programming - Strings.

Thread Starter

Zaraphrax

Joined Mar 21, 2009
49
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

etc.

So, expressed in code:

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


    org    $0000

thepattern    fcb    %00000   pattern 0
             fcb    %00001    pattern 1
             fcb    %00010    pattern 2
             fcb    %00011    pattern 3
             fcb    %00100    pattern 4
             fcb    %10101    pattern 5
             fcb    %00110    pattern 6
             fcb    %00111    pattern 7
             fcb    %01000    pattern 8
             fcb    %01001    pattern 9

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.
 

Mark44

Joined Nov 26, 2007
628
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

etc.

So, expressed in code:

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


    org    $0000

thepattern    fcb    %00000   pattern 0
             fcb    %00001    pattern 1
             fcb    %00010    pattern 2
             fcb    %00011    pattern 3
             fcb    %00100    pattern 4
             fcb    %10101    pattern 5
             fcb    %00110    pattern 6
             fcb    %00111    pattern 7
             fcb    %01000    pattern 8
             fcb    %01001    pattern 9

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