fix offset parsing and one byte loading instruction

This commit is contained in:
Ilya Rezvov
2018-04-10 19:48:02 -07:00
parent fd7ce7e450
commit 8514232513
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -649,7 +649,7 @@ eval store FunctionInstance { funcType, moduleInstance, code = Function { localT
MemoryInstance { memory } <- readIORef $ memInstances store ! (memaddrs moduleInstance ! 0)
let addr = fromIntegral $ v + fromIntegral offset
byte <- IOVector.read memory addr
let val = asWord32 $ if byte >= 128 then -1 * fromIntegral (v .&. 0x7F) else fromIntegral v
let val = asWord32 $ if byte >= 128 then -1 * fromIntegral (byte .&. 0x7F) else fromIntegral byte
return $ Done ctx { stack = VI32 val : rest }
step ctx@EvalCtx{ stack = (VI32 v:rest) } (I32Load16U MemArg { offset }) = do
MemoryInstance { memory } <- readIORef $ memInstances store ! (memaddrs moduleInstance ! 0)