benilla-re systems structs docs

bit_rshift

function · lua · primitive

Address
0x7fac70 · 85 bytes, up to 0x7facc4
Signature
int __fastcall (lua_State *L)
Meaning
Pushes argument 1 shifted right logically by argument 2
Confidence
verified, proof one
Finding
lua/libs#bit-library

Finding: Bit library in lua: the libraries

The client's bit library works on the low 32 bits of __ftol, a truncation toward zero to a 64-bit integer (eax is read, edx ignored). bnot inverts, band, bor and bxor combine every argument, lshift, rshift and arshift shift argument 1 by the count in argument 2 (masked to five bits), mod takes the remainder of argument 1 by argument 2. The results are pushed as unsigned numbers, except arshift and the remainder, which are signed. mod tests only the low dword of the divisor, so 0, 0.5 and 2^32 all answer 1 divided by argument 2.

functionnamedecided by
0x7faa50bit_bnot__ftol (0x7faa63), not eax (0x7faa68), high word zeroed (0x7faa6d), fild qword
0x7faa90bit_bandloop over lua_gettop arguments (0x7faac0), and edx,eax (0x7faad1), high word 0 (0x7faae1)
0x7fab10bit_borthe same loop with or
0x7fab90bit_bxorthe same loop with xor
0x7fac10bit_lshiftcount from argument 2 (0x7fac18), value from argument 1 (0x7fac29), shl eax,cl (0x7fac3e), high word 0 (0x7fac40)
0x7fac70bit_rshiftthe same with shr eax,cl (0x7fac9e) and high word 0 (0x7faca0)
0x7facd0bit_arshiftthe same with sar eax,cl (0x7facfc), pushed as a signed integer by fild dword (0x7fad06)
0x7fad20bit_moddivisor from __ftol (0x7fad2d) tested (0x7fad32); zero divides 1.0 by lua_tonumber (0x7fad42)
0x7fad70bit_mod_remaindercdq; idiv edi (0x7fad9a, 0x7fad9b), remainder edx pushed (0x7fadab)

The derivation is in the doc.

Callers 0

None by a direct call or jump.

Callees 3

Calls and jumps by a bare address, from tables/calls.tsv.