principia icon indicating copy to clipboard operation
principia copied to clipboard

Level loader isn't portable

Open SpicyForthProgrammer opened this issue 2 years ago • 6 comments

It uses bit-shifting. So levels wont load on non little endian hardware or they will load, but they will only load on one arch. Haven't had time to test.

SpicyForthProgrammer avatar Aug 08 '22 15:08 SpicyForthProgrammer

Yup its just an intresting issue, but making the level loader more portable isnt bad practice.

SpicyForthProgrammer avatar Aug 10 '22 18:08 SpicyForthProgrammer

This is not a real issue.

  1. Bit shifts work the same everywhere.
    Endianness is the order of bytes (not bits!) in memory.
    Integers (or any other data) have to be loaded into registers (which are neither little nor big-endian, they just store the entire 32/64 value at once) before the cpu can perform any operations on them.
  2. x86/x86_64 are always LE and ARM can do both (LE by default). Even if endianness somehow affected registers, it would still be at the lowest priority since big-endian architectures are extremely rare.

Close it. (Deleted my older comment because it was bad)

griffi-gh avatar Aug 10 '22 23:08 griffi-gh

Btw even if you remove them the compiler will optimize your basic math operations back down to bitwise ones (if possible), producing exactly the same binaries.

griffi-gh avatar Aug 10 '22 23:08 griffi-gh

Heavily depends on the compiler in general bit-shifting doesn't mean it wont load it could just mean levels on one cpu arch wont load on another.

SpicyForthProgrammer avatar Aug 11 '22 03:08 SpicyForthProgrammer

Ill see if i can get it to compile properly on ppc big endian then let you know my findings

SpicyForthProgrammer avatar Aug 11 '22 03:08 SpicyForthProgrammer

Heavily depends on the compiler in general bit-shifting doesn't mean it wont load it could just mean levels on one cpu arch wont load on another.

That may be a thing but it's not related to bitshifts

griffi-gh avatar Aug 12 '22 09:08 griffi-gh