Page 1 of 1

Little endien to Big endien

PostPosted: Tue Jul 10, 2007 1:32 am
by Game A Gogo
Some of you knows what it is right?

Well, for those who doesn't, Big endien is all natural and beautiful, while little endien is nasty and is a nature disaster...in my opinion xD

In more comprehensive word, Big endien would be normal I.e.: FF3B5A66 would actually be FF3B5A66
But, in revenge, little endien wants to pranks us, he wants to confuse us I.e.: FF3B5A66 would be 665A3BFF, which means, bytes are reversed D:

And I need a code that can take all those byte (four in total, Bytes are two Hexadecimal letters) and transform then into an array of 4 char*?

in other words, I need to flip bytes! (Or digits, or Chars)

Its easy to flip an image, because of course, their are stored into different memory addresses, but what to do when their are stored in one addresses!

I tried doing it myself, but whit no apparent succsess


Code: Select all
void Little_Big(char*Finput)
{
    FILE*output=fopen("data", "w+b");
    FILE*input= fopen("data", "r+b");
    FILE*FIoutput=fopen("sub_data", "w+b");
    FILE*FIinput= fopen("sub_data", "r+b");
    char ByteChk[4];
    char TempChk[4];
    char*Fouput;
    fputs(Finput, output);
    fgets(&ByteChk[0], 1, input);
    fgets(&ByteChk[1], 1, input);
    fgets(&ByteChk[2], 1, input);
    fgets(&ByteChk[3], 1, input);
    TempChk[0]=ByteChk[0];
    TempChk[1]=ByteChk[1];
    TempChk[2]=ByteChk[2];
    TempChk[3]=ByteChk[3];
    ByteChk[0]=TempChk[3];
    ByteChk[1]=TempChk[2];
    ByteChk[2]=TempChk[1];
    ByteChk[3]=TempChk[0];
    fputs(&ByteChk[0], FIoutput);
    fputs(&ByteChk[1], FIoutput);
    fputs(&ByteChk[2], FIoutput);
    fputs(&ByteChk[3], FIoutput);
    fclose(FIoutput);
    fgets(Fouput, 4, FIinput);
    fclose(output);
    fclose(input);
    fclose(FIoutput);
    fclose(FIinput);
    strcpy(text, Fouput);
}


PLEASE HELP!!!!!

Sorry gogo!

PostPosted: Tue Jul 10, 2007 6:50 am
by kyensoftware
Sorry gogo, cannot help you flip them here.
I can do it with 6502 (c64, NES, etc.), ARM7 (NDS 1st processor) and ARM9 (DS 2nd processor) instruction sets in assembly.
I cannot do X86 flipping in ASM or C. Sorry.
I will try recover my ASM so you can have a look!

PostPosted: Tue Jul 10, 2007 2:15 pm
by Game A Gogo
its ok, lets just hope someone will

Re: Little endien to Big endien

PostPosted: Tue Jul 10, 2007 4:53 pm
by Sgt. Sparky
Game A Gogo wrote:Some of you knows what it is right?

Well, for those who doesn't, Big endien is all natural and beautiful, while little endien is nasty and is a nature disaster...in my opinion xD

In more comprehensive word, Big endien would be normal I.e.: FF3B5A66 would actually be FF3B5A66
But, in revenge, little endien wants to pranks us, he wants to confuse us I.e.: FF3B5A66 would be 665A3BFF, which means, bytes are reversed D:

And I need a code that can take all those byte (four in total, Bytes are two Hexadecimal letters) and transform then into an array of 4 char*?

in other words, I need to flip bytes! (Or digits, or Chars)

Its easy to flip an image, because of course, their are stored into different memory addresses, but what to do when their are stored in one addresses!

I tried doing it myself, but whit no apparent succsess


Code: Select all
void Little_Big(char*Finput)
{
    FILE*output=fopen("data", "w+b");
    FILE*input= fopen("data", "r+b");
    FILE*FIoutput=fopen("sub_data", "w+b");
    FILE*FIinput= fopen("sub_data", "r+b");
    char ByteChk[4];
    char TempChk[4];
    char*Fouput;
    fputs(Finput, output);
    fgets(&ByteChk[0], 1, input);
    fgets(&ByteChk[1], 1, input);
    fgets(&ByteChk[2], 1, input);
    fgets(&ByteChk[3], 1, input);
    TempChk[0]=ByteChk[0];
    TempChk[1]=ByteChk[1];
    TempChk[2]=ByteChk[2];
    TempChk[3]=ByteChk[3];
    ByteChk[0]=TempChk[3];
    ByteChk[1]=TempChk[2];
    ByteChk[2]=TempChk[1];
    ByteChk[3]=TempChk[0];
    fputs(&ByteChk[0], FIoutput);
    fputs(&ByteChk[1], FIoutput);
    fputs(&ByteChk[2], FIoutput);
    fputs(&ByteChk[3], FIoutput);
    fclose(FIoutput);
    fgets(Fouput, 4, FIinput);
    fclose(output);
    fclose(input);
    fclose(FIoutput);
    fclose(FIinput);
    strcpy(text, Fouput);
}


PLEASE HELP!!!!!

I will make a text flipping function. :D it will be similar to my text reversing function, I will just make it so you can select to reverse the text between to points on one address. :D
EDIT: nevermind, I will make one that is specailly for what you want to do. (I got confused previously on what you wanted to do.)

PostPosted: Tue Jul 10, 2007 7:36 pm
by Sgt. Sparky