flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [solved] imul ebx,2

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

the fasm compiler allows "imul ebx,2" Shocked

(result after compiling: "imul ebx,ebx,2")

the two operand form of imul does not allow an immediate value as second operand.
that said, there is an error about this in the intel doc.
Quote:
Two-operand form — With this form the destination operand (the first
operand) is multiplied by the source operand (second operand). The destination
operand is a general-purpose register and the source operand is an immediate
value, a general-purpose register, or a memory location. The product is then
stored in the destination operand location.
... and the source operand is an immediate value <--- false,
a general-purpose register, or a memory location.

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 08 Sep 2011, 21:57; edited 1 time in total
Post 08 Sep 2011, 17:55
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Intel Manual lists these instructions:

IMUL r32,r32,imm8
IMUL r32,imm8

And both of these have exact same encoding.
Load OLLYDBG (or other debugger) and try these two.
You will see the same instruction bytes for both.
Post 08 Sep 2011, 19:51
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
Quote:
Intel Manual lists these instructions:
IMUL r32,r32,imm8
IMUL r32,imm8 <--- ?
i don't see anything about "IMUL r32,immediate value"

Volume 2A - Instruction Set Reference, A-M
253666-038US - April 2011

Image

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 08 Sep 2011, 20:28
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Smile
It is been removed from the latest manual, but my old manual from 2007 still has it.

I am thinking that Intel removed it, because it is the same code as IMUL r32,r32,imm8. They removed redundant information.

It properly compiles into longer version - there is no bug(s) here. Not in manuals and not in FASM itself.
Post 08 Sep 2011, 21:46
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

ok, understood, thank you AsmGuru62

edit: IMUL r32, imm32 works too.
Code:
;http://www.ousob.com/ng/iapx86/ngce71.php

    69 /r iw    IMUL r16,imm16          ; 186+
    69 /r iw    IMUL r16,r/m16,imm16    ; 186+
    69 /r id    IMUL r32,imm32          ; 386+ <-----
    69 /r id    IMUL r32,r/m32,imm32    ; 386+

    6B /r ib    IMUL r16,imm8           ; 186+
    6B /r ib    IMUL r16,r/m16,imm8     ; 186+
    6B /r ib    IMUL r32,imm8           ; 386+ <-----
    6B /r ib    IMUL r32,r/m32,imm8     ; 386+
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 08 Sep 2011, 21:56
View user's profile Send private message Send e-mail 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.