flat assembler
Message board for the users of flat assembler.

Index > Main > we can't PUSH a byte?

Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
Code:
push teste
push byte[teste]  ; Error: invalid size of operand
push word[teste]
push dword[teste]

teste db 0        

_________________
Sorry if bad english.
Post 09 Jul 2010, 11:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
No. The CPU does not support.
Post 09 Jul 2010, 11:09
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
oh.. o.o
Post 09 Jul 2010, 11:10
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
Code:
0040100C   6A 10              push    10h
0040100E   66:68 1000         push    word 10h
00401012   68 10000000        push    dword 10h    


why in this case it stores 10h like a byte?

_________________
Sorry if bad english.
Post 09 Jul 2010, 11:17
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1608
Location: Ukraine
shoorick
looks more as it stores it as dword Wink try it under debugger step-by-step Wink
Post 09 Jul 2010, 11:41
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
push dword 10: $68'0000000a
Post 09 Jul 2010, 11:42
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
ie. fasm tries to optimize it to make code a less as possible until you specify explicit
Post 09 Jul 2010, 11:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
Teehee wrote:
Code:
0040100C   6A 10              push    10h
0040100E   66:68 1000         push    word 10h
00401012   68 10000000        push    dword 10h    


why in this case it stores 10h like a byte?
The CPU can push signed values. 0x10 is sign extended to the operand size, in this case a dword.

Values up to 0x7f for positive, and down to 0x80 for negative.

|0x6a,0x80| will push 0xffffff80 to the stack. It is just a short form to save bytes in the code stream.
Post 09 Jul 2010, 12:28
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
nice.. thank you.
Post 09 Jul 2010, 12:35
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Teehee,

If you, for any reason, need to push exactly a byte, lea esp, [esp-1] / mov byte[esp], something may be useful. Wink
Post 11 Jul 2010, 02:15
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 707
Location: Adelaide
sinsi
Don't push a word onto the stack in windows if you are going to call an API, the stack is supposed to be dword aligned
Post 11 Jul 2010, 02:21
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.