From f9217272d1498eab3acc77a7cf3bd79ccaa188c5 Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Mon, 3 Apr 2023 13:40:36 +0200 Subject: [PATCH 1/2] Fix signed syscalls stack (#954) --- evm/src/cpu/kernel/asm/signed.asm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/evm/src/cpu/kernel/asm/signed.asm b/evm/src/cpu/kernel/asm/signed.asm index 7dd9c482..566d7d5a 100644 --- a/evm/src/cpu/kernel/asm/signed.asm +++ b/evm/src/cpu/kernel/asm/signed.asm @@ -183,32 +183,32 @@ global _sys_slt: global sys_sdiv: %charge_gas_const(@GAS_LOW) - %stack(x, y, kernel_return) -> (_sys_sdiv, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_sdiv, x, y, _syscall_return, kernel_return) JUMP global sys_smod: %charge_gas_const(@GAS_LOW) - %stack(x, y, kernel_return) -> (_sys_smod, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_smod, x, y, _syscall_return, kernel_return) JUMP global sys_signextend: %charge_gas_const(@GAS_LOW) - %stack(x, y, kernel_return) -> (_sys_signextend, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_signextend, x, y, _syscall_return, kernel_return) JUMP global sys_sar: %charge_gas_const(@GAS_VERYLOW) - %stack(x, y, kernel_return) -> (_sys_sar, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_sar, x, y, _syscall_return, kernel_return) JUMP global sys_slt: %charge_gas_const(@GAS_VERYLOW) - %stack(x, y, kernel_return) -> (_sys_slt, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_slt, x, y, _syscall_return, kernel_return) JUMP global sys_sgt: %charge_gas_const(@GAS_VERYLOW) - %stack(x, y, kernel_return) -> (_sys_sgt, x, y, _syscall_return, kernel_return) + %stack(kernel_return, x, y) -> (_sys_sgt, x, y, _syscall_return, kernel_return) JUMP _syscall_return: From 6fa59d204fbdf780c02bce41edc1144f436e49e1 Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Mon, 3 Apr 2023 16:39:18 +0200 Subject: [PATCH 2/2] Fix MSTORE8 (#955) * Fix MSTORE8 * Small optimization --- evm/src/cpu/kernel/asm/memory/syscalls.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/evm/src/cpu/kernel/asm/memory/syscalls.asm b/evm/src/cpu/kernel/asm/memory/syscalls.asm index 082b44fa..3a233856 100644 --- a/evm/src/cpu/kernel/asm/memory/syscalls.asm +++ b/evm/src/cpu/kernel/asm/memory/syscalls.asm @@ -100,7 +100,8 @@ global sys_mstore8: // stack: expanded_num_bytes, kexit_info, offset, value %update_mem_bytes // stack: kexit_info, offset, value - %stack (kexit_info, offset, value) -> (offset, value, kexit_info) + %stack (kexit_info, offset, value) -> (value, 0x100, offset, kexit_info) + MOD SWAP1 %mstore_current(@SEGMENT_MAIN_MEMORY) // stack: kexit_info EXIT_KERNEL