0

For Asembly (68hc11) This is an assigment to handle in paper.

Write a program to convert a 16-bit integer unsigned number into an ASCII string representing the number in hexadecimal. The number is in register D0 and the string is in put in memory starting at the address in register A0.

How can i separated the bit number into 4 bits to represent the hex number in assembly, is there an instruction for doing this? I have a problem to visualize the logic of the program, also. After separated the four bits how do i make the assembly to convert it to hex?? And to when I get the hex characters I need to compare them to each ascii possible character??

I really dont know where to start.

user43680
  • 33
  • 6

1 Answers1

3

You can use bitwise shift and masking to separate the 4 bits for each hex digit. Then you can use a lookup table to map them to ascii, or use the fact that 0-9 and A-F are consecutive in the character table.

Jester
  • 56,577
  • 4
  • 81
  • 125
  • ok I get about the bitwise shift, and the lookup table. But not so much about using masking, I haven't use it before. Can you explain a litlle bit more about masking? – user43680 Nov 02 '12 at 03:31
  • Take a look [here](http://en.wikipedia.org/wiki/Mask_(computing)) at the `AND` operation with appropriate bit masks. – David J Nov 02 '12 at 05:43