Register | Login
Forum Index > Bugs and Fixes > signed | unsigned comparison
Author Message
Pages: 1 2 3 4
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1544] signed | unsigned comparison - posted: 2015-01-29 19:12:00
When comparing signed numbers unsigned comparison occures. Below assume that in eax int32 number.
Code:
program RAW_IMAGE 'test';

#set bits 32;

if ([int32]eax < 0) {}
if ([int32]eax <= 0) {}
if ([int32]eax => 0) {}
if ([int32]eax > 0) {}

while ([int32]eax < 0){}
while ([int32]eax <= 0){}
while ([int32]eax => 0){}
while ([int32]eax > 0){}

repeat {} until ([int32]eax < 0)
repeat {} until ([int32]eax <= 0)
repeat {} until ([int32]eax => 0)
repeat {} until ([int32]eax > 0)

repeat {break if ([int32]eax < 0);};
repeat {break if ([int32]eax <= 0);};
repeat {break if ([int32]eax => 0);};
repeat {break if ([int32]eax > 0);};

Result:
Code:
00000000  85C0              test eax,eax
00000002  7300              jnc 0x4
00000004  85C0              test eax,eax
00000006  7700              ja 0x8
00000008  85C0              test eax,eax
0000000A  7200              jc 0xc
0000000C  85C0              test eax,eax
0000000E  7600              jna 0x10
00000010  85C0              test eax,eax
00000012  7302              jnc 0x16
00000014  EBFA              jmp short 0x10
00000016  85C0              test eax,eax
00000018  7702              ja 0x1c
0000001A  EBFA              jmp short 0x16
0000001C  85C0              test eax,eax
0000001E  7202              jc 0x22
00000020  EBFA              jmp short 0x1c
00000022  85C0              test eax,eax
00000024  7602              jna 0x28
00000026  EBFA              jmp short 0x22
00000028  85C0              test eax,eax
0000002A  73FC              jnc 0x28
0000002C  85C0              test eax,eax
0000002E  77FC              ja 0x2c
00000030  85C0              test eax,eax
00000032  72FC              jc 0x30
00000034  85C0              test eax,eax
00000036  76FC              jna 0x34
00000038  85C0              test eax,eax
0000003A  7202              jc 0x3e
0000003C  EBFA              jmp short 0x38
0000003E  85C0              test eax,eax
00000040  7602              jna 0x44
00000042  EBFA              jmp short 0x3e
00000044  85C0              test eax,eax
00000046  7302              jnc 0x4a
00000048  EBFA              jmp short 0x44
0000004A  85C0              test eax,eax
0000004C  7702              ja 0x50
0000004E  EBFA              jmp short 0x4a


Also noticed that after unconditional repeat{} need semicolon(otherwise error). Is it should be? I mean is there right behavior or not? Because after conditional repeat{} semicolon does not need.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1545] - posted: 2015-01-29 21:56:57
Thanks for report, seems I missed a bit code that passes arguments to internal assembler. This is fixed for next release.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1580] - posted: 2015-02-01 13:22:38
Above i asked you about unconditional repeat{};
Could you answer?
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1581] - posted: 2015-02-01 18:02:02
Sorry, I missed that one. 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.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1599] - posted: 2015-02-03 13:38:43
Code:
program RAW_IMAGE 'test';

#set bits 32;

int8  ib;
int16 iw;
int32 id;

if (al <  ib) {}
if (al <= ib) {}
if (al => ib) {}
if (al >  ib) {}

if (ax <  iw) {}
if (ax <= iw) {}
if (ax => iw) {}
if (ax >  iw) {}

if (eax <  id) {}
if (eax <= id) {}
if (eax => id) {}
if (eax >  id) {}

Result:
Code:
00000000  3B0564000000      cmp eax,[dword 0x64]
00000006  7300              jnc 0x8
00000008  3B0564000000      cmp eax,[dword 0x64]
0000000E  7700              ja 0x10
00000010  3B0564000000      cmp eax,[dword 0x64]
00000016  7200              jc 0x18
00000018  3B0564000000      cmp eax,[dword 0x64]
0000001E  7600              jna 0x20
00000020  663B0565000000    cmp ax,[dword 0x65]
00000027  7300              jnc 0x29
00000029  663B0565000000    cmp ax,[dword 0x65]
00000030  7700              ja 0x32
00000032  663B0565000000    cmp ax,[dword 0x65]
00000039  7200              jc 0x3b
0000003B  663B0565000000    cmp ax,[dword 0x65]
00000042  7600              jna 0x44
00000044  3B0567000000      cmp eax,[dword 0x67]
0000004A  7300              jnc 0x4c
0000004C  3B0567000000      cmp eax,[dword 0x67]
00000052  7700              ja 0x54
00000054  3B0567000000      cmp eax,[dword 0x67]
0000005A  7200              jc 0x5c
0000005C  3B0567000000      cmp eax,[dword 0x67]
00000062  7600              jna 0x64
00000064  0000              add [eax],al
00000066  0000              add [eax],al
00000068  0000              add [eax],al
0000006A  00                db 0x00
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1601] - posted: 2015-02-03 13:51:15
Also interesting how it should be translated:
Code:
if ([dword]eax => [int32]id) {}
Maybe easy way this is -- to have different operators for signed|unsigned([s]<, [s]<=, [s]=>, [s]>; [u]<, [u]<=, [u]=>, [u]>) comparison. But you already have implemented signed|unsigned type system. And such cases should be documented then.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1610] - posted: 2015-02-03 18:22:42
Thanks for reporting this. Fixed the cmp al, problem.

As for the u/s. The assembler uses the status of the first operand.

Code:
if (al <  ib) {}
if ([int8]al <  ib) {}
if ([int32]eax < edx) {}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1611] - posted: 2015-02-03 18:46:05
Maybe need some convention when we use '<reg> as <type>'
Because, for example: Code:
edx = -100500 as int32;
if (SomeFunction() < edx){}

How will be edx in SomeFunction()?
And how after return from SomeFunction()?
Pages: 1 2 3 4
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 4 user(s) online. 0 member(s) and 4 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd