flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > IF.inc checking for bit set condition?

Author
Thread Post new topic Reply to topic
Glom



Joined: 29 May 2006
Posts: 2
Glom
i previously used masm for my coding.

there i was able to use the following input for the .IF .WHILE etc macros
Code:
.IF eax & 6
   xor eax, eax
.ENDIF
   xor ebx, ebx

;which would generate the following asm intr.
test eax, 6
jz @F 
xor eax, eax
@@:
xor ebx, ebx
    


AFAIK this is not handled in the current macros in IF.inc, since the "&" and "|" are used in another way.
Im not experienced enough with the fasm macro system yet to implement this myself. I want to change the current "&" and "|" macros to use "&&" and "||" instead(this i am able to do), and implement the .IF eax & 8(dunno quite how todo this yet) Any pointers as to how i can implement this into the IF.inc macros?


This is how im handling it atm:
Code:
        mov dx, SMB_Status
        
        in al, dx
        test al, 8
        .while ~ZERO?
        
                in al, dx
                test al, 2
                .if ~ZERO?
                        jmp retry
                .endif
        
                in al, dx
                test al, 34h
                .if ~ZERO?
                        xor eax, eax
                        jmp @f 
                .endif
        
        in al, dx
        test al, 8
        .endw

;which is quite messy compared to:
        mov dx, SMB_Status
        
        in al, dx
        .while al &  8

                in al, dx
                .if al & 2
                        jmp retry
                .endif
        
                in al, dx
                .if al & 34h
                        xor eax, eax
                        jmp @f 
                .endif
        
        in al, dx
        .endw



@@:    


Regards,
Glom
Post 29 May 2006, 05:18
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Paste this in your IF.INC file (..\fasm\include\macro\if.inc) in JCOND macro just after the 'common' keyword. This will let you use: '.if eax & 1...' combinations
Code:
 match =COND v1=&v2, COND cond
 \{
   test v1,v2
   je label
   COND equ
 \}    
Unfortuantely, I don't know how does the '|' operator work in MASM.
Post 30 May 2006, 15:30
View user's profile Send private message Visit poster's website Reply with quote
Glom



Joined: 29 May 2006
Posts: 2
Glom
Quote:
Paste this in your IF.INC file (..\fasm\include\macro\if.inc) in JCOND macro just after the 'common' keyword.


Can't seem to find this particular spot.. maybe i havent got same IF.inc as you?

Running flat assembler version 1.66 for windows atm.. i've attached my IF.inc so you can have a look.




Quote:
Unfortuantely, I don't know how does the '|' operator work in MASM.

basically it's a bitwise 'or' operation
..as for the code thats generated, im not absolutely sure about


Description: my ..fasmincludemacroIF.inc file
Download
Filename: IF.INC
Filesize: 8.41 KB
Downloaded: 106 Time(s)

Post 31 May 2006, 20:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Quote:
Code:
                .if al & 2
                        jmp retry
                .endif    

Well, maybe that's a matter of taste, but for me this looks really terrible.
Post 31 May 2006, 21:23
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
same here :]
Post 31 May 2006, 22:18
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
When I posted it I had older version of fasm installed. Now I see the IF.INC file is somewhat more complicated Smile
Post 01 Jun 2006, 10:43
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.