Implement loading i8
This commit is contained in:
parent
816931b886
commit
55dbf8ee32
@ -7,6 +7,7 @@ local module = {}
|
|||||||
|
|
||||||
local vla_u8 = ffi.typeof('uint8_t[?]')
|
local vla_u8 = ffi.typeof('uint8_t[?]')
|
||||||
|
|
||||||
|
local ptr_i8 = ffi.typeof('int8_t *')
|
||||||
local ptr_i64 = ffi.typeof('int64_t *')
|
local ptr_i64 = ffi.typeof('int64_t *')
|
||||||
local ptr_i32 = ffi.typeof('int32_t *')
|
local ptr_i32 = ffi.typeof('int32_t *')
|
||||||
|
|
||||||
@ -105,6 +106,7 @@ do
|
|||||||
module.load = load
|
module.load = load
|
||||||
module.store = store
|
module.store = store
|
||||||
|
|
||||||
|
function load.i32_i8(memory, addr) return ffi.cast(ptr_i8, memory.data)[addr] end
|
||||||
function load.i32_u8(memory, addr) return memory.data[addr] end
|
function load.i32_u8(memory, addr) return memory.data[addr] end
|
||||||
function load.i32(memory, addr) return ffi.cast(ptr_i32, memory.data + addr)[0] end
|
function load.i32(memory, addr) return ffi.cast(ptr_i32, memory.data + addr)[0] end
|
||||||
function load.i64(memory, addr) return ffi.cast(ptr_i64, memory.data + addr)[0] end
|
function load.i64(memory, addr) return ffi.cast(ptr_i64, memory.data + addr)[0] end
|
||||||
|
@ -130,6 +130,14 @@ do
|
|||||||
memory.data[adjust] = bit32.bor(lhs, rhs)
|
memory.data[adjust] = bit32.bor(lhs, rhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function load.i32_i8(memory, addr)
|
||||||
|
local b = load_byte(memory, addr)
|
||||||
|
|
||||||
|
if b > 0x7F then b = b - 0x100 end
|
||||||
|
|
||||||
|
return b
|
||||||
|
end
|
||||||
|
|
||||||
load.i32_u8 = load_byte
|
load.i32_u8 = load_byte
|
||||||
|
|
||||||
function load.i32(memory, addr)
|
function load.i32(memory, addr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user