Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Motorola to Intel format
#1
Big Grin
Hi. I am trying to do a conversion from Motorola format to Intel format. For example, how would I convert the hex value (Motorola format) of " 000CB1" into the Intel format of 32.49 (approximate value).?

Thanks,

MG...
Reply
#2
What is it that you want to convert? I've programmed both kinds of machines. If it's data that your converting, decimal and hex data are the same on either machine, and as a matter of fact of most machines, so no conversion is required. The capacity or size of numbers may vary.

If you were looking at data form an IBM mainframe versus an Intel PC, then for character representation you would need to convert from EBCDIC to ASCII. Motorola and Intel, however, both use ASCII.

Please explain what you want. Maybe some sample data would make things clearer.
*****
Reply
#3
Big Grin I must convert binary data that is in Motorola format to the equivalent ASCII data in Intel format. The binary data in Motorola format will be 3 bytes represented in hex. For example, I must convert "000CA3" to an ASCII value in Intel format.

Sorry for the confusion.

Thanks,

MG...
Reply
#4
ASCII is 7 bits, extended ASCII is 8 bits. We'll assume that you mean extended ASCII, which is the one in use almost everywhere. You would get 3 ascii codes out of 3 bytes. You just need to get every two chars.

Code:
motorola$="000CA3"
PRINT "ASCII 1 = ";VAL("&H"+LEFT$(motorola$,2)); " = ";CHR$(VAL("&H"+LEFT$(motorola$,2))
PRINT "ASCII 2 = ";VAL("&H"+MID$(motorola$,3,2));" = ";CHR$(VAL("&H"+MID$(motorola$,3,2))
PRINT "ASCII 3 = ";VAL("&H"+RIGHT$(motorola$,2)) " = ";CHR$(VAL("&H"+RIGHT$(motorola$,2))

You can elaborate on those formulae to make a SUB.

Aside, you maybe mean that motorola and intel use different endians. A 2 byte integer (for example "0xABCD") in Intels is stored in memory "0xCD" first and "0xAB" in the next byte, whilst in Motorolas is stored "0xAB" first and "0xCD" in the next byte.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
Ah yes, I now recall all that nightmare about how different machines store a word. The right half-word and the left half-word, or the most significant byte and the least significant byte ---- which gets stored where in memory? Haven't had to think about this stuff since 1979.
Sorry, I'm of no help here.
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)