Register | Login
Forum Index > Bugs and Fixes > Wrong opcodes
Author Message
Pages: 1 2 3 4 5 6 7
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1491] Wrong opcodes - posted: 2015-01-21 12:18:31
There is one of my tests:
Code:
program RAW_IMAGE 'test';

#set bits 32;

inline procedure MyTest(;){        
  $x = 0;
  $repeat $argc:  
    $y = 0;
    $repeat $argc:  
      $arg[$x] |= $arg[$y];
      $arg[$x] &= $arg[$y];
      $arg[$x] ^= $arg[$y];
      $arg[$x] += $arg[$y];
      $arg[$x] -= $arg[$y];
      $y = $y + 1;
    $end
    $x = $x + 1;
  $end
}

Mytest(eax,     ebx,    ecx,    edx,  esi, edi, ebp, esp);
Mytest( ax,      bx,     cx,     dx,   si,  di,  bp,  sp);
Mytest(ah,al,   bh,bl,  ch,cl,  dh,dl);


After compile in result we can found such things:
Code:
000004F8  6644              inc sp
000004FA  03D4              add edx,esp
000004FC  6644              inc sp
000004FE  2BD4              sub edx,esp
00000500  6644              inc sp
00000502  0BF0              or esi,eax
00000504  6644              inc sp
00000506  23F0              and esi,eax
00000508  6644              inc sp
0000050A  33F0              xor esi,eax
0000050C  6644              inc sp
0000050E  03F0              add esi,eax
00000510  6644              inc sp
00000512  2BF0              sub esi,eax
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1493] - posted: 2015-01-21 13:39:35
Hmm, this looks very strange, I will check this as soon as I get in the office.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1497] - posted: 2015-01-21 19:27:48
I have just tested your exact code and the output seems correct.

Code:
L_00000000:   or eax, eax
L_00000002:   and eax, eax
L_00000004:   xor eax, eax
L_00000006:   add eax, eax
L_00000008:   sub eax, eax
L_0000000A:   or eax, ebx
L_0000000C:   and eax, ebx
L_0000000E:   xor eax, ebx
L_00000010:   add eax, ebx
L_00000012:   sub eax, ebx
L_00000014:   or eax, ecx
L_00000016:   and eax, ecx
L_00000018:   xor eax, ecx
L_0000001A:   add eax, ecx
L_0000001C:   sub eax, ecx
L_0000001E:   or eax, edx
L_00000020:   and eax, edx
L_00000022:   xor eax, edx
L_00000024:   add eax, edx
...


It is quite possible I did not update the linker plugin in the package by mistake, I have updated the download package for version 2.0.0.16, can you please re-download and let me know if this solves the issue? Thanks

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:
[1499] - posted: 2015-01-21 21:05:22
It seems that you checked only output beginning smile

If i not mistaken then wrong output starts from Code:
or ax, ax
And instead of just prefix 0x66 also added 0x44 and we get wrong 0x66, 0x44 -- it Code:
inc sp
.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1502] - posted: 2015-01-21 23:45:16
Aha, I see now, thanks for that, I'm going to look into the issue now.

Edit: Fixed for next release, thanks again for report.

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:
[1509] - posted: 2015-01-22 21:36:42
There is assignment not occures:
Code:
program RAW_IMAGE 'test';
#set bits 32;
byte b1, b2;
word w1, w2;
b1 = b2;
w1 = w2;
byte[edi] = byte[esi];
word[edi] = word[esi];

Code:
00000000  33C0              xor eax,eax
00000002  A0E0285401        mov al,[0x15428e0]
00000007  50                push eax
00000008  66680000          push word 0x0
0000000C  66FF35E3285401    push word [dword 0x15428e3]
00000013  33C0              xor eax,eax
00000015  8A06              mov al,[esi]
00000017  50                push eax
00000018  66680000          push word 0x0
0000001C  66FF36            push word [esi]
0000001F  0000              add [eax],al
00000021  0000              add [eax],al
00000023  0000              add [eax],al


As for dword's there is seems ok -- push \ pop used:
Code:
program RAW_IMAGE 'test';
#set bits 32;
dword d1, d2;
d1 = d2;

Code:
00000000  FF35D0285401      push dword [dword 0x15428d0]
00000006  8F05CC285401      pop dword [dword 0x15428cc]
0000000C  0000              add [eax],al
0000000E  0000              add [eax],al
00000010  0000              add [eax],al
00000012  0000              add [eax],al

Just suggestion.
If for byte \ word register eax used then may be also for dword better would use eax.
It faster than through the stack. Or may be need to add option's "through stack" and "through register".
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1510] - posted: 2015-01-23 22:15:53
OK, I have implemented as so:

preserving EAX is default even with byte/word etc. But there is now a directive to prevent this.

Code:
byte b1, b2;
word w1, w2;
dword d1, d2;

#set m2m_reg true;
b1 = b2;
w1 = w2;
d1 = d2;

nop

#set m2m_reg false;
b1 = b2;
w1 = w2;
d1 = d2;


Try this is the new 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:
[1513] - posted: 2015-01-25 13:30:38
I have tested new release.
Your code above works fine.

But errors here:
Code:
program RAW_IMAGE 'test';

#set bits 32;

inline procedure MyTest(;){
  $x = 0;
  $repeat $argc:
    $y = 0;
    $repeat $argc:
      byte[$arg[$x]] = byte[$arg[$y]];
      word[$arg[$x]] = word[$arg[$y]];
      dword[$arg[$x]] = dword[$arg[$y]];
      $y = $y + 1;
    $end
    $x = $x + 1;
  $end
}

#set m2m_reg true;
Mytest(eax, ebx, ecx, edx, esi, edi, ebp, esp);

#set m2m_reg false;
Mytest(eax, ebx, ecx, edx, esi, edi, ebp, esp);


Below is only part(not all) of output:
Code:
00000000  33C0              xor eax,eax
00000002  8A00              mov al,[eax]
00000004  50                push eax
00000005  66680000          push word 0x0
00000009  66FF30            push word [eax]
0000000C  FF30              push dword [eax]
0000000E  8F00              pop dword [eax]
00000010  33C0              xor eax,eax
00000012  8A03              mov al,[ebx]
00000014  50                push eax
00000015  66680000          push word 0x0
00000019  66FF33            push word [ebx]
0000001C  FF33              push dword [ebx]
0000001E  8F00              pop dword [eax]
00000020  33C0              xor eax,eax
00000022  8A01              mov al,[ecx]
00000024  50                push eax
00000025  66680000          push word 0x0
00000029  66FF31            push word [ecx]
0000002C  FF31              push dword [ecx]
0000002E  8F00              pop dword [eax]
; ............................................
00000858  33C0              xor eax,eax
0000085A  8A4500            mov al,[ebp+0x0]
0000085D  50                push eax
0000085E  66680000          push word 0x0
00000862  66FF7500          push word [ebp+0x0]
00000866  FF7500            push dword [ebp+0x0]
00000869  8F0424            pop dword [esp]
0000086C  33C0              xor eax,eax
0000086E  8A0424            mov al,[esp]
00000871  50                push eax
00000872  66680000          push word 0x0
00000876  66FF3424          push word [esp]
0000087A  FF3424            push dword [esp]
0000087D  8F0424            pop dword [esp]

Seems that works only for dword.
Pages: 1 2 3 4 5 6 7
create new reply


Quick reply:

Message:



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