;********************************************** ;* ©2006 Spatula Tzar ;* www.rctparadox.net/spatulatzar/ ;********************************************** ;Small C PIC16C84/PIC16F8X; ; Coder (2.0b 7/10/01) ; Version 1.01 ; Front End (PIC Ver 1.0 2/19/95) #INCLUDE "P16FXXX.inc" #INCLUDE "16f87x.h" ; **************code segment cseg******************* org _CSEG ; Begin Function main_ ; Configure Ports A<4-0> as input movlw 0x1f tris PORTA ; Configure Port B<7-0> as output movlw 0 tris PORTB movlw 0x20 movwf PORTB movlw 1 call _push_ ;;(# args passed) mov W, #1 call delay_sec_ ;-- add _stackptr, #1 incf _stackptr,f movlw 0 movwf idle_ movlw 0 movwf digits_ movlw 0 movwf data_read_ _2_ movlw 1 addlw 0 ;may not be needed! bz _3_ ;;(# args passed) mov W, #0 call RdPortA_ movwf data_ movfw data_ call _push_ movlw 16 call _pop_ ;--and _primary, _secondary andwf _secondary, W addlw 0 ;may not be needed! bz _4_ movlw 0 movwf idle_ movfw data_read_ call _push_ movlw 0 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _5_ movfw data_ call _push_ movlw 15 call _pop_ ;--and _primary, _secondary andwf _secondary, W movwf data_ movfw data_ call _push_ movlw 12 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _6_ movfw digits_ call _push_ movlw 4 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _8_ movfw digit1_ call _push_ movlw 2 call _pop_ call _geq_ _8_ call _bool_ addlw 0 ;may not be needed! bz _9_ movfw digit2_ call _push_ movlw 4 call _pop_ call _geq_ _9_ call _bool_ addlw 0 ;may not be needed! bz _10_ movfw digit3_ call _push_ movlw 8 call _pop_ call _geq_ _10_ call _bool_ addlw 0 ;may not be needed! bz _11_ movfw digit4_ call _push_ movlw 6 call _pop_ call _geq_ _11_ call _bool_ addlw 0 ;may not be needed! bz _7_ movlw 16 call _push_ ;;(# args passed) mov W, #1 call WrPortB_ ;-- add _stackptr, #1 incf _stackptr,f movlw 2 call _push_ ;;(# args passed) mov W, #1 call delay_sec_ ;-- add _stackptr, #1 incf _stackptr,f _7_ movlw 0 call _push_ ;;(# args passed) mov W, #1 call WrPortB_ ;-- add _stackptr, #1 incf _stackptr,f movlw 0 movwf digits_ movlw 0 movwf data_read_ b _12_ _6_ incf digits_,f movlw 1 movwf data_read_ movfw digits_ call _push_ movlw 1 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _13_ movfw data_ movwf digit1_ b _14_ _13_ movfw digits_ call _push_ movlw 2 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _15_ movfw data_ movwf digit2_ b _16_ _15_ movfw digits_ call _push_ movlw 3 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _17_ movfw data_ movwf digit3_ b _18_ _17_ movfw digits_ call _push_ movlw 4 call _pop_ call _geq_ addlw 0 ;may not be needed! bz _19_ movfw data_ movwf digit4_ _19_ _18_ _16_ _14_ _12_ _5_ b _20_ _4_ movlw 0 movwf data_read_ incf idle_,f movfw idle_ call _push_ movlw 30 ;FYI: WARNING: Signed chars are not implemented call _pop_ call _ggt_ addlw 0 ;may not be needed! bz _21_ movlw 0 movwf digits_ movlw 0 call _push_ ;;(# args passed) mov W, #1 call WrPortB_ ;-- add _stackptr, #1 incf _stackptr,f _21_ _20_ movlw 100 call _push_ ;;(# args passed) mov W, #1 call delay_ms_ ;-- add _stackptr, #1 incf _stackptr,f b _2_ _3_ _1_ return ; Begin Function RdPortA_ movfw _portA return ; Begin Function WrPortB_ movfw _stackptr ;-- call _indr_ movwf _fr4 movfw _fr0 ; movwf _portB return ; Begin Function delay_ms_ movfw _stackptr call _indr_ movwf _primary _dly1ms0_ clrf _temp _dly1ms_ decfsz _temp, f goto _dly1ms_ decfsz _primary, f goto _dly1ms_ return ; Begin Function delay_sec_ ;--sub _stackptr, #1 decf _stackptr,f movfw _stackptr call _push_ movlw 0 call _pop_ ;FYI: WARNING: only char ptrs are allowed call _putstk_ _26_ movfw _stackptr ;FYI: WARNING: only char ptrs are allowed call _indr_ call _push_ movlw 2 ;--add _primary, _stackptr addwf _stackptr,W call _indr_ ;FYI: WARNING: Signed chars are not implemented call _pop_ call _glt_ addlw 0 ;may not be needed! skpz goto _28_ b _29_ _27_ movfw _stackptr call _push_ ;FYI: WARNING: only char ptrs are allowed call _indr_ addlw 1 call _pop_ ;FYI: WARNING: only char ptrs are allowed call _putstk_ addlw 255 b _26_ _28_ movlw 250 call _push_ ;;(# args passed) mov W, #1 call delay_ms_ ;-- add _stackptr, #1 incf _stackptr,f movlw 250 call _push_ ;;(# args passed) mov W, #1 call delay_ms_ ;-- add _stackptr, #1 incf _stackptr,f movlw 250 call _push_ ;;(# args passed) mov W, #1 call delay_ms_ ;-- add _stackptr, #1 incf _stackptr,f movlw 250 call _push_ ;;(# args passed) mov W, #1 call delay_ms_ ;-- add _stackptr, #1 incf _stackptr,f b _27_ _29_ _25_ ;-- add _stackptr, #1 incf _stackptr,f return ;*******need compare standard library******** #include "glibpic.h" ; **************data segment dseg******************* org _DSEG data_ res 1 data_read_ res 1 digits_ res 1 digit1_ res 1 digit2_ res 1 digit3_ res 1 digit4_ res 1 idle_ res 1 ;0 error(s) in compilation ; literal pool:0 ; global pool:255 ; Macro pool:214 end