flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need an if before equ

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 15:02
Code:
macro matche s{
  local t
  irps x, s \{
    if x in <(, [, \{>
      t equ x
    else if ~defined t
      goto _false
    else if x eq ) & t eq (
      restore t
    else if x eq ] & t eq [
      restore t
    else if x eq \} & t eq \{
      restore t
    else
      goto _false
    end if
  \}
  if defined t
_false:
    var equ 0
  else
    var equ 1
  end if
}    

The meaning was shown but the code is with a lot of mistake Very Happy
Post 15 Apr 2016, 15:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 15 Apr 2016, 15:07
IF and EQU are not compatible when used like that. IF is processed by the assembler, EQU by the preprocessor. In your code 'var' is always EQUated to '1'.

Instead, try using '='.
Code:
var = 0    
Post 15 Apr 2016, 15:07
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 15:09
revolution wrote:
IF and EQU are not compatible when used like that. IF is processed by the assembler, EQU by the preprocessor. In your code 'var' is always EQUated to '1'.

Instead, try using '='.
Code:
var = 0    
I knew that. I just want to know how to do the right thing
Post 15 Apr 2016, 15:09
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 15:12
Mainly I wonder how to do with this
Code:
    if x in <(, [, \{> 
      t equ x 
    else if ~defined t 
      goto _false 
    
Post 15 Apr 2016, 15:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 15 Apr 2016, 15:16
Use MATCH instead of IF.
Post 15 Apr 2016, 15:16
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 15:21
Code:
macro matche s{ 
  local t 
  irps x, s \{ 
    if x in <(, [, \{> 
      t equ x 
    else if x eqtype 0
      t equ num 
    else if ~defined t 
      goto _false 
    else if x eq ) & t eq ( 
      restore t 
    else if x eq ] & t eq [ 
      restore t 
    else if x eq \} & t eq \{ 
      restore t 
    else if x eqtype eax & t eq num 
      restore t 
    else 
      goto _false 
    end if 
  \} 
  if defined t 
_false: 
    var equ 0 
  else 
    var equ 1 
  end if 
}    

with eqtype still use MATCH how?
Post 15 Apr 2016, 15:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 15 Apr 2016, 15:26
You can't use IF any other assembler operator like EQ or EQTYPE with RESTORE/MATCH/EQU like that. You'll need to use only preprocessor operators, or only assembler operators. You have to understand that the two stages are completely separate.
Post 15 Apr 2016, 15:26
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 15 Apr 2016, 15:29
If you want an example to show one way to use MATCH look at the macro 'allow_nesting' in WIN32AX.inc.
Post 15 Apr 2016, 15:29
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 15:53
I didn't ask why not correct but how to make it correct, right?
Post 15 Apr 2016, 15:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 15 Apr 2016, 16:14
l4m2 wrote:
I didn't ask why not correct but how to make it correct, right?
I think the example I mentioned above will give you a good starting point.

But I also think that writing a full parser in fasm preprocessor syntax will be very challenging. Perhaps Tomasz's suggestion about using fasmg (in your other thread) is worth considering.
Post 15 Apr 2016, 16:14
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 15 Apr 2016, 23:48
Code:
macro matche s{
  local t 
  irps x, s \{ 
    if x in <(, [, \{> 
      t = x
    else if ~defined t 
      goto _false 
    else if x eq ) & t eq ( 
      =restore t
    else if x eq ] & t eq [ 
      =restore t
    else if x eq \} & t eq \{ 
      =restore t
    else 
      goto _false 
    end if 
  \} 
  if defined t 
_false: 
    var = 0 
  else 
    var = 1 
  end if 
}    

If using Control directives how to make the stack ?
Post 15 Apr 2016, 23:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20421
Location: In your JS exploiting you and your system
revolution 16 Apr 2016, 11:42
EQU pushes on the stack, RESTORE pops off the stack. IRPV enumerates the stack.
Post 16 Apr 2016, 11:42
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.