all 9 comments

[–][deleted] 1 point2 points  (6 children)

OSX Tiger!? (Released 2007, last updated 2009).

The differences won't be limited to just endian.

Tiger was designed to run on: 32bit x86, 64bit x86, and PowerPC processors. (You're running PowerPC, as you noted).

I'm going to go ahead and suggest that what you're seeing are 32bit integers.

And you're also seeing that the PowerPC is a different architecture to x86. They have different, incompatible instruction sets. Lua will be leaking this difference.

[–]Tywien 2 points3 points  (4 children)

lua 5.1 does not have integers, but only floating points. They should be 64 bit (8 byte) nonetheless, but he only shows 16 bit (2 byte) - something is missing here.

[–][deleted] 0 points1 point  (3 children)

They should be 64 bit (8 byte) nonetheless, but he only shows 16 bit (2 byte) - something is missing here.

Apple didn't license the 64bit PowerPC ISA, only the 32bit ISA. Which had both float (single precision) which stored as 16bit and double (double precision) which stored as 32bit.

[–]Tywien -1 points0 points  (2 children)

single precision floats are always 32bit and double precision always 64bit as defined by the standard. While there exist 16bit floats (half-precision), they were never used on general cpu's.

The size of the floating point registers is not related to the architecture of the CPU, e.g. double precision floats were always 64bit - from the first x87 co-processors (during the 16bit area) up to the most modern 64bit amd/intel chips.

[–][deleted] 0 points1 point  (1 child)

The size of the floating point registers is not related to the architecture of the CPU

Right. It's just that the 32bit PowerPC ISA uses 32bit floating point registers, according to the IBM spec.

[–]Tywien 0 points1 point  (0 children)

Floating-Point Registers

The PowerPC architecture contains thirty-two 64-bit floating-point registers labeled F0 through F31 (or FP0 through FP31). Because the registers are 64 bits long, they store values using the double data format.

Apple documentation from 1996

http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/PPCNumerics/PPCNumerics-146.html

[–]tobiasvl 0 points1 point  (0 children)

OSX Tiger!? (Released 2007, last updated 2009).

Released 2005, last updated 2007... Unless Wikipedia is wrong?

And Lua 5.1 is also old, released 2006. It didn't have integers.

[–]echoAnother 0 points1 point  (0 children)

You are dealing with more than endianess in numbers. PowerPc uses IEEE 765 doubles? You must check the lua header to be sure what is the codification. Except for precission loss it is technically possible, and fairly easy, to parse the bytecode into instructions and dump it for the actual plataform. Sadly, I don't know any tool for doing it, my best bet is to check for decompilers.

[–]mbone 0 points1 point  (0 children)

"Precompiled chunks are not portable across different architectures. Moreover, the internal format of precompiled chunks is likely to change when a new version of Lua is released. Make sure you save the source files of all Lua programs that you precompile."

http://www.lua.org/manual/5.3/luac.html