Register | Login
Forum Index > Bugs and Fixes > Case statement
Author Message
Pages: 1 2
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1579] Case statement - posted: 2015-02-01 10:13:57
Code:
program RAW_IMAGE 'test';

#set bits 32;

case (esp) {
state eax: edx = 1; break;
state ebx: edx = 2; break;
state ecx: edx = 3; break;
state edx: edx = 4; break;
state esi: edx = 5; break;
state edi: edx = 6; break;
state ebp: edx = 7; break;
default:   edx = 8; 
}

Result:
Seems here is unnecessary first jump.
Code:
00000000  EB00              jmp short 0x2
00000002  3BE0              cmp esp,eax
00000004  750A              jnz 0x10
00000006  BA01000000        mov edx,0x1
0000000B  E947000000        jmp dword 0x57
00000010  3BE3              cmp esp,ebx
00000012  7507              jnz 0x1b
00000014  BA02000000        mov edx,0x2
00000019  EB3C              jmp short 0x57
0000001B  3BE1              cmp esp,ecx
0000001D  7507              jnz 0x26
0000001F  BA03000000        mov edx,0x3
00000024  EB31              jmp short 0x57
00000026  3BE2              cmp esp,edx
00000028  7507              jnz 0x31
0000002A  BA04000000        mov edx,0x4
0000002F  EB26              jmp short 0x57
00000031  3BE6              cmp esp,esi
00000033  7507              jnz 0x3c
00000035  BA05000000        mov edx,0x5
0000003A  EB1B              jmp short 0x57
0000003C  3BE7              cmp esp,edi
0000003E  7507              jnz 0x47
00000040  BA06000000        mov edx,0x6
00000045  EB10              jmp short 0x57
00000047  3BE5              cmp esp,ebp
00000049  7507              jnz 0x52
0000004B  BA07000000        mov edx,0x7
00000050  EB05              jmp short 0x57
00000052  BA08000000        mov edx,0x8


Next (true instead of esp) give error 'Instruction usage is not supported!'
Code:
program RAW_IMAGE 'test';

#set bits 32;

case (true) {
state eax: edx = 1; break;
state ebx: edx = 2; break;
state ecx: edx = 3; break;
state edx: edx = 4; break;
state esi: edx = 5; break;
state edi: edx = 6; break;
state ebp: edx = 7; break;
default:   edx = 8; 
}
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1587] - posted: 2015-02-02 16:40:49
Thanks, fixed both of these 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:
[1594] - posted: 2015-02-02 20:07:21
In the listing above there is Code:
0000000B  E947000000        jmp dword 0x57

It can be coded as short variant.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1596] - posted: 2015-02-02 20:56:52
This is already fixed. Thanks smile

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:
[1778] - posted: 2015-02-23 14:43:37
I would like to discuss about 'case' statement. What it will be when it is ready?

Maybe it would be more convenient to be able to test the range:
Code:
case (gp_ax) {
state -7..3: break;
state 5..100: break;
state 0x80..0x200: break;
state gp_dx..gp_cx: break;
state gp_si..0xffff: break;
state 0x12345678..gp_di: break;
default:   
}

Or maybe this will be useful:
Code:
case (gp_ax) {
state 0, 2, 5, 100: break;
state gp_bx, gp_cx: break;
state gp_dx, 0x20, 0b111: break;
default:   
}

Or even so:
Code:
case (gp_ax, gp_dx, gp_cx) {
state 0,1,2,3: break;
state 4,6,8: break;
state gp_si..gp_di: break;
default:   
}


What do you think about it?
And what you are really planned with 'case' statement?
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1782] - posted: 2015-02-23 17:26:04
you can place multiple states in front of one another (but maybe i will add using comma for additional states)

Code:
// example
case (gp_ax) {
  state 0:
  state 5:
  state 21:
    eax = 512;
    break;

  state 10:
  state 61:
    eax = 1024;
    break;
}


Ranges may be a good idea, but I will first concentrate on fixing any other bugs before extending any high level features.

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:
[1811] - posted: 2015-02-28 19:26:37
What do you think about this variant:
Code:
case (gp_ax) {
state  < gp_bx: break;
state <= gp_cx: break;
state == gp_dx: break;
state <> gp_si: break;
state => gp_di: break;
state  > gp_bp: break;
default:   
}
Also it can be extended by this way:
Code:
case (gp_ax) {
state  < gp_bx, <= gp_cx: break;
state == gp_dx, <> gp_si: break;
state => gp_di,  > gp_bp: break;
default:   
}
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1812] - posted: 2015-03-01 00:26:27
I have added this to my list and will consider this implementation.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 6 user(s) online. 0 member(s) and 6 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