Register | Login
Forum Index > Bugs and Fixes > Wrong size used
Author Message
Pages: 1
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1465] Wrong size used - posted: 2015-01-15 10:39:18
Used dword but must be byte. Code:
enum MyEnum : byte {val1 = 0, val2, val3};
byte MyByte; eax = @MyByte;
mov [eax], val1;
mov [eax], val2;
mov [eax], val3;
Result: Code:
c70000000000         mov    dword ptr [eax], 00h
      c70001000000         mov    dword ptr [eax], 01h
      c70002000000         mov    dword ptr [eax], 02h
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1468] - posted: 2015-01-15 11:13:06
with no size prefix, the assembler assumes a pointer type and will convert the right operator, in this case:

Code:
byte[eax] = val1;


I will however look at changing this to check against the right operand.

EDIT: I have updated the assembler and this is solved 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:
[1721] - posted: 2015-02-17 14:05:43
I think it a bit relevant to this topic:
Code:
procedure Test(qword X) {} Test(0);

Result:
Code:
00000000  6A00              push byte +0x0
00000002  E800000000        call dword 0x7
00000007  55                push ebp
00000008  8BEC              mov ebp,esp
0000000A  8BE5              mov esp,ebp
0000000C  5D                pop ebp
0000000D  C20800            ret 0x8

Also in 16 bit mode we get wrong opcodes:
Code:
00000000  6A00              push byte +0x0
00000002  E80000558B        call dword 0x8b550007
00000007  EC                in al,dx
00000008  8BE5              mov esp,ebp
0000000A  5D                pop ebp
0000000B  C20800            ret 0x8
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1722] - posted: 2015-02-18 10:47:06
Also in 16 bit mode we get wrong opcodes:
Actually result was:
Code:
00000000  6A00              push byte +0x0
00000002  E80000            call word 0x5
00000005  55                push bp
00000006  8BEC              mov bp,sp
00000008  8BE5              mov sp,bp
0000000A  5D                pop bp
0000000B  C20800            ret 0x8
In post above result was just because i disassembled it in 32 bit mode.

But anyway smile
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1724] - posted: 2015-02-18 11:38:54
Also strange warnings:
Code:
program RAW_IMAGE 'test';

#set bits 32;

qword a, b;

a = b;

[7,6]: Warning: [666] b passed as value to stack, consider passing by ref in [te
st.zir]
[7,6]: Warning: [666] a passed as value to stack, consider passing by ref in [te
st.zir]
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1725] - posted: 2015-02-18 12:11:27
Also there is value was truncated to 32-bit without any warnings:
Code:
program RAW_IMAGE 'test';

#set bits 32;

procedure Test(qword X) {}
Test(0x123456789ABCDEF0);

Result:
Code:
00000000  68F0DEBC9A        push dword 0x9abcdef0
00000005  E800000000        call dword 0xa
0000000A  55                push ebp
0000000B  8BEC              mov ebp,esp
0000000D  8BE5              mov esp,ebp
0000000F  5D                pop ebp
00000010  C20800            ret 0x8
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1866] - posted: 2016-12-13 00:33:11
Also strange warnings:


This is warning you that 2 dwords are being pushed to the stack. (because: 32-bit mode)

Also there is value was truncated to 32-bit without any warnings


Fixed for next release.

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


Quick reply:

Message:



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