FAIL - Generate Error message

Syntax
FAIL  <arg>|<string>

Synonym

None

Description

There are three modes of the FAIL directive, depending upon the operand that is specified:

Examples

The assembly code in the following listing generates the error messages in the next listing. The value of the operand associated with the `FAIL  200' or `FAIL  600'directives determines (1) the format of any warning or error message and (2) whether the source code segment will be assembled.

Listing: Example source code

cpChar: MACRO
          IFC "\1", ""

            FAIL  200

            MEXIT

          ELSE

            LDA   \1

          ENDIF

          IFC "\2", ""

            FAIL  600

          ELSE

            STA   \2

          ENDIF

        ENDM

codSec: SECTION

Start:

        cpChar char1
Listing: Error messages resulting from assembling the source code

>> in "C:\Freescale\demo\warnfail.asm", line 13, col 19, pos 226
          IFC "\2", ""

            FAIL  600

                  ^

WARNING A2332: FAIL found

Macro Call :             FAIL 600

The following listing is another assembly code example which again incorporates the FAIL  200 and the FAIL  600 directives.

Listing: Example source code

cpChar: MACRO
          IFC "\1", ""

            FAIL  200

            MEXIT

          ELSE

            LDA  \1

          ENDIF

          IFC "\2", ""

            FAIL  600

          ELSE

            STA  \2

          ENDIF

        ENDM

codeSec: SECTION

Start:

         cpChar, char2

The following listing is the error message that was generated as a result of assembling the source code in the above listing.

Listing: Error messages resulting from assembling the source code

>> in "C:\Freescale\demo\errfail.asm", line 6, col 19, pos 96
          IFC "\1", ""

            FAIL  200

                  ^

ERROR A2329: FAIL found

Macro Call :             FAIL 200

The following listing has additional uses of the FAIL directive. In this example, the FAIL  string and FAIL  600 directives are used.

Listing: Example source code

cpChar: MACRO
          IFC "\1", ""

            FAIL  "A character must be specified as first parameter"

            MEXIT

          ELSE

            LDA  \1

          ENDIF

          IFC "\2", ""

            FAIL  600

          ELSE

            STA  \2

          ENDIF

        ENDM

codeSec: SECTION

Start:

        cpChar, char2

The following listing shows the error messages generated from the assembly code as a result of the FAIL directive.

Listing: Error messages resulting from assembling the source code

>> in "C:\Freescale\demo\failmes.asm", line 7, col 17, pos 110
          IFC "\1", ""

            FAIL "A character must be specified as first parameter"

                   ^

ERROR A2338: A character must be specified as first parameter

Macro Call :   FAIL "A character must be specified as first parameter"