From 38ed21db492c52f38955e18df3bfe4ca0a0c904c Mon Sep 17 00:00:00 2001 From: jbirddog <100367399+jbirddog@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:28:15 -0400 Subject: [PATCH] Fix issue with user defined input stack effects (#81) --- dictionary.inc | 26 ++++++++++---------------- dictionary_test.inc | 4 ++-- flow.inc | 7 +++++++ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/dictionary.inc b/dictionary.inc index 73f01ee..0648f0b 100644 --- a/dictionary.inc +++ b/dictionary.inc @@ -58,8 +58,8 @@ macro _ose e { _core_words: .prev_word = 0 - _wi 'ecx', 3, se_reg_ecx, 0, 0 - _wi 'eax', 3, se_reg_eax, 0, 0 + _wi 'ecx', 3, se_reg.ecx, 0, 0 + _wi 'eax', 3, se_reg.eax, 0, 0 .se_reg_latest = .prev_word .prev_word = 0 @@ -415,10 +415,13 @@ seX_parse_end: ret -se_reg_eax: - mov rax, _EAX +se_reg: +macro _se_reg reg, _REG { + .##reg: + mov rax, _REG mov rdi, [_dictionary.here] stosq + mov [_dictionary.here], rdi mov rdi, [_dictionary.latest] add rdi, 2 @@ -427,16 +430,7 @@ se_reg_eax: stosb ret - -se_reg_ecx: - mov rax, _ECX - mov rdi, [_dictionary.here] - stosq - - mov rdi, [_dictionary.latest] - add rdi, 2 - mov al, byte [rdi] - inc al - stosb +} - ret + _se_reg eax, _EAX + _se_reg ecx, _ECX diff --git a/dictionary_test.inc b/dictionary_test.inc index 282ecef..47105fa 100644 --- a/dictionary_test.inc +++ b/dictionary_test.inc @@ -163,8 +163,8 @@ dictionary_test: tc3 seX_o_parse, _core_words.se_parse_latest tc3 seX_parse_end, _core_words.se_parse_latest - tc3 se_reg_eax, _core_words.se_reg_latest - tc3 se_reg_ecx, _core_words.se_reg_latest + tc3 se_reg.eax, _core_words.se_reg_latest + tc3 se_reg.ecx, _core_words.se_reg_latest call dictionary_deinit diff --git a/flow.inc b/flow.inc index 7f98eda..8221eb6 100644 --- a/flow.inc +++ b/flow.inc @@ -12,6 +12,10 @@ flow_in: lea rbx, [rdi + (rcx * 8)] mov rbx, [rbx] + + cmp bl, _REGISTER + jne .bad_se + and rbx, REG_MASK shr rbx, REG_OFFSET @@ -51,6 +55,9 @@ flow_in: .done: ret + .bad_se: + die ERR_BAD_SE + ; ; expects ; - word in rax