Conditional directives
RASM supports a set of directives that allow you to influence the assembly by checking conditional expressions. In general case, when variables are used in these expressions, they must be defined at evaluation time.
ASSERT
ASSERT condition
ASSERT condition,text,...
This directive evaluates the condition and stops the assembly if the condition is false. An optional text (similar to the PRINT directive) can be sent to the console.
ASSERT $<#38
ASSERT data<#3FFF,'data leak!'
IF, IFNOT, ELSE, ELSEIF, ELSEIFNOT condition
IF condition ... ELSE ... ENDIF
IF condition ... ELSEIF condition ... ENDIF
IF condition ... ELSEIF condition ... ELSE ... ENDIF
IFNOT condition ... ELSE ... ENDIF
IFNOT condition ... ELSEIF condition ... ENDIF
IFNOT condition ... ELSEIF condition ... ELSE ... ENDIF
Define conditional assembly blocks based on an expression
CODE_PRODUCTION=1
if CODE_PRODUCTION
or #80
else
and #7F
endif
out (c),a
IFDEF, IFNDEF
Define conditional blocks based on the existence or not of a variable, a label, an alias or a macro
IFDEF production
or #80
ENDIF
UNDEF
UNDEF variable
Deletes a variable from RASM. If the variable does not exist, the directive has no effect.
IFUSED, IFNUSED
Define conditional blocks based on whether or not a variable, label or alias was used in an expression, at the time of calling these directives.
SWITCH, CASE, DEFAULT, BREAK, ENDSWITCH
The syntax is similar to the switch/case of the C language, with the particularity of being able to write several CASE blocks with the same value, which offers more flexibility to the conditional code (partially mutualize code between different cases). A SWITCH block is terminated with the ENDSWITCH direction.
grouik=5
switch grouik
nop ; outside CASE perimeter, this NOP wont be produced
case 3
defb 'A'
case 5
defb 'B'
case 7
defb 'C'
break
case 8
defb 'D'
case 5
defb 'E'
break
default
defb 'F'
endswitch
; sortie => BCE
The parser will pass through CASE 5, continue in CASE 7 which makes a BREAK, there will be a restart in the second CASE 5. The DEFAULT tag will be ignored because we have previously passed through at least one CASE.