flat assembler
Message board for the users of flat assembler.

Index > Main > if .....

Author
Thread Post new topic Reply to topic
wishmaster



Joined: 25 Aug 2004
Posts: 9
wishmaster 09 Oct 2004, 12:50
Hi, i have a problem with "if". I want to use if on a value from a variable:

Code:
abc db 5
.....
if [abc] > 6
end if
......
    


But that doesnt work: error: invalid value.

I hope somebody can help me.
Post 09 Oct 2004, 12:50
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 09 Oct 2004, 13:04
IF is processed before the assembly takes place. I don't think that you can check the value of a variable at the preprocessing stage.
Post 09 Oct 2004, 13:04
View user's profile Send private message Visit poster's website Reply with quote
wishmaster



Joined: 25 Aug 2004
Posts: 9
wishmaster 09 Oct 2004, 13:14
Is there a way to check the value of a variable ? TASM supports that.
Post 09 Oct 2004, 13:14
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 09 Oct 2004, 13:34
Smile
don't use post processor for that

Code:
; you can say this is a character table writer program,
; but its destination is to demonstrate using a simple variable in FASM
; MATRIX
; oh, i have discovered it is 32 bytes Smile
org 256

and word [testvar],0
mov ax,$b800
push es
mov es,ax

mov ah,$07
mainloop:
stosw
inc word [testvar]
mov al,byte [testvar]
cmp word [testvar],255
jb mainloop ; if [testvar] <= 50 then goto mainloop

pop es
int 20h

testvar: rw 1
    


MATRIX
Post 09 Oct 2004, 13:34
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 09 Oct 2004, 13:50
I think you could do something like:

Code:
abc_value = 5
abc db abc_value

if abc_value < 6
. . .
then
    


Just out of curiosity, why do you need to check the value of a variable during the preprocessing time?
Post 09 Oct 2004, 13:50
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 09 Oct 2004, 20:29
crc: what you've done it's better to do this way:
Code:
abc db 5

load abc_value from abc
if abc_value < 6
; ...
end if    


However it seems that it's just the ".if" macro what wishmaster is looking for, to generate the code that will do the checking of the variable at the run time.
Post 09 Oct 2004, 20:29
View user's profile Send private message Visit poster's website Reply with quote
wishmaster



Joined: 25 Aug 2004
Posts: 9
wishmaster 10 Oct 2004, 11:03
Thank you, that works well Very Happy
Post 10 Oct 2004, 11:03
View user's profile Send private message Reply with quote
Dragontamer



Joined: 24 Aug 2003
Posts: 84
Dragontamer 10 Oct 2004, 23:59
Just wanna make sure you know...

the if statement will always be true.

It is a PREPROCESSOR statement. I agree with Privalov, the ".if" macro is what you want.

What I would use, is the conditional jumps. But thats just me.
Post 10 Oct 2004, 23:59
View user's profile Send private message 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.