flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > if and else again

Author
Thread Post new topic Reply to topic
uri



Joined: 09 Apr 2004
Posts: 44
Location: L'viv, Ukraine
Good day, look this

program:
Code:
format MS COFF
macro    select  a,b,c
{
if b > c
   a equ b
else
   a equ c
end if
}

public    main as '_main'
main:
  select      myvar,3,7
mov        eax,myvar
  select   myvar,6,4
mov        eax,myvar
  ret
    

result:
Code:
B8 07000000  mov     eax, 7
B8 04000000  mov     eax, 4
C3                 retn
    

why mov eax,4 ? must be mov eax,6

i want to use equ, no = , because i want like this

select myvar, var1, var2

it's possible?

thanks
Post 06 May 2004, 11:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 874
Location: Colombia
Weird, there is a problem with macro substitution. "if-else" does it right.
I'm puzzled ¿?

Compiling this:
Code:
macro select a,b,c
{
if b > c
   display 'b > c = TRUE',0Dh,0Ah
   display 'before a,b,c = ',a+30h,', ',b+30h,', ',c+30h,', ',0Dh,0Ah
   a equ b
   display 'after equ a,b,c = ',a+30h,', ',b+30h,', ',c+30h,', ',0Dh,0Ah
else
   display 'b > c = FALSE',0Dh,0Ah
   display 'before a,b,c = ',a+30h,', ',b+30h,', ',c+30h,', ',0Dh,0Ah
   a equ c
   display 'after equ a,b,c = ',a+30h,', ',b+30h,', ',c+30h,', ',0Dh,0Ah
end if
}
myvar equ 0
display 'myvar = ',myvar+30h,0Dh,0Ah
select myvar,3,7
display 0Dh,0Ah,'myvar = ',myvar+30h,0Dh,0Ah
select myvar,6,4
display 0Dh,0Ah,'myvar = ',myvar+30h,0Dh,0Ah
myvar equ 6
display 0Dh,0Ah,'myvar = ',myvar+30h
    

Will result in:
Code:
myvar = 0
b > c = FALSE
before a,b,c = 3, 3, 7, 
after equ a,b,c = 7, 3, 7, 

myvar = 7
b > c = TRUE
before a,b,c = 7, 6, 4, 
after equ a,b,c = 6, 6, 4, 

myvar = 4

myvar = 6    
Post 06 May 2004, 13:05
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1095
Location: Poland
maybe it's because IF's are processed at assembly stage, so they will be calculated *after* equ's.
Post 06 May 2004, 13:32
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7362
Location: Kraków, Poland
See the third question in the FAQ.


Last edited by Tomasz Grysztar on 11 Jun 2005, 18:40; edited 1 time in total
Post 06 May 2004, 14:37
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-2019, Tomasz Grysztar.

Powered by rwasa.