I Like the Select statement better than the IF......ELSE

Started by Robert Collins, December 22, 2004, 11:05:05 PM

Previous topic - Next topic

Robert Collins

Is there a Select case command (maybe a macro) similar to the one used in C and/or Visual Basic for Assembly programs?

hutch--

Robert,

In the macros that MASM32 supports there is a very good Switch/Case set of macros written by Greg Falen. I did some aliases so you could use Select/Case as well. You will find the macros in the macros.asm file in MASM32 in the macros directory. just include the macro file after the include files in your project and you can use all of them.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

BogdanOntanu

It might be and if there is not ...
I guess writting one is pretty easy

However in MASM and TASM the IF macro is actually a CASE construct when using the ELSEIF variation like that:


mov ebx,[another_variable]
.IF [test_value]==16
            ; do something here
.ELSEIF [test_value]==27
            ; some other things
.ELSEIF [test_value]==MY_ACT_MESSAGE
            ;action based on equates
.ELSEIF [test_value]>39
            ; as you can se we can have real conditions
            ; a thing not available in C /C++
.ELSEIF [test_value]<ebx
           ; now ve can even test against a variable ;)
.ELSE
           ; here we can do the normal "otherwise" statement
.ENDIF


So you see it is much better than a "simple C" SWITCH statement ...
But i am sure that a macro specialized guy can easyly furfill your apparent need

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Robert Collins

Quote from: hutch-- on December 22, 2004, 11:33:01 PM
Robert,

In the macros that MASM32 supports there is a very good Switch/Case set of macros written by Greg Falen. I did some aliases so you could use Select/Case as well. You will find the macros in the macros.asm file in MASM32 in the macros directory. just include the macro file after the include files in your project and you can use all of them.

Thanks, hutch. I was too eager to post the message. I found the macros.asm file right after I posted.

Robert Collins

Quote from: BogdanOntanu on December 22, 2004, 11:38:55 PM
It might be and if there is not ...
I guess writting one is pretty easy

However in MASM and TASM the IF macro is actually a CASE construct when using the ELSEIF variation like that:


mov ebx,[another_variable]
.IF [test_value]==16
            ; do something here
.ELSEIF [test_value]==27
            ; some other things
.ELSEIF [test_value]==MY_ACT_MESSAGE
            ;action based on equates
.ELSEIF [test_value]>39
            ; as you can se we can have real conditions
            ; a thing not available in C /C++
.ELSEIF [test_value]<ebx
           ; now ve can even test against a variable ;)
.ELSE
           ; here we can do the normal "otherwise" statement
.ENDIF


So you see it is much better than a "simple C" SWITCH statement ...
But i am sure that a macro specialized guy can easyly furfill your apparent need



Come to think about it you're right. I never really gave any thought to that, I just saw .IF ..... .ELSEIF ..... .ELSEIF ..... .ELSE ...... .ENDIF and left it as that. Thanls for the clue.