The register should be as what it was before calling the macro, as macros are inlined, they use the current state of variables and registers etc.
signed | unsigned comparison
A community discussion post from the original code:zIRON forum.
Replies
Seems it works :) (exept eax = al)
program RAW_IMAGE 'test';
#set bits 32;
inline function SomeInlineFunction() {
eax as dword;
if (eax > 0) {eax = al;}
if ([int32]eax > 0) {eax = al;}
}
eax as int32;
if (eax > 0) {eax = al;}
if ([dword]eax > 0) {eax = al;}
SomeInlineFunction();
if (eax > 0) {eax = al;}
if ([dword]eax > 0) {eax = al;}
Result:
00000000 85C0 test eax,eax
00000002 7E03 jng 0x7
00000004 0FB6C0 movzx eax,al
00000007 85C0 test eax,eax
00000009 7603 jna 0xe
0000000B 0FB6C0 movzx eax,al
0000000E 85C0 test eax,eax
00000010 7603 jna 0x15
00000012 0FB6C0 movzx eax,al
00000015 85C0 test eax,eax
00000017 7E03 jng 0x1c
00000019 0FB6C0 movzx eax,al
0000001C 85C0 test eax,eax
0000001E 7603 jna 0x23
00000020 0FB6C0 movzx eax,al
00000023 85C0 test eax,eax
00000025 7603 jna 0x2a
00000027 0FB6C0 movzx eax,al
Yes, unconditional repeat requires ; as I tried to keep the syntax the same as Ziron 1, this lets the assembler know there is no until/while statement, it was intended to help performance (faster peeking). However, in Ziron 2 i have improved the internal parser, so I will add it to my list to make this optional.
I think it no so hard to correct this.
As i understand there is not needed to be optional. Because ';' -- it just an empty operator.
We are able to write also:
repeat{};;;;;;;;;;;;;
It is not about correcting, but was about performance. The parser must look ahead at the next identifier to know if it should continue processing or treat it as a infinite repeat (checking a simple char ';' is faster than checking for a keyword. But I have already changed this for next release.
exept eax = al
I have changed assignments to check signed against first operand, this should solve the problem and make it work as expected.
I think it relevant to this topic.
This
program RAW_IMAGE 'test';
#set bits 32;
eax as int32;
eax >> 1;
produces
00000000 D1E8 shr eax,1
Why in this case when 'eax' is signed 'sar' instruction was not used?
Thanks, corrected this for next release.
program RAW_IMAGE 'test';
#set bits 32;
if ([sysint]gp_cx > 0) {}
Result:
00000000 85C9 test ecx,ecx
00000002 7600 jna 0x4