ERRORLEVEL Example
Directives highlighted in this example are:
Program Functional Description
This program demonstrates the utility of the
errorlevel
assembler directive, which sets the type of messages that are printed in the listing file and error file.Commented Code Listing
list p=16f877 ;Select the device.
#include <p16f877.inc> ;Include standard header file
;for the selected device.
errorlevel 0 ;Display/print messages,
;warnings and errors.
messg "CAUTION: This program has errors"
errorlevel 1 ;Display/print warnings
;and errors.
messg "CAUTION: This program has errors"
group1 udata 0x20
group1_var1 res 1 ;Label of this directive is not
;at column 1. This will generate
;a warning no. 207.
errorlevel -207 ;This disables warning whose
;msgnum is 207.
group1_var2 res 1 ;label of this directive is also
;not at column 1, but no warning
;is displayed/printed.
errorlevel +207 ;This enables warning whose
;msgnum is 207
group2 udata
errorlevel 2 ;Display/print errors
group2_var1 res 1 ;label of this directive is not
;at column 1. This will generate
;a warning no. 207.
errorlevel 1 ;Display/print warnings
;and errors.
group2_var2 res 1 ;label of this directive is not
;at column 1. This will generate
;a warning no. 207.
RST CODE H'0 ' ;The code section named RST is
;placed at H'0'. The instruction
;'goto start' is placed in code
;section RST.
goto start ;Jumps to the location labelled
;'start'.
INTRT CODE H'4 ' ;The code section named INTRT is
;placed at H'4'. The instruction
;'goto service_int' is placed in
;code section INTRT
goto service_int ;Label 'service_int' is not
;defined. Hence this generates
;error[113].
PGM CODE ;This is the begining of the code
;section named 'PGM'. It is a
;relocatable code section since
;no absolute address is given along
;with directive 'CODE'
start
movwf group1_var1
goto $
end
Microchip Technology Inc. Microchip's Web Site Voice: (480) 792-7200 Fax: (480) 899-9210 Microchip's E-mail Address |