Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Motorolla MC68HC11 Microcontroller-to convert a Hex digit.

Status
Not open for further replies.

NiCeBoY

New Member
Hello,
I am require to write a program module to convert a Hex digit passed to it in the lower nibble of Accumulator A to its ASCII character code. The upper nibble should be treated as "don't care".
Return the ASCII code in Accumulator A and save it in a suitable memory location.
All other CPU register values are to remain unchanged.


Thanks in advance for your help...

Regards...
Edit/Delete Message
 
thats in australia university man...
Can you just give me an idea how to do thisc onversion.
i know how to convert BCD to ASCII..but this one i dnt know...

thanks..
 
Where do they teach 68hc11?
I am going to school here in the USA and I am taking a class that teaches the 68HC11. When I asked why use the 68HC11, I was told that a microcontroller is a microcontroller, it's just that newer ones may have more extras.

To the OP, what dev board are you using?
 
i think i got the steps how to proceed.. can anyone check it out and let me know if its good?

First of all, clear the upper bits by doing an AND with immediate data 0x0F.
Then compare the remaining number with 9. If it's less than or equal to 9, then do an OR with 0x30H and that is the ASCII code.

If the number is greater than 9, then subtract 9 and then do an OR with 0x40H to get the ASCII code.


thanks
 
This is translated From microcip PIC asm:
For pic 16fxxx:

hexconv
addlw 0x100-0x0a
btfss status,c
addlw 0x3A+0x100-0x41
addlw 0x41
return




68hc11:
ANDA#$0F
ADDA #$100-#$0x0a ; check if higher than 9
BCS label; if higher than move to letters
ADDA #$3A+#$100-#$41
label
ADDA #$41
result for 0..9 is A_register +0x100- 0x0A +0x41 = 0x41..0x46 (A..F)
result for A..F is A_register +0x100- 0x0A +0x41 +0x3A+0x100-0x41= 0x30..0x39 (0..9)

This use only A register for conversion
 
Last edited:
can you please explain to me how this line work to check?
ADDA #$100-#$0x0a ; check if higher than 9

because i think should use the CMPA instruction..
thanks you..
 
If the number is higher than 9, it will set the carry bit in the program status word. That is why there is a branch if carry set instruction next.
 
now i have to write a program module to convert a Hex byte passed to it in AccA to its ASCII coded word.
Return the word in AccD and then save it in a suitable area memory.
NB. This module affects AccA & AccB.

Can you help me again please?...

Thanks very much..
 
TAB; copy A to B
-- convert A to hex using previous method
ANDB#$F0
LSRB; if you don't have a "swap nibbles in B" instruction
LSRB
LSRB
LSRB
-- convert to B hex using previous method and instructions for B register
 
Status
Not open for further replies.

Latest threads

Back
Top