flat assembler
Message board for the users of flat assembler.

flat assembler > Compiler Internals > Why PUSH/POP use irps way

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 613
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: 274
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
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: 15904
Location: SDSS J140821.67+025733.2
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: 1171
Location: Unknown
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: 15904
Location: SDSS J140821.67+025733.2
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: 613
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: 15904
Location: SDSS J140821.67+025733.2
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: 2290
Location: Usono (aka, USA)
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-2018, Tomasz Grysztar.

Powered by rwasa.