;********************************************* ;* Code Produced by the * ;* PICBASIC PLUS LITE Compiler. Version 1.10 * ;********************************************* LIST P=16F877 , w=2, x=on, r=DEC #include "P16F877.lpb" XTAL = 20 RAM_BANKS = 4 BANK0_START = 32 BANK0_END = 127 BANK1_START = 160 BANK1_END = 239 BANK2_START = 272 BANK2_END = 367 BANK3_START = 400 BANK3_END = 495 p@b=0 c@s=8 s@b macro v@r if((v@r&384)==0) if(p@b==1) bcf 3,5 endif if(p@b==2) bcf 3,6 endif if(p@b==3) bcf 3,5 bcf 3,6 endif p@b=0 endif if((v@r&384)==128) if(p@b==0) bsf 3,5 endif if(p@b==2) bsf 3,5 bcf 3,6 endif if(p@b==3) bcf 3,6 endif p@b=1 endif if((v@r&384)==256) if(p@b==0) bsf 3,6 endif if(p@b==1) bcf 3,5 bsf 3,6 endif if(p@b==3) bcf 3,5 endif p@b=2 endif if((v@r&384)==384) if(p@b==0) bsf 3,5 bsf 3,6 endif if(p@b==1) bsf 3,6 endif if(p@b==2) bsf 3,5 endif p@b=3 endif endm r@b macro if((p@b&1)!=0) bcf 3,5 endif if((p@b&2)!=0) bcf 3,6 endif p@b=0 endm mov@fw macro bytein s@b bytein movf bytein,w endm mov@ff macro bytein s@b bytein movf bytein,f endm mov@wf macro bytein s@b bytein movwf bytein endm mov@lf macro numin,byteout movlw numin mov@wf byteout endm clr@f macro bytein s@b bytein clrf bytein endm addwf@f macro bytein s@b bytein addwf bytein,f endm addwf@w macro bytein s@b bytein addwf bytein,w endm subwf@f macro bytein s@b bytein subwf bytein,f endm subwf@w macro bytein s@b bytein subwf bytein,w endm incf@f macro bytein s@b bytein incf bytein,f endm incf@w macro bytein s@b bytein incf bytein,w endm decf@f macro bytein s@b bytein decf bytein,f endm decf@w macro bytein s@b bytein decf bytein,w endm andwf@f macro bytein s@b bytein andwf bytein,f endm andwf@w macro bytein s@b bytein andwf bytein,w endm comf@f macro bytein s@b bytein comf bytein,f endm comf@w macro bytein s@b bytein comf bytein,w endm xorwf@f macro bytein s@b bytein xorwf bytein,f endm xorwf@w macro bytein s@b bytein xorwf bytein,w endm iorwf@f macro bytein s@b bytein iorwf bytein,f endm iorwf@w macro bytein s@b bytein iorwf bytein,w endm swapf@f macro bytein s@b bytein swapf bytein,f endm swapf@w macro bytein s@b bytein swapf bytein,w endm rrf@f macro bytein s@b bytein rrf bytein,f endm rrf@w macro bytein s@b bytein rrf bytein,w endm rlf@f macro bytein s@b bytein rlf bytein,f endm rlf@w macro bytein s@b bytein rlf bytein,w endm set@bit macro varin,bitin s@b varin bsf varin,bitin endm clr@bit macro varin,bitin s@b varin bcf varin,bitin endm btf@sc macro varin,bitin s@b varin btfsc varin,bitin endm btf@ss macro varin,bitin s@b varin btfss varin,bitin endm incfsz@w macro bytein s@b bytein incfsz bytein,w endm incfsz@f macro bytein s@b bytein incfsz bytein,f endm decfsz@w macro bytein s@b bytein decfsz bytein,w endm decfsz@f macro bytein s@b bytein decfsz bytein,f endm bc@f macro varin,bitin s@b varin bcf varin,bitin endm bs@f macro varin,bitin s@b varin bsf varin,bitin endm jump macro dest goto dest endm wreg_byte macro byteout mov@wf byteout endm wreg_bit macro varout,bitout s@b varout andlw 1 skpnz bcf varout,bitout skpz bsf varout,bitout endm wreg_word macro wordout mov@wf wordout clr@f wordout+1 endm byte_wreg macro bytein mov@fw bytein endm num_wreg macro numin movlw low numin endm num_byte macro numin,byteout if(low numin==0) clr@f byteout else movlw low numin mov@wf byteout endif endm num_bit macro numin,varout,bitout if((numin&1)==1) bs@f varout,bitout else bc@f varout,bitout endif endm num_word macro numin,wordout if(low numin==0) clr@f wordout else movlw low numin mov@wf wordout endif if(high numin==0) clr@f wordout+1 else movlw high numin mov@wf wordout+1 endif endm bit_wreg macro varin,bitin clrw btf@sc varin,bitin movlw 1 endm bit_byte macro varin,bitin,byteout clrw btf@sc varin,bitin movlw 1 mov@wf byteout endm bit_bit macro varin,bitin,varout,bitout if((varin&65408)==(varout&65408)) s@b varout btf@sc varin,bitin bsf varout,bitout btf@ss varin,bitin bcf varout,bitout else clrdc btf@sc varin,bitin setdc s@b varout skpndc bsf varout,bitout skpdc bcf varout,bitout endif endm bit_word macro varin,bitin,wordout clrw btf@sc varin,bitin movlw 1 mov@wf wordout clr@f wordout+1 endm word_wreg macro wordin mov@fw wordin endm word_byte macro wordin,byteout mov@fw wordin mov@wf byteout endm word_bit macro wordin,varout,bitout if((wordin&65408)==(varout&65408)) btf@sc wordin,0 bsf varout,bitout btf@ss wordin,0 bcf varout,bitout else rrf@w wordin s@b varout skpnc bsf varout,bitout skpc bcf varout,bitout endif endm word_word macro wordin,wordout mov@fw wordin+1 mov@wf wordout+1 mov@fw wordin mov@wf wordout endm byte_byte macro bytein,byteout mov@fw bytein mov@wf byteout endm byte_word macro bytein,wordout mov@fw bytein mov@wf wordout clr@f wordout+1 endm byte_bit macro bytein,varout,bitout if((bytein&65408)==(varout&65408)) btf@sc bytein,0 bsf varout,bitout btf@ss bytein,0 bcf varout,bitout else rrf@w bytein s@b varout skpnc bsf varout,bitout skpc bcf varout,bitout endif endm f@c macro dest if((p@b&1)!=0) bcf 3,5 endif if((p@b&2)!=0) bcf 3,6 endif p@b=0 if(dest<1) if(c@s>=4) if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif else if(dest>$) if(c@s>=4) if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif else if(c@s>=4) if((dest&6144)==0) clrf 10 else if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif endif endif endif endif call dest endm f@g macro dest if($==dest) clrwdt endif if((p@b&1)!=0) bcf 3,5 endif if((p@b&2)!=0) bcf 3,6 endif p@b=0 if(dest<1) if(c@s>=4) if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif else if(dest>$) if(c@s>=4) if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif else if(c@s>=4) if((dest&6144)==0) clrf 10 else if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif endif endif endif endif goto dest endm t@g macro cst,v@r,bitin,dest if(dest==$) clrwdt endif if(c@s>=4) if((dest&2048)==0) bcf 10,3 else bsf 10,3 endif endif if(c@s==8) if((dest&4096)==0) bcf 10,4 else bsf 10,4 endif endif if((v@r&65408)!=0) s@b v@r clrdc if(cst==0) btfss v@r,bitin else btfsc v@r,bitin endif setdc if((p@b&1)!=0) bcf 3,5 endif if((p@b&2)!=0) bcf 3,6 endif p@b=0 skpndc else if((p@b&1)!=0) bcf 3,5 endif if((p@b&2)!=0) bcf 3,6 endif p@b=0 if(cst==0) btfss v@r,bitin else btfsc v@r,bitin endif endif goto dest endm return_wreg macro ifdef return_var if(return_type==0) wreg_byte return_var endif if(return_type==1) wreg_word return_var endif if(return_type==2) wreg_bit return_var,return_bitnum endif endif endm return_byte macro bytein ifdef return_var if(return_type==0) byte_byte bytein,return_var endif if(return_type==1) byte_word bytein,return_var endif if(return_type==2) byte_bit bytein,return_var,return_bitnum endif endif endm return_word macro wordin ifdef return_var if(return_type==0) word_byte wordin,return_var endif if(return_type==1) word_word wordin,return_var endif if(return_type==2) word_bit wordin,return_var,return_bitnum endif endif endm return_bit macro varin,bitin ifdef return_var if(return_type==0) bit_byte varin,bitin,return_var endif if(return_type==1) bit_word varin,bitin,return_var endif if(return_type==2) bit_bit varin,bitin,return_var,return_bitnum endif endif endm GEN Equ 32 GENH Equ 33 GEN2 Equ 34 GEN2H Equ 35 GEN3 Equ 36 GEN3H Equ 37 GEN4 Equ 38 GEN4H Equ 39 PP0 Equ 40 PP0H Equ 41 PP1 Equ 42 PP1H Equ 43 PP2 Equ 44 PP2H Equ 45 PP3 Equ 46 PP3H Equ 47 PP4 Equ 48 PP4H Equ 49 PP5 Equ 50 PP5H Equ 51 PP6 Equ 52 PP6H Equ 53 PP7 Equ 54 PP7H Equ 55 GPR Equ 56 BPF Equ 57 BPFH Equ 58 org 0 clrwdt clrf 57 clrf 10 goto Start@ rsout@ pwm movwf 32 movfw 40 iorwf 41,w bz i@nt call n@gt clrf 43 clrf 44 comf 32,w bsf 4,7 andwf 0,f bcf 4,7 clrwdt goto $+1 movfw 42 addwf 43,f movf 0,w iorwf 32,w skpc xorwf 32,w movwf 0 incf 44,f skpnz incf 40,f skpnz incfsz 41,f goto $-14 movfw 32 bsf 4,7 iorwf 0,f goto i@nt n@gt comf 40,f comf 41,f i@pp0 incf 40,f skpnz incf 41,f return i@nt bcf 3,7 bcf 3,5 bcf 3,6 clrwdt return if($>=800h) ERROR "Library has exceeded page 0." endif Start@