Qbasicnews.com
February 22, 2020, 07:12:38 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Motorola to Intel format  (Read 7208 times)
MGG
New Member

Posts: 8


« on: August 11, 2004, 10:06:41 PM »

Cheesy
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...
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #1 on: August 14, 2004, 01:27:00 AM »

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.
*****
Logged
MGG
New Member

Posts: 8


« Reply #2 on: August 15, 2004, 06:05:45 PM »

Cheesy 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...
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #3 on: August 15, 2004, 07:32:31 PM »

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

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Moneo
Na_th_an
*****
Posts: 1971


« Reply #4 on: August 21, 2004, 04:15:53 PM »

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.
*****
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!