littel to big endian question...

Find quick help here to get you started with Hollywood
Post Reply
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

littel to big endian question...

Post by Tuxedo »

HI ALL!
I'm working on a routine to convert littel to big endian longwords and get some problem...
maybe I'm only a newbe guy...
To convert shorts was all really simple! I use a ror(or rol) and all works great :)
The poblem was when I try to convert longs...probably I miss some function but I cant reach to swap the position for bytes to convert from little to big...
Any idea here?
I know that i have to swap the bytes of a long(for ex: 1,2,3,4 to 4,3,2,1) but I cant found any function in hollywood to do that...

Thanks a LOT!!!!!!
Simone"Tuxedo"Monsignori, Perugia, ITALY.
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: littel to big endian question...

Post by Tuxedo »

Solved :)
Simply copied a C method since the bitwise opertors was the same in Hollywood too :)
ANd I've miss the bitwise operators of Hollywood since today... :P

So topic closed :P
Simone"Tuxedo"Monsignori, Perugia, ITALY.
User avatar
Clyde
Posts: 349
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: littel to big endian question...

Post by Clyde »

Would be cool if you would share the solution you found in case someone else also gets in trouble on this topic. :-)

Thanks!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
Tuxedo
Posts: 345
Joined: Sun Feb 14, 2010 12:41 pm

Re: littel to big endian question...

Post by Tuxedo »

Well...
I find rather easly the code:

inline void endian_swap(unsigned short& x)
{
x = (x>>8) |
(x<<8);
}

inline void endian_swap(unsigned int& x)
{
x = (x>>24) |
((x<<8) & 0x00FF0000) |
((x>>8) & 0x0000FF00) |
(x<<24);
}

On the net...
Than sonce the logical commands was exactly the same in Hollywood too I simply adapted that to my code :)
Easy :)

The full link was here:

http://www.codeguru.com/forum/showthread.php?t=292902

Hope that was usefull to someone :)
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Post Reply