flat assembler
Message board for the users of flat assembler.

Index > Main > Silly or BUG: INC [EBX] vs INC [EBP] ???

Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 12 Jun 2010, 23:20
Code:
INC DWORD [EBX]
    


2 Byte's

Code:
INC DWORD [EBP]
    


3 Byte's

No way to encode [EBP] with just 2 Byte's ???
Post 12 Jun 2010, 23:20
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 12 Jun 2010, 23:56
DOS386 wrote:
Code:
INC DWORD [EBX]
    


2 Byte's

Code:
INC DWORD [EBP]
    


3 Byte's

No way to encode [EBP] with just 2 Byte's ???
Refer to "Table 2-2. 32-Bit Addressing Forms with the ModR/M Byte" in Intel's manual vol2A. As you'll see, "INC DWORD [EBP+$00]" is the shortest.
Post 12 Jun 2010, 23:56
View user's profile Send private message Reply with quote
score_under



Joined: 27 Aug 2009
Posts: 27
score_under 14 Jun 2010, 19:55
MOV EAX,[ESP+4] = 4 bytes.
MOV EAX,[EBP+4] = 3 bytes.

It's just one of those cases where there actually *is* a difference between registers on x86 Wink
Post 14 Jun 2010, 19:55
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 14 Jun 2010, 23:50
Also note: DOS386's code assumes use32
Post 14 Jun 2010, 23:50
View user's profile Send private message Reply with quote
score_under



Joined: 27 Aug 2009
Posts: 27
score_under 20 Jun 2010, 19:37
bitshifter wrote:
Also note: DOS386's code assumes use32

Uhh... real men use64 or something? Razz
Post 20 Jun 2010, 19:37
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 20 Jun 2010, 20:57
score_under,

16/64-bit inc [ebx] requires address-size prefix and can't be 2 bytes long. 32-bit can.
Post 20 Jun 2010, 20:57
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 27 Jun 2010, 11:00
Thanks.

> assumes use32

Right.
Post 27 Jun 2010, 11:00
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.