flat assembler
Message board for the users of flat assembler.

Index > Main > Changing code/data at assembly time?

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 10 May 2006, 16:50
Is it possible to change pieces of code or data at assembly time?
Something like:
1) I declare a equate (so changing from 1 to 0 will disable it):
Code:
Active = 1
    


2) When assembling, FASM looks to if's and if condition is match, then it declares some variable or change the value of a variable:
Code:
if Active=1
  var1 db 'A'
else
  var1 db 'B'
endif
    

Now how to turn it into a counter? Like I delare "var1 db 0", and if some condition is match, then it add 1 to var1. becoming 1. And later, 2, 3, and so on...

Thanks
Post 10 May 2006, 16:50
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 10 May 2006, 17:14
Section 2.2.1 of manual has this example:
Code:
    dd sum
    x = 1
    x = x+2
    sum = x    

This can be adopted for your needs like:
Code:
var db final
    x = 'A'
    if Active
       x = 'B'
    end if
    final = x    
Post 10 May 2006, 17:14
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.