Search code examples
x86masm

If-else macro in MASM


In MASM, is it possible to create an if...ekse macro (similar to those found in high-level programming languages)? I haven't yet found any kind of if-else statement macro for MASM, but I think a macro for this purpose would be very useful.

It would be useful if I could find a macro to make it easier to write a complicated series of if-statements in masm, as shown here:

;jump to each case here
    checkCase1:
    cmp theVariable, 5;
    jne case1; 

    checkCase2:
    cmp theVariable, var2;
    jne case2;

    jmp defaultCase; do this if no other statement is true
;each of the cases are handled here

    case1:
    ;handle case 1
    jmp checkCase2; //check whether case 2 is true

    case2:
    handle case 2
    jmp endOfStatement;
    defaultCase:
        ;this is the default case
endOfStatement:
;this is the end of the statement

Solution

  • Nobody reads the manual anymore??? Assembly has been around for YEARS, MASM has been out for YEARS!!! Tons of samples and documentation!!!

    For example:

    .if eax == 1
    
    .elseif eax !=10
    
    .elseif eax >= 11
    
    .else
    
    .endif
    

    MASM32 contains a case macro...