0

I'm working on a program in assembly (in Easy68K) that prompts a user to enter a memory address. The program then converts each of those ASCII chars into their hex equivalents. I can convert the hex just fine, but I'm running into a problem.

If the user enters A234567F, this is stored (in A1) as 8 bytes, but the valid memory address hex equivalent is only 4 bytes (2 words, 1 longword). I can iterate through each character and convert it to its hex-digit equivalent, no problem. But I can't figure out how to "concatenate" them together, so to speak.

I don't want there to be a separate byte of storage for "A" and a separate byte of storage for "2". I want "A2" to be stored in the same byte of storage.

And so, in this example, what I'd like is for the storage to look like this for this example:

Memory address $00000000 should hold the value $A2.

$00000001 holds $34

$00000002 holds $56

$00000003 holds $7F

Then, if I do a MOVE.L starting from address $00000000 into D1, then D1 would contain the value $A234567F.

How can I do this?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Tyler M.
  • 115
  • 1
  • 1
  • 11
  • 2
    Shift by 4 bits then add the next hex digit. – Jester Feb 24 '20 at 01:11
  • It sounds like the user input already *is* in hex (a serialization format for binary numbers), and you want to deserialize it into a single binary integer in a register. Not convert *to* hex. – Peter Cordes Feb 24 '20 at 08:58
  • @Jester Thank you! I don't naturally see the answer when it comes to bit-shifting, but this is exactly what I was looking for. – Tyler M. Feb 24 '20 at 21:31
  • @PeterCordes I'm not super sure what you mean, but from my perspective, the user input is the ASCII representation of hex digits, and I want to convert to the numerical representation. Then I want to store that representation in a register, as hex. – Tyler M. Feb 24 '20 at 21:33

0 Answers0