myocytebd2 Cheater
Reputation: 0
Joined: 23 Apr 2015 Posts: 33
|
Posted: Mon Oct 05, 2020 9:19 am Post subject: Unstable behavior of auto assembler |
|
|
In some conditions it produced inconsistent result if lua string expression is involved.
| Code: | [ENABLE]
{$lua}
s = "-3A"
function setstr(argstr, syntaxcheckonly)
print("setstr", tostring(syntaxcheckonly), argstr)
return argstr
end
unregisterAutoAssemblerCommand("setstr")
registerAutoAssemblerCommand("setstr", setstr)
{$asm}
define(as, -3A)
alloc(sa, $4096)
registerSymbol(sa)
sa:
cmp eax, -3A
cmp eax, $s
cmp eax, as
setstr(cmp eax, -3A)
cmp ecx, -3A
cmp ecx, $s
cmp ecx, as
setstr(cmp ecx, -3A)
cmp esi, -3A
cmp esi, $s
cmp esi, as
setstr(cmp esi, -3A)
xor eax,eax
xor eax,eax
xor eax,eax
xor eax,eax
[DISABLE]
dealloc(sa) |
Result:
| Code: | sa - 83 F8 C6 - cmp eax,-3A { 198 }
0F010003- 83 F8 C6 - cmp eax,-3A { 198 }
0F010006- 83 F8 C6 - cmp eax,-3A { 198 }
0F010009- 83 F8 C6 - cmp eax,-3A { 198 }
0F01000C- 83 F9 C6 - cmp ecx,-3A { 198 }
0F01000F- 81 F9 C6FFFFFF - cmp ecx,FFFFFFC6 { -58 } !!! cmp ecx, $s
0F010015- 83 F9 C6 - cmp ecx,-3A { 198 }
0F010018- 83 F9 C6 - cmp ecx,-3A { 198 }
0F01001B- 83 FE C6 - cmp esi,-3A { 198 }
0F01001E- 81 FE C6FFFFFF - cmp esi,FFFFFFC6 { -58 } !!! cmp esi, $s
0F010024- 83 FE C6 - cmp esi,-3A { 198 }
0F010027- 83 FE C6 - cmp esi,-3A { 198 }
0F01002A- 31 C0 - xor eax,eax
0F01002C- 31 C0 - xor eax,eax
0F01002E- 31 C0 - xor eax,eax
0F010030- 31 C0 - xor eax,eax |
I would expect all of them encoded as imm8, as the input is equivalent.
Looks define() is safe to use, but such inconsistent behavior doesn't look very correct.
|
|