rendered paste body;File Name: hello world.asm
;Author: Stephen Shirley
;Date: 2006/01/23
;Version: 1.00
;Description: Not sure yet
;
;******************************************************************************
list p=12F675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF
;******************************************************************************
;Defines
;******************************************************************************
#define Bank0 0x00
#define Bank1 0x80
#define D01Tris 0x0F
#define D0On 0x10
#define D1On 0x20
#define D23Tris 0x2B
#define D2On 0x10
#define D3On 0x04
#define D45Tris 0x1B
#define D4On 0x20
#define D5On 0x04
#define D67Tris 0x35
#define D6On 0x02
#define D7On 0x01
;******************************************************************************
;General Purpose Registers (GPR's)
;******************************************************************************
cblock 0x20
LedOn ; Led on flag
Count ; general counting reg
endc
;******************************************************************************
;Reset Vector
;******************************************************************************
ORG 0x000 ; processor reset vector
nop ; required by in circuit debugger
goto Init ; go to beginning of program
;******************************************************************************
;Interrupt Vector
;******************************************************************************
ORG 0x004
return ; interrupt trap - return without re-enabling
;******************************************************************************
;Initialization
;******************************************************************************
Init
call 0x3FF ; retrieve factory calibration value
; comment instruction if using simulator, ICD2, or ICE2000
BANKSEL Bank1 ; BANK1
movwf OSCCAL ; update register with factory cal value
movlw B'11010011' ; Timer0 internal clock, 1:4 prescale
movwf OPTION_REG ; set option register for Timer0 functions
clrf ANSEL ; configure A/D I/O as digital
banksel Bank0 ; switch back to PORT memory bank
clrf GPIO
movlw 0x77 ; configure comparator inputs as digital I/O
movwf CMCON ;
clrf Count ; zero counter
clrf Count ; zero counter
;******************************************************************************
;Main
;******************************************************************************
Main
; Wait for Timer0 overflow
; Timer0 overflows about every 1 millisecond with the internal 4 MHz clock
; and 1:4 prescale
TimerLoop
btfss INTCON,T0IF ; wait for Timer0 overflow
goto TimerLoop ;
bcf INTCON,T0IF ; clear Timer0 overflow flag
incfsz Count,1
goto TimerLoop;
call LightLed ; test switch once every millisecond
;******************************************************************************
;Subroutines & Functions
;******************************************************************************
;******************************************************************************
;TestSwitch - Test switch state and take action when filter count saturates
;******************************************************************************
LightLed
movf LedOn,1
btfsc STATUS,Z
goto LED0
decf LedOn,0
btfsc STATUS,Z
goto LED1
decf W,0
btfsc STATUS,Z
goto LED2
decf W,0
btfsc STATUS,Z
goto LED3
decf W,0
btfsc STATUS,Z
goto LED4
decf W,0
btfsc STATUS,Z
goto LED5
decf W,0
btfsc STATUS,Z
goto LED6
decf W,0
btfsc STATUS,Z
goto LED7
IncrementLed
incf LedOn,1 ; Increment LedOn variable
goto Main ; return to monitor loop
;******************************************************************************
;LED0 - Drive I/O port to turn D0 on
;******************************************************************************
LED0
BANKSEL Bank0
movlw D01Tris
movwf TRISIO
movlw D0On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED1 - Drive I/O port to turn D1 on
;******************************************************************************
LED1
BANKSEL Bank0
movlw D01Tris
movwf TRISIO
movlw D1On
movwf GPIO
goto IncrementLed
END
;******************************************************************************
;LED2 - Drive I/O port to turn D2 on
;******************************************************************************
LED2
BANKSEL Bank0
movlw D23Tris
movwf TRISIO
movlw D2On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED3 - Drive I/O port to turn D3 on
;******************************************************************************
LED3
BANKSEL Bank0
movlw D23Tris
movwf TRISIO
movlw D3On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED4 - Drive I/O port to turn D4 on
;******************************************************************************
LED4
BANKSEL Bank0
movlw D45Tris
movwf TRISIO
movlw D4On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED5 - Drive I/O port to turn D5 on
;******************************************************************************
LED5
BANKSEL Bank0
movlw D45Tris
movwf TRISIO
movlw D5On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED6 - Drive I/O port to turn D6 on
;******************************************************************************
LED6
BANKSEL Bank0
movlw D67Tris
movwf TRISIO
movlw D6On
movwf GPIO
goto IncrementLed
;******************************************************************************
;LED7 - Drive I/O port to turn D7 on
;******************************************************************************
LED7
BANKSEL Bank0
movlw D67Tris
movwf TRISIO
movlw D7On
movwf GPIO
goto IncrementLed