ARM Technical Support Knowledge Articles

DIFFERENCE BETWEEN IF AND $IF

Applies to: A51 Macro Assembler

Answer


Information in this article applies to:


QUESTION

What's the difference between the $IF and IF conditional statements?

ANSWER

The primary difference between $IF and IF is the defined names or symbols that may be tested. In assembler, there are several ways to define symbols.

The $IF statement may only be used to test symbols defined with $SET or $RESET within the program or on the command line.

The IF statement may only be used to test symbols defined with EQU, LIT, or SET, or labels with an absolute address. IF may not be used to test symbols defined with $SET or $RESET.

For example:

$set    (var1=1)
var2    equ     2
var3    lit     '3'   ;This works only on AX51
var4    set     4

dseg at 5
var5: ds 1

$if (var1 eq 1)
  __error__ "1"
$endif

if (var2 eq 2)
  __error__ "2"
endif

if (var3 eq 3)
  __error__ "3"
endif

if (var4 eq 4)
  __error__ "4"
endif

if (var5 ge 5)
  __error__ "5"
endif

SEE ALSO

Article last edited on: 2004-06-07 23:34:12

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential