EXITM Example

MPASM Assembler

EXITM Example

Directives highlighted in this example are:

  • exitm

Program Functional Description

This program demonstrates the utility of the exitm assembler directive, which causes an immediate exit from a macro. It is used in the example to exit from the macro when certain conditions are met.

Commented Code Listing

list p=16f877 ;Select the device.

#include <p16f877.inc> ;Include standard header file

;for the selected device.

result equ 20 ;Assign value 20H to label

;result.

ORG 0000 ;The following code will be placed

;in reset address 0.

goto start ;Jump to an address whose label is

;'start'.

add MACRO num1,num2 ;'add' is a macro. The values of

;'num1' and 'num2' must be passed

;to this macro.

if num1>0xff ;If num1>255 decimal,

extim ;force immediate return from

;macro during assembly.

else

if num2>0xff ;If num2>255 decimal,

extim ;force immediate return from

;macro during assembly.

else

movlw num1 ;Load W register with a literal

;value assigned to the label

;'num1'.

movwf result ;Load W register to an address

;location assigned to the label

;'result'.

movlw num2 ;Load W register with a literal

;value assigned to the label

;'num2'.

addwf result ;Add W register with the memory

;location addressed by 'result'

;and load the result back to

;'result'.

endif

endif

endm ;End of 'add' MACRO

org 0010 ;My main program starts at 10H.

start ;The label 'start' is assigned an

;address 10H.

add .100,.256 ;Call 'add' MACRO with decimal

;numbers 100 and 256 assigned to

;'num1' and 'num2' labels,

;respactively. EXTIM directive in

;macro will force return.

end


Microchip Technology Inc.
Microchip's Web Site
Voice: (480) 792-7200
Fax: (480) 899-9210
Microchip's E-mail Address
PreviousNext