Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
Скачиваний:
475
Добавлен:
12.08.2013
Размер:
4.99 Mб
Скачать

186

Chapter 9

;=====================================================================

;

; Configuration Bits

;

;=====================================================================

_CP_ON

EQU

H’000F’

_CP_OFF

EQU

H’3FFF’

_PWRTE_ON

EQU

H’3FF7’

_PWRTE_OFF

EQU

H’3FFF’

_WDT_ON

EQU

H’3FFF’

_WDT_OFF

EQU

H’3FFB’

_LP_OSC

EQU

H’3FFC’

_XT_OSC

EQU

H’3FFD’

_HS_OSC

EQU

H’3FFE’

_RC_OSC

EQU

H’3FFF’

Names in the include file are defined in all-capital letters. It is probably a good idea to adhere to this style instead of creating alternate names in lower case. The C-like #include directive is used to refer the .inc files at assembly time, for example:

#include <p16f84a.inc>

9.4.6 Errorlevel Directive

This directive allows controlling the warning and error messages produced at assembly and link times. One particular type of warning can be disturbing: those that refer to bank changes. Applications often turn off bank change related warning with the following line:

errorlevel -302

9.5 Pseudo Instructions

Sometimes a code listing contains instructions that are not part of the standard set for the particular device. The reason this happens is that MPLAB includes a set of p s e u d o - i n s t r u c t i o n s f o r 1 2 - a n d 1 4 - b i t d e v i c e s . Ta b l e 9 . 2 l i s t s t h e s e pseudo-instructions and their standard equivalents:

Table 9.2

PIC Pseudo Instructions

MNEMONIC

DESCRIPTION

EQUIVALENT

STATUS BIT

 

 

 

OPERATION(S)

CHANGED

 

 

 

 

ADDCF f,d

Add Carry to File

BTFSC 3,0

Z

 

 

Register

INCF f,d

 

ADDDCF f,d

Add Digit Carry

 

 

 

 

 

to File Register

BTFSC 3,1

Z

 

 

 

INCF f,d

 

B

k

Branch

GOTO k

-

BC

k

Branch on Carry

BTFSC 3,0

 

 

 

 

GOTO k

-

(continues)

PIC Programming: Tools and Techniques

 

 

187

 

 

Table 9.2

 

 

 

 

 

 

PIC Pseudo Instructions

 

 

 

 

 

 

 

MNEMONIC

DESCRIPTION

EQUIVALENT

STATUS BIT

 

 

 

OPERATION(S)

CHANGED

 

 

 

 

 

 

 

 

BDC k

 

Branch on Digit

 

 

 

 

 

 

 

Carry

BTFSC

 

3,1

 

 

 

 

GOTO k

-

 

BNC k

 

Branch on No Carry BTFSS 3,0

 

 

BNDC

k

Branch on No Digit

GOTO k

-

 

 

 

 

 

 

 

 

Carry

BTFSS

 

3,1

 

 

 

 

GOTO k

-

 

BNZ k

 

Branch on No Zero

BTFSS

 

3,2

 

 

 

 

GOTO k, 2

-

 

BZ k

 

Branch on Zero

BTFSC 3,2

 

 

 

 

 

GOTO

k

-

 

CLRC

 

Clear Carry

BCF

3,0

-

 

CLRDC

Clear Digit Carry

BCF

3,1

-

 

CLRZ

 

Clear Zero

BCF

3,2

-

 

LCALL

k

Long Call

BCF/BSF 0x0a,3

 

 

 

 

 

BCF/BSF 0x0a,4

 

 

 

 

 

CALL k

 

 

LGOTO k

Long GOTO

BCF/BSF 0x0a,3

 

 

 

 

 

BCF/BSF 0x0a,4

 

 

 

 

 

GOTO k

 

 

MOVFW f

Move File to W

MOVF f,0

Z

NEGF

f,d

Negate File

COMF

f,1

 

 

 

 

 

INCF

f,d

-

 

SETC

 

Set Carry

BSF

3,0

-

 

SETDC

 

Set Digit Carry

BSF

3,1

-

 

SETZ

 

Set Zero

BSF

3,2

-

 

SKPC

 

Skip on Carry

BTFSS

3,0

-

 

SKPDC

Skip on Digit Carry

BTFSS

3,1

-

 

SKPNC

Skip on No Carry

BTFSC 3,0

-

 

SKPNDC

Skip on No Digit

 

 

 

 

 

 

 

Carry

BTFSC

3,1

-

 

SKPNZ

 

Skip on Non Zero

BTFSC 3,2

-

 

SKPZ

 

Skip on Zero

BTFSS

3,2

-

 

SUBCF

f,d

Subtract Carry from

 

 

 

 

 

 

 

File

BTFSC

3,0

 

 

SUBDCF f,d

Subtract Digit Carry

DECF

f,d

Z

 

 

 

 

 

 

 

from File

BTFSC

3,1

 

 

 

 

 

DECF

f,d

Z

TSTF f

 

Test File

MOVF

f,1

Z

 

We have listed the PIC pseudo-instructions to provide a reference. In our programming we prefer to stay away from using them since they tend to make code less readable. Microchip recommends not using the pseudo-instructions.