flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > About irps reg,reglist {reverse pop reg}

Author
Thread Post new topic Reply to topic
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 06 Feb 2010, 23:44
Hallo,
bug ?
Code:
format PE64 GUI 5.0
entry start
include 'win64a.inc'

define reglist rax rbx rdi rsi

section '.data' data readable writeable
  _title TCHAR 'Win64 program template',0
section '.code' code readable executable
start:
 irps reg,rax rbx rdi rsi {forward push reg} ;OK
 nop
 irps reg,rax rbx rdi rsi {reverse pop reg} ;OK
 nop
 irps reg,reglist {forward push reg} ;OK
 nop
 irps reg,reglist {reverse pop reg} ;<------ NOT OK
 ret
    


Cheers,
hopcode
Post 06 Feb 2010, 23:44
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 07 Feb 2010, 00:35
hopcode, no, not a bug.

Check the difference between:
Code:
 irps reg,reglist {forward display `reg, 13 ,10}
 display "-------", 13, 10
 nop
 irps reg,reglist {reverse display `reg, 13 ,10} 
     
And:
Code:
 match reglist, reglist{
 irps reg,reglist \{forward display \`reg, 13 ,10\}
 display "-------", 13, 10
 nop
 irps reg,reglist \{reverse display \`reg, 13 ,10\} 
 }    


Your first "irps reg, reglist" gave you the illusion that it was working because PUSH and POP supports an arbitrary number of parameters (not separated by commas), and are always processed in forward order.
Post 07 Feb 2010, 00:35
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 07 Feb 2010, 01:19
Oh, yes, lot of thanks.
That is a very subtle difference! To try an explanation: un-wrap/extract with a match the single elements contained under the symbol "reglist" and give them, as they are positioned, to the irps directive.
corrected to
Code:
define reglist rax rbx rdi rsi
match reglist, reglist{
 irps reg,reglist \{forward push reg \}
 irps reg,reglist \{reverse pop reg \} 
 }
    

Cheers,
hopcode

(moderator can freely move the tread if needed)

btw: i needed it for this thread where i will post a reply in 10 minutes
http://board.flatassembler.net/topic.php?p=109427#109427
Post 07 Feb 2010, 01:19
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.