flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Why PUSH/POP use irps way

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 25 Jul 2016, 11:18
Code:
PUSH 3 4    
compiled into
Code:
PUSH 3
PUSH 4    
but
Code:
PUSH 3 -4    
compiled into
Code:
PUSH -1    
.
Easily we know why it happens but what if we reach
Code:
macro foo a, b {
  push a b
  call 0xbeef
}
foo 3, -7     
? You may get difficulty in understanding what wrong it is
Post 25 Jul 2016, 11:18
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 413
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 25 Jul 2016, 12:48
Code:
3-4=-1    

you must define operand size
Code:
push dword 3 dword -4    

_________________
smaller is better
Post 25 Jul 2016, 12:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 25 Jul 2016, 19:17
The algorithm is greedy. So "3 -4" is evaluated first and then passed to the instruction encoder. You can force it like this:
Code:
push 3 (-4)    
This breaks the evaluation into two parts because as a whole it is not a valid expression.
Post 25 Jul 2016, 19:17
View user's profile Send private message Visit poster's website Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 25 Jul 2016, 19:48
Offensive post removed.


Last edited by HaHaAnonymous on 25 Jul 2016, 20:01; edited 1 time in total
Post 25 Jul 2016, 19:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 25 Jul 2016, 19:51
Additional: For your macro you can do this:
Code:
macro foo a, b {
  push (a) (b)
  call 0xbeef
}
foo 3, -7    
Post 25 Jul 2016, 19:51
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 17 Dec 2017, 00:32
revolution wrote:
Additional: For your macro you can do this:
Code:
macro foo a, b {
  push (a) (b)
  call 0xbeef
}
foo 3, -7    
error on
Code:
foo ax, bx    
Post 17 Dec 2017, 00:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 17 Dec 2017, 11:57
foo only works for numeric values. Use ordinary push for registers.
Post 17 Dec 2017, 11:57
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 20 Dec 2017, 22:39
macro using eqtype, perhaps?
Post 20 Dec 2017, 22:39
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.