[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: and/or missbehaviour in embedded lua 5.1
- From: Andreas Stenius <kaos@...>
- Date: Thu, 16 Mar 2006 15:06:12 +0100
Interesting, I implemented luac into my monitor to see the output, and
get this:
> c"local a = true and 0"
main <(string):0,0> (2 instructions, 8 bytes at 0x148f7a)
0+ params, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
1 [1] LOADK 0 -1 ; 2.1436356971487e-228
2 [1] RETURN 0 1
constants (1) for 0x148f7a:
1 2.1436356971487e-228
locals (1) for 0x148f7a:
0 a 2 2
upvalues (0) for 0x148f7a:
> c"local a = true or 0"
main <(string):0,0> (6 instructions, 24 bytes at 0x14563a)
0+ params, 2 slots, 0 upvalues, 1 local, 1 constant, 0 functions
1 [1] JMP 3 ; to 5
2 [1] LOADK 0 -1 ; 2.1436356971487e-228
3 [1] JMP 2 ; to 6
4 [1] LOADBOOL 0 0 1
5 [1] LOADBOOL 0 1 0
6 [1] RETURN 0 1
constants (1) for 0x14563a:
1 2.1436356971487e-228
locals (1) for 0x14563a:
0 a 6 6
upvalues (0) for 0x14563a:
>
Any lua internals knowledgable have any conclusions to make from this?
Btw, I've completely forgot to mention some info regarding my target env:
The sizes for the various data types is as:
["char"] = 1,
["void *"] = 4,
["int"] = 2,
["short"] = 2,
["double"] = 8,
["float"] = 4,
["long"] = 4,
Thanks any input you may have!
//Andreas
Kein-Hong Man skrev:
Your sample:
local a = true and 0
on Lua 5.1/cygwin gives 0. It compiles to:
[1] loadk 0 0 ; 0
[2] return 0 1
But on your platform, 1.0890312344636e-60 is however, E0FFFFFF05007C33
hex, and the first 4 bytes looks *very* suspicious to me.
But:
local a = true or 0
is not optimized to a LOADK. It compiles to:
[1] jmp 3 ; to [5]
[2] loadk 0 0 ; 0
[3] jmp 2 ; to [6]
[4] loadbool 0 0 1 ; false, to [6]
[5] loadbool 0 1 0 ; true
[6] return 0 1
Looks like some kind of optimization thingy barfed on you. :-)