Specifications
mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix B: Examples
Example 10:
;********************** Header **********************************************
;************* DEFINING VARIABLES *******************************************
cblock 0x20 ; Block of variables starts at address 20h
w_temp ; Variable at address 20h
pclath_temp ; Variable at address 21h
status_temp ; Variable at address 22h
endc
#define DARK PORTB,0 ; Push-button "DARK" is connected
; to PORTB,0 pin
#define BRIGHT PORTB,1 ; Push-button "BRIGHT" is connected
; to PORTB,1 pin
;************************ PROGRAM START *************************************
org 0x0000 ; First program instruction address
goto main ; Jump to label "main"
;************************ INTERRUPT ROUTINE *********************************
org 0x0004 ; Interrupt vector
movwf w_temp ; Save register W
movf STATUS ; Save register STATUS
movwf status_temp
http://www.mikroe.com/en/books/picmcubook/appb/ (36 of 54)5/3/2009 11:36:02 AM