flat assembler
Message board for the users of flat assembler.

Index > Main > A bug?

Author
Thread Post new topic Reply to topic
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83
Why is it that
Code:
add ax,0xFFFF    
generates the 0x83 opcode rather than 0x05?
This not only is bad optimization, but isn't it wrong because 0x83 is add modrm16, imm8
(v1.67.88)

_________________
x86 CPU Emulation library: http://sourceforge.net/projects/x86lib
Post 19 Nov 2007, 17:54
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
0x83 adds modrm16 to SIGN-EXTENDED imm8. Sign-extended 0xFF (byte -1) to word is 0xFFFF (word -1)

05 takes fixed imm16/imm32 operand (2 or 4 bytes), where 83 has 1 byte operand
Post 19 Nov 2007, 18:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83
hmm...well, for 16bit, as long as modrm isn't slower, 0x83 and 0x05 are the same for 0xFFFF....hmm...

(makes note that 0x83 is sign extended)

thanks for telling me...
Post 19 Nov 2007, 18:19
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
no problemo. Tomasz probably preferred 83 because it is equal good in 16bit mode, and better in 32bit mode

check out Intel Manual 2A and Intel Manual 2B.
Post 19 Nov 2007, 18:36
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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.