flat assembler
Message board for the users of flat assembler.

Index > Main > Constant size forcing

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 311
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan
Why this not works?

imul r8,rdx,dword 0
Post 11 Oct 2009, 17:09
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
It was decided in some point in time that imm operands cannot be forced to a size larger or shorter than the other(s) operands.

I'll not move this to Main yet though, because there is something "unfair" here. The following is allowed and makes a difference:
Code:
use32

imul eax, edx, 0         ; 3 bytes
imul eax, edx, dword 0   ; 6 bytes    


Perhaps this "unfairness" was discussed already but I'm pointing it out just in case it wasn't really intended.
Post 11 Oct 2009, 17:21
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael
You can always put some bogus value to force immediate's size and then overwrite that immediate, as in this example:
Code:
imul r8, rax, 1000000 ;or any other value that must be represented as a dword
store dword 0 at $-4 ;overwrite it with 0    
Post 11 Oct 2009, 20:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
LocoDelAssembly wrote:
Perhaps this "unfairness" was discussed already but I'm pointing it out just in case it wasn't really intended.
Yes, it was discussed before. You cannot multiply qword by dword, so this combination is not allowed just for the same reason as "imul eax,edx,byte 0" is disallowed. The "dword" case is allowed, because the size is right in this case, and is just a redudant operator. For 64-bit prefixing with "qword" works where you want to have full-size immediate, analoguosly, however the "imul" instruction doesn't have a 64-bit variant with full-size immediate.
Post 11 Oct 2009, 21:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.