Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PPC little-endian mode

PPC little-endian mode
Thread Tools
Fresh-Faced Recruit
Join Date: Aug 2001
Status: Offline
Reply With Quote
Jun 12, 2002, 12:42 PM
 
How do I get a program to tell the PPC (G4): "Hey dude, use little-endian mode?"

Just running a small data mining C proggie that I'm developing on my TiBook but will be run on a Wintel POS.
     
Junior Member
Join Date: May 2002
Location: Germany/Heidelberg or Germany/Dresden
Status: Offline
Reply With Quote
Jun 12, 2002, 03:20 PM
 
Sorry, that I can't provide a solution but what is "little-endian mode"?

Lars
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jun 12, 2002, 03:36 PM
 
Little-endian and big-endian refer to how numbers are interpreted by the processor. The bits that form a number can be interpreted either right-to-left or left-to-right.

But, you almost certainly don't want to try switching the processor's endian-ness while running a program. The only safe way to do it would be to get the kernel to switch endian-ness when giving your program the context and switch back when switching your program out. And you wouldn't be able to call any library functions.

But anyway, it's probably something that's set in hardware, or that you need to be in supervisor mode on the processor to change.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Senior User
Join Date: Jun 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jun 12, 2002, 07:58 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by smeger:
<strong>Little-endian and big-endian refer to how numbers are interpreted by the processor. The bits that form a number can be interpreted either right-to-left or left-to-right.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I don't think that is quite right.

I thought that endian issues had to do with bit swapping in memory where a number read like:

0110 1001

would end up in memory as:

1001 0110

This is all on x86. Or maybe it was more data that was swapped (bytes over bits), I cant remember now. But I am almost positive it had nothing to do with the direction the memory was read.
     
Dedicated MacNNer
Join Date: Mar 2001
Location: Iowa City, IA
Status: Offline
Reply With Quote
Jun 12, 2002, 09:10 PM
 
If you're using standard C, the bitwise operators are required to operate as if the data they were handling was big-endian, regardless of what the underlying platform actually supports.

So unless the Wintel platform uses a non-ANSI C compiler (or you have ANSI compliance checked off for some reason) this should be a non-issue.
James

"I grew up. Then I got better." - Sea Wasp
     
Dedicated MacNNer
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jun 12, 2002, 09:13 PM
 
<strong>This is all on x86. Or maybe it was more data that was swapped (bytes over bits), I cant remember now. But I am almost positive it had nothing to do with the direction the memory was read.</strong>

That's not exactly what he said, but you're on the right track, too. Say you have a grouping (I wanted to say string, but didn't want to be misinterpreted) of two byte long data words:

MSB1 LSB1
MSB2 LSB2
MSB3 LSB3

The data in the format read by the PPC will look just like that. The data in the format read by X86 will look like this:

LSB1 MSB1
LSB2 MSB2
LSB3 MSB3

where LSB is the least significant byte and MSB is the most significant byte.

In other words, from Hennessy and Patterson: "There are two different conventions for ordering the bytes within a word. Little Endian byte order puts the byte whose address is "x....x00" at the least-significant position in the word (the little end). Big Endian byte order puts the byte wose address is "x...x00" at the most-significant position in the word (the big end). In Big Endian addressing, the address of a datum is the address of the most-significant byte; while in Little Endian, the address of a datum is the address of the least-significant byte."
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Jun 13, 2002, 02:13 AM
 
Sorry for being unclear - I was trying to get the point across without giving a comp-sci lecture What you say is absolutely correct.

Just out of curiousity, does anyone know what is required to change the ppc endian flag? I have a vague recollection that it's done in hardware or in supervisor mode, but I don't remember for sure.

BTW - I just used the new "preview post" function for the first time. The pop-up is a nice feature!
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Forum Regular
Join Date: Mar 2002
Location: Düsseldorf, Germany, Europe, Earth
Status: Offline
Reply With Quote
Jun 13, 2002, 07:25 AM
 
I think you have to be in supervisor mode and of course use assembly code to do the switch. Then I suppose you'd have to switch back if you want to use any system calls. Sounds like a great source of bugs to me. Why not try to write Endian-clean code?
     
Dedicated MacNNer
Join Date: May 2001
Location: Edinburgh, UK
Status: Offline
Reply With Quote
Jun 14, 2002, 12:02 PM
 
Why don't you just write some simple byte swapping functions? I don't think it is possible for Apple hardware to run in little endian mode (although I may be wrong) because various system components are moto byte order only.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:22 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2