Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/PIC/K2Project/K2sauce
Apple][e/PD/PIC/K2Project/K2sauce
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras |
| Filename: | Apple][e/PD/PIC/K2Project/K2sauce |
| Read OK: | ✔ |
| File size: | 2121 bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/PIC/K2Project/K2backup
- Archimedes archive » Acorn User » AU 1997-10 A.adf » Extras » Apple][e/PD/PIC/K2Project/K2sauce
File contents
10REM K2 temperature sensor project PIC code for 16C71 20REM V0.95 (C)1997 SPROW 30: 40REM These are the RAM workspaces used 50bcdhi=12:REM Workspace for binary -> BCD converter 60bcdlo=13:REM Workspace for binary -> BCD converter 70displaybyte=bcdlo:REM Workspace for current value on display 80delay=bcdlo:REM Used as adc setup delay counter 90maths=bcdlo:REM Used by alarm changer maths routine 100acknowledge=14:REM Flag for having silenced the alarm 110savermask=15:REM Screen saver AND mask 120osram=16:REM Used as a RAM copy of portA 130alarm=17:REM Alarm point (6 bit signed binary NOT bcd) 140scaledADC=18:REM Workspace for halved ADC value 150timerlo=20:REM 256* the clock 160timerhi=21:REM 256*256* the clock value 170: 180W=0 190F=1 200status=3:REM Status register 210carry=0:REM Carry flag in status register 220zero=2:REM Zero flag in status register 230pager=5:REM Selects between page 0&1 for registers 240buzzer=4:REM The buzzer bit in port A 250setsw=2:REM Bit in portA for SET button 260go=2:REM Bit in adcon1 to start ad conversion 270REM This is how it is nc.nc.nc.buzzer.RnW.set.adc1.adc0 280: 290portA=5:REM Port A in memory map 300portB=6:REM Port A in memory map 310ddrA=5:REM Data direction register,in bank 1 320ddrB=6:REM Data direction register,in bank 1 330adcon0=8:REM ADC control,part one,in bank 0 340adcon1=8:REM ADC control,part two,in bank 1 350adresult=9:REM Where the PIC stores the ADC 360option=1:REM The option register 370intcon=11:REM Interrupt control register 380PC=2:REM Program counter 390: 400DIM code% 512 410FORX=4TO7STEP3 420P%=0:REM Processor jumps to &0000 on power up 430O%=code% 440[OPTX 450.reset 460GOTO init 470NOP 480NOP 490NOP 500: 510.init 520CLRF portB \Set some files to a known state 530CALL turnonscreen 540CLRF alarm 550CLRF acknowledge 560CLRF timerhi 570CLRF timerlo 580MOVLW #%xxx10000 \Buzzer off by default 590MOVWF osram 600MOVWF portA 610: 620\Read and write in page 1 630BSF status,pager 640MOVLW #%0x0x0111 650MOVWF option \Set timer0 to be clockcycle/256 660MOVLW #%xxxxxx10 670MOVWF adcon1 \Set RA0 to 4 to be AADDD respectively 680MOVLW #%xxx00111 690MOVWF ddrA \Set ddrA I and O pins 700MOVLW #%00000000 710MOVWF ddrB \Set ddrB as all outputs 720BCF status,pager 730: 740\Read and write in page 0 again 750MOVLW #%11x00001 760MOVWF adcon0 \Enable ADC module,ch0,using internal RC timing 770MOVLW #%11111111 780CALL writeout 790MOVLW #%01111111 800CALL writeout \Dummy writes to just put something in the latches 810: 820.poll 830\Get and show the current temperature 840CALL howhot 850: 860\Check for being below the alarm point 870CALL alarum 880: 890\Read 'mode' button now 900CALL analoguein1 910BTFSC adresult,7 920GOTO modepress 930: 940\Read 'set' button now 950BTFSC portA,setsw 960GOTO setpress 970: 980\No button pressed so increment pseudo screensaver timer 990INCFSZ timerlo,F 1000GOTO poll 1010INCFSZ timerhi,F 1020GOTO poll 1030MOVLW #%01111111 \Turn the screen saver on 1040MOVWF savermask 1050GOTO poll 1060: 1070.modepress 1080\Mode button is pressed,so set alarm point 1090CALL analoguein1 1100BTFSC adresult,7 \Debounce 'mode' button 1110GOTO modepress 1120CALL turnonscreen \Ensure screensaver is not active 1130.debounce_set 1140BTFSC portA,setsw 1150GOTO debounce_set \Debounce 'set' button 1160MOVF alarm,W 1170CALL bintoBCD 1180CALL digits \Remind user of current value 1190.sitandwait 1200BTFSC portA,setsw 1210GOTO alteralarm \Advance alarm point 1220CALL analoguein1 1230BTFSS adresult,7 \If 'mode' pressed,return to main loop 1240GOTO sitandwait 1250.debounce_mode 1260CALL analoguein1 1270BTFSC adresult,7 1280GOTO debounce_mode 1290GOTO poll 1300: 1310.alteralarm 1320BCF acknowledge,7 \Alarm point change means alarm point can be tested for again 1330MOVF alarm,W 1340BTFSS alarm,7 1350GOTO addon \If zero OR +ve then add on one 1360.takeoff 1370ANDLW #127 1380MOVWF maths \Copy the SIZE only of 'alarm' to 'maths' 1390MOVLW #128 \Setup default to be STILL negative 1400DECF maths,F 1410BTFSC status,zero 1420XORLW #128 1430IORWF maths,W 1440MOVWF alarm \Then alarm=maths OR w (this is signed binary) 1450GOTO debounce_set 1460.addon 1470MOVWF maths 1480INCF maths,F 1490MOVLW #40 \Has it reached +40 yet 1500XORWF maths,W 1510BTFSC status,zero 1520GOTO wraparound \Yes,so a wraparound to -39 occurs 1530MOVF maths,W 1540MOVWF alarm 1550GOTO debounce_set 1560.wraparound 1570MOVLW #128+39 \ie.this is -39 1580MOVWF alarm 1590GOTO debounce_set 1600: 1610.setpress 1620\Set is pressed which has limited effect on its own 1630CALL turnonscreen \Ensure screensaver is not active 1640MOVF osram,W 1650IORLW #%xxx10000 \Silences buzzer 1660MOVWF osram 1670MOVWF portA 1680BSF acknowledge,7 \Ensure the alarm stays off 1690GOTO poll 1700: 1710.alarum 1720BTFSC acknowledge,7 \Do nothing if the user silenced the buzzer 1730RETURN 1740MOVF scaledADC,W \Ignore if they're equal 1750XORWF alarm,W 1760BTFSC status,zero 1770RETURN 1780MOVF scaledADC,W \Test if they're both -ve 1790ANDWF alarm,W 1800MOVWF maths 1810BTFSC maths,7 \Both had bit 7 set 1820GOTO bothminus 1830MOVF scaledADC,W 1840IORWF alarm,W 1850MOVWF maths 1860BTFSS maths,7 \Both had bit 7 clear 1870GOTO bothplus 1880.nonequal 1890BTFSS scaledADC,7 1900RETURN 1910.turnonalarm 1920MOVF osram,W 1930ANDLW #%xxx01111 \Ground the buzzer to turn it on 1940MOVWF osram \Update ram copy 1950BCF portA,buzzer 1960RETURN 1970.bothplus 1980MOVF alarm,W 1990SUBWF scaledADC,F 2000BTFSC scaledADC,7 \Becomes -ve if temperature < alarm 2010GOTO turnonalarm 2020RETURN 2030.bothminus 2040MOVF alarm,W 2050ANDLW #%01111111 2060MOVWF maths \Ensures it is +ve 2070BCF scaledADC,7 2080MOVF scaledADC,W 2090SUBWF maths,F 2100BTFSC maths,7 \Becomes -ve if temperature < alarm 2110GOTO turnonalarm 2120RETURN 2130: 2140.howhot 2150CALL analoguein0 2160MOVLW #255 2170BTFSC adresult,7 2180MOVLW #128 2190XORWF adresult,W 2200MOVWF scaledADC \Temperature is now 255...0...127 2210BCF status,carry 2220RRF scaledADC,W \Halve the temperature,now in range 127...0...63 2230MOVWF scaledADC 2240BCF scaledADC,7 \Ensure bit7 is clear 2250BTFSC scaledADC,6 2260XORLW #%11xxxxxx \Make bit6 set into a bit7 set 2270MOVWF scaledADC \Temperature is now 63...0...63 & signed 2280CALL bintoBCD 2290CALL digits \Write bytes 2300RETURN 2310: 2320.analoguein0 2330\Get ADC value from channel 0 2340BCF adcon0,3 2350CALL analoguein \Now use generic sampler 2360RETURN 2370.analoguein1 2380\Get ADC value from channel 1 2390BSF adcon0,3 2400CALL analoguein \Now use generic sampler 2410RETURN 2420.analoguein 2430BSF adcon0,go \Tell the ADC to 'go' 2440MOVLW #32 2450MOVWF delay 2460.wastetime 2470DECFSZ delay,F \Allow a few clock cycles for ADC setup 2480GOTO wastetime 2490.doneyet 2500BTFSC adcon0,go \See if the 'go' bit is cleared 2510GOTO doneyet 2520RETURN 2530: 2540.bintoBCD 2550CLRF bcdhi \Must start at 0 2560MOVWF bcdlo 2570BTFSC bcdlo,7 \Was it negative? 2580BSF bcdhi,3 \Yes,so set what will become the top bit 2590BCF bcdlo,7 \Ensure it is clear to avoid overflow 2600.taketen 2610MOVLW #10 2620SUBWF bcdlo,W \Repeatedly subtract 10 2630BTFSS status,carry 2640GOTO completed 2650MOVWF bcdlo \Store result so far 2660INCF bcdhi,F 2670GOTO taketen 2680.completed 2690SWaPF bcdhi,W \This becomes the upper nybble 2700ANDLW #%11110000 2710IORWF bcdlo,F \Combine hi and lo 2720.rangecheck 2730BTFSC bcdlo,6 \Check that top digit < 4 2740RETLW #%11001010 \Out of range returns '-4A' which becomes '---' later 2750MOVF bcdlo,W \In range returns conversion 2760RETURN 2770: 2780.turnonscreen 2790MOVLW #0 \Button pressed so reenable screen 2800MOVWF savermask 2810MOVWF timerlo 2820MOVWF timerhi 2830RETURN 2840: 2850.writeout 2860IORWF savermask,W \Take into account the screensaver 2870MOVWF portB 2880MOVF osram,W \Read OS copy of port A 2890ANDLW #%xxx10xxx \BEL status maintained 2900MOVWF portA 2910IORLW #%xxx01xxx \Lock the latch 2920MOVWF portA 2930MOVWF osram \Update OS copy 2940RETURN 2950: 2960.digits 2970MOVWF displaybyte \Make a RAM copy 2980ANDLW #15 2990CALL lookuplo \Bottom nybble first 3000CALL writeout 3010SWaPF displaybyte,W 3020ANDLW #7 3030CALL lookuphi \Do high digit next 3040CALL writeout 3050RETURN 3060: 3070.lookuplo 3080ADDWF PC,F 3090\Bits %mabcdefg where m=multiplex 3100RETLW #%00000001 3110RETLW #%00011111 3120RETLW #%00100100 3130RETLW #%00001100 3140RETLW #%00011010 3150RETLW #%01001000 3160RETLW #%01000000 3170RETLW #%00011101 3180RETLW #%00000000 3190RETLW #%00011000 3200RETLW #%01111110 \Special case returns hyphen 3210: 3220.lookuphi 3230BTFSC displaybyte,7 3240ADDLW #4 3250ADDWF PC,F 3260\Bits %mabcdsfg where m=multiplex,s=sign 3270RETLW #%11111111 \Numbers 0,1,2,3 with leading zero supression 3280RETLW #%10011111 3290RETLW #%10100100 3300RETLW #%10001100 3310RETLW #%11111110 \Numbers -0,-1,-2,-3 with leading zero supression 3320RETLW #%10011011 3330RETLW #%10100000 3340RETLW #%10001000 3350RETLW #%11111010 \Special case returns hyphens 3360] 3370NEXT
6� K2 temperature sensor project PIC code for 16C71
� V0.95 (C)1997 SPROW
:
('� These are the RAM workspaces used
24bcdhi=12:� Workspace for binary -> BCD converter
<4bcdlo=13:� Workspace for binary -> BCD converter
F>displaybyte=bcdlo:� Workspace for current value on display
P1delay=bcdlo:� Used as adc setup delay counter
Z5maths=bcdlo:� Used by alarm changer maths routine
d7acknowledge=14:� Flag for having silenced the alarm
n(savermask=15:� Screen saver AND mask
x*osram=16:� Used as a RAM copy of portA
�8alarm=17:� Alarm point (6 bit signed binary NOT bcd)
�1scaledADC=18:� Workspace for halved ADC value
�timerlo=20:� 256* the clock
�)timerhi=21:� 256*256* the clock value
�:
�W=0
�F=1
�status=3:� Status register
�+carry=0:� Carry flag in status register
�)zero=2:� Zero flag in status register
�4pager=5:� Selects between page 0&1 for registers
�'buzzer=4:� The buzzer bit in port A
�)setsw=2:� Bit in portA for SET button
/go=2:� Bit in adcon1 to start ad conversion
9� This is how it is nc.nc.nc.buzzer.RnW.set.adc1.adc0
:
""portA=5:� Port A in memory map
,"portB=6:� Port A in memory map
6.ddrA=5:� Data direction register,in bank 1
@.ddrB=6:� Data direction register,in bank 1
J-adcon0=8:� ADC control,part one,in bank 0
T-adcon1=8:� ADC control,part two,in bank 1
^-adresult=9:� Where the PIC stores the ADC
h"option=1:� The option register
r*intcon=11:� Interrupt control register
|PC=2:� Program counter
�:
�� code% 512
��X=4�7�3
�/P%=0:� Processor jumps to &0000 on power up
�O%=code%
� [OPTX
�
.reset
�
� init
�NOP
�NOP
�NOP
�:
� .init
0CLRF portB \Set some files to a known state
� turnonscreen
CLRF alarm
&CLRF acknowledge
0CLRF timerhi
:CLRF timerlo
D,MOVLW #%xxx10000 \Buzzer off by default
NMOVWF osram
XMOVWF portA
b:
l\Read and write in page 1
vBSF status,pager
�MOVLW #%0x0x0111
�2MOVWF option \Set timer0 to be clockcycle/256
�MOVLW #%xxxxxx10
�8MOVWF adcon1 \Set RA0 to 4 to be AADDD respectively
�MOVLW #%xxx00111
�&MOVWF ddrA \Set ddrA I and O pins
�MOVLW #%00000000
�(MOVWF ddrB \Set ddrB as all outputs
�BCF status,pager
�:
�#\Read and write in page 0 again
�MOVLW #%11x00001
�AMOVWF adcon0 \Enable ADC module,ch0,using internal RC timing
MOVLW #%11111111
� writeout
MOVLW #%01111111
B� writeout \Dummy writes to just put something in the latches
*:
4 .poll
>)\Get and show the current temperature
H� howhot
R:
\*\Check for being below the alarm point
f� alarum
p:
z\Read 'mode' button now
�� analoguein1
�BTFSC adresult,7
�� modepress
�:
�\Read 'set' button now
�BTFSC portA,setsw
�� setpress
�:
�<\No button pressed so increment pseudo screensaver timer
�INCFSZ timerlo,F
�
� poll
�INCFSZ timerhi,F
�
� poll
/MOVLW #%01111111 \Turn the screen saver on
MOVWF savermask
� poll
$:
..modepress
8.\Mode button is pressed,so set alarm point
B� analoguein1
L-BTFSC adresult,7 \Debounce 'mode' button
V� modepress
`5� turnonscreen \Ensure screensaver is not active
j.debounce_set
tBTFSC portA,setsw
~*� debounce_set \Debounce 'set' button
�MOVF alarm,W
�� bintoBCD
�+� digits \Remind user of current value
�.sitandwait
�BTFSC portA,setsw
�&� alteralarm \Advance alarm point
�� analoguein1
�<BTFSS adresult,7 \If 'mode' pressed,return to main loop
�� sitandwait
�.debounce_mode
�� analoguein1
�BTFSC adresult,7
� debounce_mode
� poll
:
.alteralarm
(TBCF acknowledge,7 \Alarm point change means alarm point can be tested for again
2MOVF alarm,W
<BTFSS alarm,7
F+� addon \If zero � +ve then add on one
P.takeoff
Z�LW #127
d:MOVWF maths \Copy the SIZE only of 'alarm' to 'maths'
n3MOVLW #128 \Setup default to be STILL negative
xDECF maths,F
�BTFSC status,zero
�XORLW #128
�IORWF maths,W
�>MOVWF alarm \Then alarm=maths � w (this is signed binary)
�� debounce_set
�
.addon
�MOVWF maths
�INCF maths,F
�&MOVLW #40 \Has it reached +40 yet
�XORWF maths,W
�BTFSC status,zero
�4� wraparound \Yes,so a wraparound to -39 occurs
�MOVF maths,W
MOVWF alarm
� debounce_set
.wraparound
""MOVLW #128+39 \ie.this is -39
,MOVWF alarm
6� debounce_set
@:
J
.setpress
T7\Set is pressed which has limited effect on its own
^5� turnonscreen \Ensure screensaver is not active
hMOVF osram,W
r&IORLW #%xxx10000 \Silences buzzer
|MOVWF osram
�MOVWF portA
�2BSF acknowledge,7 \Ensure the alarm stays off
�
� poll
�:
�.alarum
�DBTFSC acknowledge,7 \Do nothing if the user silenced the buzzer
��
�.MOVF scaledADC,W \Ignore if they're equal
�XORWF alarm,W
�BTFSC status,zero
��
�/MOVF scaledADC,W \Test if they're both -ve
��WF alarm,W
MOVWF maths
&BTFSC maths,7 \Both had bit 7 set
� bothminus
&MOVF scaledADC,W
0IORWF alarm,W
:MOVWF maths
D(BTFSS maths,7 \Both had bit 7 clear
N� bothplus
X
.nonequal
bBTFSS scaledADC,7
l�
v.turnonalarm
�MOVF osram,W
�4�LW #%xxx01111 \Ground the buzzer to turn it on
�!MOVWF osram \Update ram copy
�BCF portA,buzzer
��
�
.bothplus
�MOVF alarm,W
�SUBWF scaledADC,F
�:BTFSC scaledADC,7 \Becomes -ve if temperature < alarm
�� turnonalarm
��
�.bothminus
�MOVF alarm,W
�LW #%01111111
#MOVWF maths \Ensures it is +ve
BCF scaledADC,7
MOVF scaledADC,W
*SUBWF maths,F
46BTFSC maths,7 \Becomes -ve if temperature < alarm
>� turnonalarm
H�
R:
\.howhot
f� analoguein0
pMOVLW #255
zBTFSC adresult,7
�MOVLW #128
�XORWF adresult,W
�6MOVWF scaledADC \Temperature is now 255...0...127
�BCF status,carry
�ERRF scaledADC,W \Halve the temperature,now in range 127...0...63
�MOVWF scaledADC
�*BCF scaledADC,7 \Ensure bit7 is clear
�BTFSC scaledADC,6
�4XORLW #%11xxxxxx \Make bit6 set into a bit7 set
�=MOVWF scaledADC \Temperature is now 63...0...63 & signed
�� bintoBCD
�� digits \Write bytes
��
:
.analoguein0
!\Get ADC value from channel 0
$BCF adcon0,3
.*� analoguein \Now use generic sampler
8�
B.analoguein1
L!\Get ADC value from channel 1
VBSF adcon0,3
`*� analoguein \Now use generic sampler
j�
t.analoguein
~(BSF adcon0,go \Tell the ADC to 'go'
�
MOVLW #32
�MOVWF delay
�.wastetime
�;DECFSZ delay,F \Allow a few clock cycles for ADC setup
�� wastetime
�.doneyet
�4BTFSC adcon0,go \See if the 'go' bit is cleared
�
� doneyet
��
�:
�
.bintoBCD
� CLRF bcdhi \Must start at 0
MOVWF bcdlo
$BTFSC bcdlo,7 \Was it negative?
9BSF bcdhi,3 \Yes,so set what will become the top bit
6BCF bcdlo,7 \Ensure it is clear to avoid overflow
(.taketen
2
MOVLW #10
<*SUBWF bcdlo,W \Repeatedly subtract 10
FBTFSS status,carry
P� completed
Z%MOVWF bcdlo \Store result so far
dINCF bcdhi,F
n
� taketen
x.completed
�1SWaPF bcdhi,W \This becomes the upper nybble
��LW #%11110000
�%IORWF bcdlo,F \Combine hi and lo
�.rangecheck
�,BTFSC bcdlo,6 \Check that top digit < 4
�KRETLW #%11001010 \Out of range returns '-4A' which becomes '---' later
�.MOVF bcdlo,W \In range returns conversion
��
�:
�.turnonscreen
�0MOVLW #0 \Button pressed so reenable screen
�MOVWF savermask
�MOVWF timerlo
MOVWF timerhi
�
:
"
.writeout
,9IORWF savermask,W \Take into account the screensaver
6MOVWF portB
@)MOVF osram,W \Read OS copy of port A
J*�LW #%xxx10xxx \BEL status maintained
TMOVWF portA
^%IORLW #%xxx01xxx \Lock the latch
hMOVWF portA
r MOVWF osram \Update OS copy
|�
�:
�.digits
�'MOVWF displaybyte \Make a RAM copy
��LW #15
�$� lookuplo \Bottom nybble first
�� writeout
�SWaPF displaybyte,W
�
�LW #7
�#� lookuphi \Do high digit next
�� writeout
��
�:
�
.lookuplo
ADDWF PC,F
'\Bits %mabcdefg where m=multiplex
RETLW #%00000001
&RETLW #%00011111
0RETLW #%00100100
:RETLW #%00001100
DRETLW #%00011010
NRETLW #%01001000
XRETLW #%01000000
bRETLW #%00011101
lRETLW #%00000000
vRETLW #%00011000
�2RETLW #%01111110 \Special case returns hyphen
�:
�
.lookuphi
�BTFSC displaybyte,7
�ADDLW #4
�ADDWF PC,F
�.\Bits %mabcdsfg where m=multiplex,s=sign
�CRETLW #%11111111 \Numbers 0,1,2,3 with leading zero supression
�RETLW #%10011111
�RETLW #%10100100
�RETLW #%10001100
�GRETLW #%11111110 \Numbers -0,-1,-2,-3 with leading zero supression
�RETLW #%10011011
RETLW #%10100000
RETLW #%10001000
3RETLW #%11111010 \Special case returns hyphens
]
*�
� 00000000 0d 00 0a 36 f4 20 4b 32 20 74 65 6d 70 65 72 61 |...6. K2 tempera|
00000010 74 75 72 65 20 73 65 6e 73 6f 72 20 70 72 6f 6a |ture sensor proj|
00000020 65 63 74 20 50 49 43 20 63 6f 64 65 20 66 6f 72 |ect PIC code for|
00000030 20 31 36 43 37 31 0d 00 14 19 f4 20 56 30 2e 39 | 16C71..... V0.9|
00000040 35 20 28 43 29 31 39 39 37 20 53 50 52 4f 57 0d |5 (C)1997 SPROW.|
00000050 00 1e 05 3a 0d 00 28 27 f4 20 54 68 65 73 65 20 |...:..('. These |
00000060 61 72 65 20 74 68 65 20 52 41 4d 20 77 6f 72 6b |are the RAM work|
00000070 73 70 61 63 65 73 20 75 73 65 64 0d 00 32 34 62 |spaces used..24b|
00000080 63 64 68 69 3d 31 32 3a f4 20 57 6f 72 6b 73 70 |cdhi=12:. Worksp|
00000090 61 63 65 20 66 6f 72 20 62 69 6e 61 72 79 20 2d |ace for binary -|
000000a0 3e 20 42 43 44 20 63 6f 6e 76 65 72 74 65 72 0d |> BCD converter.|
000000b0 00 3c 34 62 63 64 6c 6f 3d 31 33 3a f4 20 57 6f |.<4bcdlo=13:. Wo|
000000c0 72 6b 73 70 61 63 65 20 66 6f 72 20 62 69 6e 61 |rkspace for bina|
000000d0 72 79 20 2d 3e 20 42 43 44 20 63 6f 6e 76 65 72 |ry -> BCD conver|
000000e0 74 65 72 0d 00 46 3e 64 69 73 70 6c 61 79 62 79 |ter..F>displayby|
000000f0 74 65 3d 62 63 64 6c 6f 3a f4 20 57 6f 72 6b 73 |te=bcdlo:. Works|
00000100 70 61 63 65 20 66 6f 72 20 63 75 72 72 65 6e 74 |pace for current|
00000110 20 76 61 6c 75 65 20 6f 6e 20 64 69 73 70 6c 61 | value on displa|
00000120 79 0d 00 50 31 64 65 6c 61 79 3d 62 63 64 6c 6f |y..P1delay=bcdlo|
00000130 3a f4 20 55 73 65 64 20 61 73 20 61 64 63 20 73 |:. Used as adc s|
00000140 65 74 75 70 20 64 65 6c 61 79 20 63 6f 75 6e 74 |etup delay count|
00000150 65 72 0d 00 5a 35 6d 61 74 68 73 3d 62 63 64 6c |er..Z5maths=bcdl|
00000160 6f 3a f4 20 55 73 65 64 20 62 79 20 61 6c 61 72 |o:. Used by alar|
00000170 6d 20 63 68 61 6e 67 65 72 20 6d 61 74 68 73 20 |m changer maths |
00000180 72 6f 75 74 69 6e 65 0d 00 64 37 61 63 6b 6e 6f |routine..d7ackno|
00000190 77 6c 65 64 67 65 3d 31 34 3a f4 20 46 6c 61 67 |wledge=14:. Flag|
000001a0 20 66 6f 72 20 68 61 76 69 6e 67 20 73 69 6c 65 | for having sile|
000001b0 6e 63 65 64 20 74 68 65 20 61 6c 61 72 6d 0d 00 |nced the alarm..|
000001c0 6e 28 73 61 76 65 72 6d 61 73 6b 3d 31 35 3a f4 |n(savermask=15:.|
000001d0 20 53 63 72 65 65 6e 20 73 61 76 65 72 20 41 4e | Screen saver AN|
000001e0 44 20 6d 61 73 6b 0d 00 78 2a 6f 73 72 61 6d 3d |D mask..x*osram=|
000001f0 31 36 3a f4 20 55 73 65 64 20 61 73 20 61 20 52 |16:. Used as a R|
00000200 41 4d 20 63 6f 70 79 20 6f 66 20 70 6f 72 74 41 |AM copy of portA|
00000210 0d 00 82 38 61 6c 61 72 6d 3d 31 37 3a f4 20 41 |...8alarm=17:. A|
00000220 6c 61 72 6d 20 70 6f 69 6e 74 20 28 36 20 62 69 |larm point (6 bi|
00000230 74 20 73 69 67 6e 65 64 20 62 69 6e 61 72 79 20 |t signed binary |
00000240 4e 4f 54 20 62 63 64 29 0d 00 8c 31 73 63 61 6c |NOT bcd)...1scal|
00000250 65 64 41 44 43 3d 31 38 3a f4 20 57 6f 72 6b 73 |edADC=18:. Works|
00000260 70 61 63 65 20 66 6f 72 20 68 61 6c 76 65 64 20 |pace for halved |
00000270 41 44 43 20 76 61 6c 75 65 0d 00 96 1f 74 69 6d |ADC value....tim|
00000280 65 72 6c 6f 3d 32 30 3a f4 20 32 35 36 2a 20 74 |erlo=20:. 256* t|
00000290 68 65 20 63 6c 6f 63 6b 0d 00 a0 29 74 69 6d 65 |he clock...)time|
000002a0 72 68 69 3d 32 31 3a f4 20 32 35 36 2a 32 35 36 |rhi=21:. 256*256|
000002b0 2a 20 74 68 65 20 63 6c 6f 63 6b 20 76 61 6c 75 |* the clock valu|
000002c0 65 0d 00 aa 05 3a 0d 00 b4 07 57 3d 30 0d 00 be |e....:....W=0...|
000002d0 07 46 3d 31 0d 00 c8 1e 73 74 61 74 75 73 3d 33 |.F=1....status=3|
000002e0 3a f4 20 53 74 61 74 75 73 20 72 65 67 69 73 74 |:. Status regist|
000002f0 65 72 0d 00 d2 2b 63 61 72 72 79 3d 30 3a f4 20 |er...+carry=0:. |
00000300 43 61 72 72 79 20 66 6c 61 67 20 69 6e 20 73 74 |Carry flag in st|
00000310 61 74 75 73 20 72 65 67 69 73 74 65 72 0d 00 dc |atus register...|
00000320 29 7a 65 72 6f 3d 32 3a f4 20 5a 65 72 6f 20 66 |)zero=2:. Zero f|
00000330 6c 61 67 20 69 6e 20 73 74 61 74 75 73 20 72 65 |lag in status re|
00000340 67 69 73 74 65 72 0d 00 e6 34 70 61 67 65 72 3d |gister...4pager=|
00000350 35 3a f4 20 53 65 6c 65 63 74 73 20 62 65 74 77 |5:. Selects betw|
00000360 65 65 6e 20 70 61 67 65 20 30 26 31 20 66 6f 72 |een page 0&1 for|
00000370 20 72 65 67 69 73 74 65 72 73 0d 00 f0 27 62 75 | registers...'bu|
00000380 7a 7a 65 72 3d 34 3a f4 20 54 68 65 20 62 75 7a |zzer=4:. The buz|
00000390 7a 65 72 20 62 69 74 20 69 6e 20 70 6f 72 74 20 |zer bit in port |
000003a0 41 0d 00 fa 29 73 65 74 73 77 3d 32 3a f4 20 42 |A...)setsw=2:. B|
000003b0 69 74 20 69 6e 20 70 6f 72 74 41 20 66 6f 72 20 |it in portA for |
000003c0 53 45 54 20 62 75 74 74 6f 6e 0d 01 04 2f 67 6f |SET button.../go|
000003d0 3d 32 3a f4 20 42 69 74 20 69 6e 20 61 64 63 6f |=2:. Bit in adco|
000003e0 6e 31 20 74 6f 20 73 74 61 72 74 20 61 64 20 63 |n1 to start ad c|
000003f0 6f 6e 76 65 72 73 69 6f 6e 0d 01 0e 39 f4 20 54 |onversion...9. T|
00000400 68 69 73 20 69 73 20 68 6f 77 20 69 74 20 69 73 |his is how it is|
00000410 20 6e 63 2e 6e 63 2e 6e 63 2e 62 75 7a 7a 65 72 | nc.nc.nc.buzzer|
00000420 2e 52 6e 57 2e 73 65 74 2e 61 64 63 31 2e 61 64 |.RnW.set.adc1.ad|
00000430 63 30 0d 01 18 05 3a 0d 01 22 22 70 6f 72 74 41 |c0....:..""portA|
00000440 3d 35 3a f4 20 50 6f 72 74 20 41 20 69 6e 20 6d |=5:. Port A in m|
00000450 65 6d 6f 72 79 20 6d 61 70 0d 01 2c 22 70 6f 72 |emory map..,"por|
00000460 74 42 3d 36 3a f4 20 50 6f 72 74 20 41 20 69 6e |tB=6:. Port A in|
00000470 20 6d 65 6d 6f 72 79 20 6d 61 70 0d 01 36 2e 64 | memory map..6.d|
00000480 64 72 41 3d 35 3a f4 20 44 61 74 61 20 64 69 72 |drA=5:. Data dir|
00000490 65 63 74 69 6f 6e 20 72 65 67 69 73 74 65 72 2c |ection register,|
000004a0 69 6e 20 62 61 6e 6b 20 31 0d 01 40 2e 64 64 72 |in bank 1..@.ddr|
000004b0 42 3d 36 3a f4 20 44 61 74 61 20 64 69 72 65 63 |B=6:. Data direc|
000004c0 74 69 6f 6e 20 72 65 67 69 73 74 65 72 2c 69 6e |tion register,in|
000004d0 20 62 61 6e 6b 20 31 0d 01 4a 2d 61 64 63 6f 6e | bank 1..J-adcon|
000004e0 30 3d 38 3a f4 20 41 44 43 20 63 6f 6e 74 72 6f |0=8:. ADC contro|
000004f0 6c 2c 70 61 72 74 20 6f 6e 65 2c 69 6e 20 62 61 |l,part one,in ba|
00000500 6e 6b 20 30 0d 01 54 2d 61 64 63 6f 6e 31 3d 38 |nk 0..T-adcon1=8|
00000510 3a f4 20 41 44 43 20 63 6f 6e 74 72 6f 6c 2c 70 |:. ADC control,p|
00000520 61 72 74 20 74 77 6f 2c 69 6e 20 62 61 6e 6b 20 |art two,in bank |
00000530 31 0d 01 5e 2d 61 64 72 65 73 75 6c 74 3d 39 3a |1..^-adresult=9:|
00000540 f4 20 57 68 65 72 65 20 74 68 65 20 50 49 43 20 |. Where the PIC |
00000550 73 74 6f 72 65 73 20 74 68 65 20 41 44 43 0d 01 |stores the ADC..|
00000560 68 22 6f 70 74 69 6f 6e 3d 31 3a f4 20 54 68 65 |h"option=1:. The|
00000570 20 6f 70 74 69 6f 6e 20 72 65 67 69 73 74 65 72 | option register|
00000580 0d 01 72 2a 69 6e 74 63 6f 6e 3d 31 31 3a f4 20 |..r*intcon=11:. |
00000590 49 6e 74 65 72 72 75 70 74 20 63 6f 6e 74 72 6f |Interrupt contro|
000005a0 6c 20 72 65 67 69 73 74 65 72 0d 01 7c 1a 50 43 |l register..|.PC|
000005b0 3d 32 3a f4 20 50 72 6f 67 72 61 6d 20 63 6f 75 |=2:. Program cou|
000005c0 6e 74 65 72 0d 01 86 05 3a 0d 01 90 0f de 20 63 |nter....:..... c|
000005d0 6f 64 65 25 20 35 31 32 0d 01 9a 0c e3 58 3d 34 |ode% 512.....X=4|
000005e0 b8 37 88 33 0d 01 a4 2f 50 25 3d 30 3a f4 20 50 |.7.3.../P%=0:. P|
000005f0 72 6f 63 65 73 73 6f 72 20 6a 75 6d 70 73 20 74 |rocessor jumps t|
00000600 6f 20 26 30 30 30 30 20 6f 6e 20 70 6f 77 65 72 |o &0000 on power|
00000610 20 75 70 0d 01 ae 0c 4f 25 3d 63 6f 64 65 25 0d | up....O%=code%.|
00000620 01 b8 09 5b 4f 50 54 58 0d 01 c2 0a 2e 72 65 73 |...[OPTX.....res|
00000630 65 74 0d 01 cc 0a e5 20 69 6e 69 74 0d 01 d6 07 |et..... init....|
00000640 4e 4f 50 0d 01 e0 07 4e 4f 50 0d 01 ea 07 4e 4f |NOP....NOP....NO|
00000650 50 0d 01 f4 05 3a 0d 01 fe 09 2e 69 6e 69 74 0d |P....:.....init.|
00000660 02 08 30 43 4c 52 46 20 70 6f 72 74 42 20 20 5c |..0CLRF portB \|
00000670 53 65 74 20 73 6f 6d 65 20 66 69 6c 65 73 20 74 |Set some files t|
00000680 6f 20 61 20 6b 6e 6f 77 6e 20 73 74 61 74 65 0d |o a known state.|
00000690 02 12 12 d6 20 74 75 72 6e 6f 6e 73 63 72 65 65 |.... turnonscree|
000006a0 6e 0d 02 1c 0e 43 4c 52 46 20 61 6c 61 72 6d 0d |n....CLRF alarm.|
000006b0 02 26 14 43 4c 52 46 20 61 63 6b 6e 6f 77 6c 65 |.&.CLRF acknowle|
000006c0 64 67 65 0d 02 30 10 43 4c 52 46 20 74 69 6d 65 |dge..0.CLRF time|
000006d0 72 68 69 0d 02 3a 10 43 4c 52 46 20 74 69 6d 65 |rhi..:.CLRF time|
000006e0 72 6c 6f 0d 02 44 2c 4d 4f 56 4c 57 20 23 25 78 |rlo..D,MOVLW #%x|
000006f0 78 78 31 30 30 30 30 20 20 5c 42 75 7a 7a 65 72 |xx10000 \Buzzer|
00000700 20 6f 66 66 20 62 79 20 64 65 66 61 75 6c 74 0d | off by default.|
00000710 02 4e 0f 4d 4f 56 57 46 20 6f 73 72 61 6d 0d 02 |.N.MOVWF osram..|
00000720 58 0f 4d 4f 56 57 46 20 70 6f 72 74 41 0d 02 62 |X.MOVWF portA..b|
00000730 05 3a 0d 02 6c 1d 5c 52 65 61 64 20 61 6e 64 20 |.:..l.\Read and |
00000740 77 72 69 74 65 20 69 6e 20 70 61 67 65 20 31 0d |write in page 1.|
00000750 02 76 14 42 53 46 20 73 74 61 74 75 73 2c 70 61 |.v.BSF status,pa|
00000760 67 65 72 0d 02 80 14 4d 4f 56 4c 57 20 23 25 30 |ger....MOVLW #%0|
00000770 78 30 78 30 31 31 31 0d 02 8a 32 4d 4f 56 57 46 |x0x0111...2MOVWF|
00000780 20 6f 70 74 69 6f 6e 20 20 5c 53 65 74 20 74 69 | option \Set ti|
00000790 6d 65 72 30 20 74 6f 20 62 65 20 63 6c 6f 63 6b |mer0 to be clock|
000007a0 63 79 63 6c 65 2f 32 35 36 0d 02 94 14 4d 4f 56 |cycle/256....MOV|
000007b0 4c 57 20 23 25 78 78 78 78 78 78 31 30 0d 02 9e |LW #%xxxxxx10...|
000007c0 38 4d 4f 56 57 46 20 61 64 63 6f 6e 31 20 20 5c |8MOVWF adcon1 \|
000007d0 53 65 74 20 52 41 30 20 74 6f 20 34 20 74 6f 20 |Set RA0 to 4 to |
000007e0 62 65 20 41 41 44 44 44 20 72 65 73 70 65 63 74 |be AADDD respect|
000007f0 69 76 65 6c 79 0d 02 a8 14 4d 4f 56 4c 57 20 23 |ively....MOVLW #|
00000800 25 78 78 78 30 30 31 31 31 0d 02 b2 26 4d 4f 56 |%xxx00111...&MOV|
00000810 57 46 20 64 64 72 41 20 20 5c 53 65 74 20 64 64 |WF ddrA \Set dd|
00000820 72 41 20 49 20 61 6e 64 20 4f 20 70 69 6e 73 0d |rA I and O pins.|
00000830 02 bc 14 4d 4f 56 4c 57 20 23 25 30 30 30 30 30 |...MOVLW #%00000|
00000840 30 30 30 0d 02 c6 28 4d 4f 56 57 46 20 64 64 72 |000...(MOVWF ddr|
00000850 42 20 20 5c 53 65 74 20 64 64 72 42 20 61 73 20 |B \Set ddrB as |
00000860 61 6c 6c 20 6f 75 74 70 75 74 73 0d 02 d0 14 42 |all outputs....B|
00000870 43 46 20 73 74 61 74 75 73 2c 70 61 67 65 72 0d |CF status,pager.|
00000880 02 da 05 3a 0d 02 e4 23 5c 52 65 61 64 20 61 6e |...:...#\Read an|
00000890 64 20 77 72 69 74 65 20 69 6e 20 70 61 67 65 20 |d write in page |
000008a0 30 20 61 67 61 69 6e 0d 02 ee 14 4d 4f 56 4c 57 |0 again....MOVLW|
000008b0 20 23 25 31 31 78 30 30 30 30 31 0d 02 f8 41 4d | #%11x00001...AM|
000008c0 4f 56 57 46 20 61 64 63 6f 6e 30 20 20 5c 45 6e |OVWF adcon0 \En|
000008d0 61 62 6c 65 20 41 44 43 20 6d 6f 64 75 6c 65 2c |able ADC module,|
000008e0 63 68 30 2c 75 73 69 6e 67 20 69 6e 74 65 72 6e |ch0,using intern|
000008f0 61 6c 20 52 43 20 74 69 6d 69 6e 67 0d 03 02 14 |al RC timing....|
00000900 4d 4f 56 4c 57 20 23 25 31 31 31 31 31 31 31 31 |MOVLW #%11111111|
00000910 0d 03 0c 0e d6 20 77 72 69 74 65 6f 75 74 0d 03 |..... writeout..|
00000920 16 14 4d 4f 56 4c 57 20 23 25 30 31 31 31 31 31 |..MOVLW #%011111|
00000930 31 31 0d 03 20 42 d6 20 77 72 69 74 65 6f 75 74 |11.. B. writeout|
00000940 20 20 5c 44 75 6d 6d 79 20 77 72 69 74 65 73 20 | \Dummy writes |
00000950 74 6f 20 6a 75 73 74 20 70 75 74 20 73 6f 6d 65 |to just put some|
00000960 74 68 69 6e 67 20 69 6e 20 74 68 65 20 6c 61 74 |thing in the lat|
00000970 63 68 65 73 0d 03 2a 05 3a 0d 03 34 09 2e 70 6f |ches..*.:..4..po|
00000980 6c 6c 0d 03 3e 29 5c 47 65 74 20 61 6e 64 20 73 |ll..>)\Get and s|
00000990 68 6f 77 20 74 68 65 20 63 75 72 72 65 6e 74 20 |how the current |
000009a0 74 65 6d 70 65 72 61 74 75 72 65 0d 03 48 0c d6 |temperature..H..|
000009b0 20 68 6f 77 68 6f 74 0d 03 52 05 3a 0d 03 5c 2a | howhot..R.:..\*|
000009c0 5c 43 68 65 63 6b 20 66 6f 72 20 62 65 69 6e 67 |\Check for being|
000009d0 20 62 65 6c 6f 77 20 74 68 65 20 61 6c 61 72 6d | below the alarm|
000009e0 20 70 6f 69 6e 74 0d 03 66 0c d6 20 61 6c 61 72 | point..f.. alar|
000009f0 75 6d 0d 03 70 05 3a 0d 03 7a 1b 5c 52 65 61 64 |um..p.:..z.\Read|
00000a00 20 27 6d 6f 64 65 27 20 62 75 74 74 6f 6e 20 6e | 'mode' button n|
00000a10 6f 77 0d 03 84 11 d6 20 61 6e 61 6c 6f 67 75 65 |ow..... analogue|
00000a20 69 6e 31 0d 03 8e 14 42 54 46 53 43 20 61 64 72 |in1....BTFSC adr|
00000a30 65 73 75 6c 74 2c 37 0d 03 98 0f e5 20 6d 6f 64 |esult,7..... mod|
00000a40 65 70 72 65 73 73 0d 03 a2 05 3a 0d 03 ac 1a 5c |epress....:....\|
00000a50 52 65 61 64 20 27 73 65 74 27 20 62 75 74 74 6f |Read 'set' butto|
00000a60 6e 20 6e 6f 77 0d 03 b6 15 42 54 46 53 43 20 70 |n now....BTFSC p|
00000a70 6f 72 74 41 2c 73 65 74 73 77 0d 03 c0 0e e5 20 |ortA,setsw..... |
00000a80 73 65 74 70 72 65 73 73 0d 03 ca 05 3a 0d 03 d4 |setpress....:...|
00000a90 3c 5c 4e 6f 20 62 75 74 74 6f 6e 20 70 72 65 73 |<\No button pres|
00000aa0 73 65 64 20 73 6f 20 69 6e 63 72 65 6d 65 6e 74 |sed so increment|
00000ab0 20 70 73 65 75 64 6f 20 73 63 72 65 65 6e 73 61 | pseudo screensa|
00000ac0 76 65 72 20 74 69 6d 65 72 0d 03 de 14 49 4e 43 |ver timer....INC|
00000ad0 46 53 5a 20 74 69 6d 65 72 6c 6f 2c 46 0d 03 e8 |FSZ timerlo,F...|
00000ae0 0a e5 20 70 6f 6c 6c 0d 03 f2 14 49 4e 43 46 53 |.. poll....INCFS|
00000af0 5a 20 74 69 6d 65 72 68 69 2c 46 0d 03 fc 0a e5 |Z timerhi,F.....|
00000b00 20 70 6f 6c 6c 0d 04 06 2f 4d 4f 56 4c 57 20 23 | poll.../MOVLW #|
00000b10 25 30 31 31 31 31 31 31 31 20 20 5c 54 75 72 6e |%01111111 \Turn|
00000b20 20 74 68 65 20 73 63 72 65 65 6e 20 73 61 76 65 | the screen save|
00000b30 72 20 6f 6e 0d 04 10 13 4d 4f 56 57 46 20 73 61 |r on....MOVWF sa|
00000b40 76 65 72 6d 61 73 6b 0d 04 1a 0a e5 20 70 6f 6c |vermask..... pol|
00000b50 6c 0d 04 24 05 3a 0d 04 2e 0e 2e 6d 6f 64 65 70 |l..$.:.....modep|
00000b60 72 65 73 73 0d 04 38 2e 5c 4d 6f 64 65 20 62 75 |ress..8.\Mode bu|
00000b70 74 74 6f 6e 20 69 73 20 70 72 65 73 73 65 64 2c |tton is pressed,|
00000b80 73 6f 20 73 65 74 20 61 6c 61 72 6d 20 70 6f 69 |so set alarm poi|
00000b90 6e 74 0d 04 42 11 d6 20 61 6e 61 6c 6f 67 75 65 |nt..B.. analogue|
00000ba0 69 6e 31 0d 04 4c 2d 42 54 46 53 43 20 61 64 72 |in1..L-BTFSC adr|
00000bb0 65 73 75 6c 74 2c 37 20 20 5c 44 65 62 6f 75 6e |esult,7 \Deboun|
00000bc0 63 65 20 27 6d 6f 64 65 27 20 62 75 74 74 6f 6e |ce 'mode' button|
00000bd0 0d 04 56 0f e5 20 6d 6f 64 65 70 72 65 73 73 0d |..V.. modepress.|
00000be0 04 60 35 d6 20 74 75 72 6e 6f 6e 73 63 72 65 65 |.`5. turnonscree|
00000bf0 6e 20 20 5c 45 6e 73 75 72 65 20 73 63 72 65 65 |n \Ensure scree|
00000c00 6e 73 61 76 65 72 20 69 73 20 6e 6f 74 20 61 63 |nsaver is not ac|
00000c10 74 69 76 65 0d 04 6a 11 2e 64 65 62 6f 75 6e 63 |tive..j..debounc|
00000c20 65 5f 73 65 74 0d 04 74 15 42 54 46 53 43 20 70 |e_set..t.BTFSC p|
00000c30 6f 72 74 41 2c 73 65 74 73 77 0d 04 7e 2a e5 20 |ortA,setsw..~*. |
00000c40 64 65 62 6f 75 6e 63 65 5f 73 65 74 20 20 5c 44 |debounce_set \D|
00000c50 65 62 6f 75 6e 63 65 20 27 73 65 74 27 20 62 75 |ebounce 'set' bu|
00000c60 74 74 6f 6e 0d 04 88 10 4d 4f 56 46 20 61 6c 61 |tton....MOVF ala|
00000c70 72 6d 2c 57 0d 04 92 0e d6 20 62 69 6e 74 6f 42 |rm,W..... bintoB|
00000c80 43 44 0d 04 9c 2b d6 20 64 69 67 69 74 73 20 20 |CD...+. digits |
00000c90 5c 52 65 6d 69 6e 64 20 75 73 65 72 20 6f 66 20 |\Remind user of |
00000ca0 63 75 72 72 65 6e 74 20 76 61 6c 75 65 0d 04 a6 |current value...|
00000cb0 0f 2e 73 69 74 61 6e 64 77 61 69 74 0d 04 b0 15 |..sitandwait....|
00000cc0 42 54 46 53 43 20 70 6f 72 74 41 2c 73 65 74 73 |BTFSC portA,sets|
00000cd0 77 0d 04 ba 26 e5 20 61 6c 74 65 72 61 6c 61 72 |w...&. alteralar|
00000ce0 6d 20 20 5c 41 64 76 61 6e 63 65 20 61 6c 61 72 |m \Advance alar|
00000cf0 6d 20 70 6f 69 6e 74 0d 04 c4 11 d6 20 61 6e 61 |m point..... ana|
00000d00 6c 6f 67 75 65 69 6e 31 0d 04 ce 3c 42 54 46 53 |loguein1...<BTFS|
00000d10 53 20 61 64 72 65 73 75 6c 74 2c 37 20 20 5c 49 |S adresult,7 \I|
00000d20 66 20 27 6d 6f 64 65 27 20 70 72 65 73 73 65 64 |f 'mode' pressed|
00000d30 2c 72 65 74 75 72 6e 20 74 6f 20 6d 61 69 6e 20 |,return to main |
00000d40 6c 6f 6f 70 0d 04 d8 10 e5 20 73 69 74 61 6e 64 |loop..... sitand|
00000d50 77 61 69 74 0d 04 e2 12 2e 64 65 62 6f 75 6e 63 |wait.....debounc|
00000d60 65 5f 6d 6f 64 65 0d 04 ec 11 d6 20 61 6e 61 6c |e_mode..... anal|
00000d70 6f 67 75 65 69 6e 31 0d 04 f6 14 42 54 46 53 43 |oguein1....BTFSC|
00000d80 20 61 64 72 65 73 75 6c 74 2c 37 0d 05 00 13 e5 | adresult,7.....|
00000d90 20 64 65 62 6f 75 6e 63 65 5f 6d 6f 64 65 0d 05 | debounce_mode..|
00000da0 0a 0a e5 20 70 6f 6c 6c 0d 05 14 05 3a 0d 05 1e |... poll....:...|
00000db0 0f 2e 61 6c 74 65 72 61 6c 61 72 6d 0d 05 28 54 |..alteralarm..(T|
00000dc0 42 43 46 20 61 63 6b 6e 6f 77 6c 65 64 67 65 2c |BCF acknowledge,|
00000dd0 37 20 20 5c 41 6c 61 72 6d 20 70 6f 69 6e 74 20 |7 \Alarm point |
00000de0 63 68 61 6e 67 65 20 6d 65 61 6e 73 20 61 6c 61 |change means ala|
00000df0 72 6d 20 70 6f 69 6e 74 20 63 61 6e 20 62 65 20 |rm point can be |
00000e00 74 65 73 74 65 64 20 66 6f 72 20 61 67 61 69 6e |tested for again|
00000e10 0d 05 32 10 4d 4f 56 46 20 61 6c 61 72 6d 2c 57 |..2.MOVF alarm,W|
00000e20 0d 05 3c 11 42 54 46 53 53 20 61 6c 61 72 6d 2c |..<.BTFSS alarm,|
00000e30 37 0d 05 46 2b e5 20 61 64 64 6f 6e 20 20 5c 49 |7..F+. addon \I|
00000e40 66 20 7a 65 72 6f 20 84 20 2b 76 65 20 74 68 65 |f zero . +ve the|
00000e50 6e 20 61 64 64 20 6f 6e 20 6f 6e 65 0d 05 50 0c |n add on one..P.|
00000e60 2e 74 61 6b 65 6f 66 66 0d 05 5a 0c 80 4c 57 20 |.takeoff..Z..LW |
00000e70 23 31 32 37 0d 05 64 3a 4d 4f 56 57 46 20 6d 61 |#127..d:MOVWF ma|
00000e80 74 68 73 20 20 5c 43 6f 70 79 20 74 68 65 20 53 |ths \Copy the S|
00000e90 49 5a 45 20 6f 6e 6c 79 20 6f 66 20 27 61 6c 61 |IZE only of 'ala|
00000ea0 72 6d 27 20 74 6f 20 27 6d 61 74 68 73 27 0d 05 |rm' to 'maths'..|
00000eb0 6e 33 4d 4f 56 4c 57 20 23 31 32 38 20 20 5c 53 |n3MOVLW #128 \S|
00000ec0 65 74 75 70 20 64 65 66 61 75 6c 74 20 74 6f 20 |etup default to |
00000ed0 62 65 20 53 54 49 4c 4c 20 6e 65 67 61 74 69 76 |be STILL negativ|
00000ee0 65 0d 05 78 10 44 45 43 46 20 6d 61 74 68 73 2c |e..x.DECF maths,|
00000ef0 46 0d 05 82 15 42 54 46 53 43 20 73 74 61 74 75 |F....BTFSC statu|
00000f00 73 2c 7a 65 72 6f 0d 05 8c 0e 58 4f 52 4c 57 20 |s,zero....XORLW |
00000f10 23 31 32 38 0d 05 96 11 49 4f 52 57 46 20 6d 61 |#128....IORWF ma|
00000f20 74 68 73 2c 57 0d 05 a0 3e 4d 4f 56 57 46 20 61 |ths,W...>MOVWF a|
00000f30 6c 61 72 6d 20 20 5c 54 68 65 6e 20 61 6c 61 72 |larm \Then alar|
00000f40 6d 3d 6d 61 74 68 73 20 84 20 77 20 28 74 68 69 |m=maths . w (thi|
00000f50 73 20 69 73 20 73 69 67 6e 65 64 20 62 69 6e 61 |s is signed bina|
00000f60 72 79 29 0d 05 aa 12 e5 20 64 65 62 6f 75 6e 63 |ry)..... debounc|
00000f70 65 5f 73 65 74 0d 05 b4 0a 2e 61 64 64 6f 6e 0d |e_set.....addon.|
00000f80 05 be 0f 4d 4f 56 57 46 20 6d 61 74 68 73 0d 05 |...MOVWF maths..|
00000f90 c8 10 49 4e 43 46 20 6d 61 74 68 73 2c 46 0d 05 |..INCF maths,F..|
00000fa0 d2 26 4d 4f 56 4c 57 20 23 34 30 20 20 5c 48 61 |.&MOVLW #40 \Ha|
00000fb0 73 20 69 74 20 72 65 61 63 68 65 64 20 2b 34 30 |s it reached +40|
00000fc0 20 79 65 74 0d 05 dc 11 58 4f 52 57 46 20 6d 61 | yet....XORWF ma|
00000fd0 74 68 73 2c 57 0d 05 e6 15 42 54 46 53 43 20 73 |ths,W....BTFSC s|
00000fe0 74 61 74 75 73 2c 7a 65 72 6f 0d 05 f0 34 e5 20 |tatus,zero...4. |
00000ff0 77 72 61 70 61 72 6f 75 6e 64 20 20 5c 59 65 73 |wraparound \Yes|
00001000 2c 73 6f 20 61 20 77 72 61 70 61 72 6f 75 6e 64 |,so a wraparound|
00001010 20 74 6f 20 2d 33 39 20 6f 63 63 75 72 73 0d 05 | to -39 occurs..|
00001020 fa 10 4d 4f 56 46 20 6d 61 74 68 73 2c 57 0d 06 |..MOVF maths,W..|
00001030 04 0f 4d 4f 56 57 46 20 61 6c 61 72 6d 0d 06 0e |..MOVWF alarm...|
00001040 12 e5 20 64 65 62 6f 75 6e 63 65 5f 73 65 74 0d |.. debounce_set.|
00001050 06 18 0f 2e 77 72 61 70 61 72 6f 75 6e 64 0d 06 |....wraparound..|
00001060 22 22 4d 4f 56 4c 57 20 23 31 32 38 2b 33 39 20 |""MOVLW #128+39 |
00001070 20 5c 69 65 2e 74 68 69 73 20 69 73 20 2d 33 39 | \ie.this is -39|
00001080 0d 06 2c 0f 4d 4f 56 57 46 20 61 6c 61 72 6d 0d |..,.MOVWF alarm.|
00001090 06 36 12 e5 20 64 65 62 6f 75 6e 63 65 5f 73 65 |.6.. debounce_se|
000010a0 74 0d 06 40 05 3a 0d 06 4a 0d 2e 73 65 74 70 72 |t..@.:..J..setpr|
000010b0 65 73 73 0d 06 54 37 5c 53 65 74 20 69 73 20 70 |ess..T7\Set is p|
000010c0 72 65 73 73 65 64 20 77 68 69 63 68 20 68 61 73 |ressed which has|
000010d0 20 6c 69 6d 69 74 65 64 20 65 66 66 65 63 74 20 | limited effect |
000010e0 6f 6e 20 69 74 73 20 6f 77 6e 0d 06 5e 35 d6 20 |on its own..^5. |
000010f0 74 75 72 6e 6f 6e 73 63 72 65 65 6e 20 20 5c 45 |turnonscreen \E|
00001100 6e 73 75 72 65 20 73 63 72 65 65 6e 73 61 76 65 |nsure screensave|
00001110 72 20 69 73 20 6e 6f 74 20 61 63 74 69 76 65 0d |r is not active.|
00001120 06 68 10 4d 4f 56 46 20 6f 73 72 61 6d 2c 57 0d |.h.MOVF osram,W.|
00001130 06 72 26 49 4f 52 4c 57 20 23 25 78 78 78 31 30 |.r&IORLW #%xxx10|
00001140 30 30 30 20 20 5c 53 69 6c 65 6e 63 65 73 20 62 |000 \Silences b|
00001150 75 7a 7a 65 72 0d 06 7c 0f 4d 4f 56 57 46 20 6f |uzzer..|.MOVWF o|
00001160 73 72 61 6d 0d 06 86 0f 4d 4f 56 57 46 20 70 6f |sram....MOVWF po|
00001170 72 74 41 0d 06 90 32 42 53 46 20 61 63 6b 6e 6f |rtA...2BSF ackno|
00001180 77 6c 65 64 67 65 2c 37 20 20 5c 45 6e 73 75 72 |wledge,7 \Ensur|
00001190 65 20 74 68 65 20 61 6c 61 72 6d 20 73 74 61 79 |e the alarm stay|
000011a0 73 20 6f 66 66 0d 06 9a 0a e5 20 70 6f 6c 6c 0d |s off..... poll.|
000011b0 06 a4 05 3a 0d 06 ae 0b 2e 61 6c 61 72 75 6d 0d |...:.....alarum.|
000011c0 06 b8 44 42 54 46 53 43 20 61 63 6b 6e 6f 77 6c |..DBTFSC acknowl|
000011d0 65 64 67 65 2c 37 20 20 5c 44 6f 20 6e 6f 74 68 |edge,7 \Do noth|
000011e0 69 6e 67 20 69 66 20 74 68 65 20 75 73 65 72 20 |ing if the user |
000011f0 73 69 6c 65 6e 63 65 64 20 74 68 65 20 62 75 7a |silenced the buz|
00001200 7a 65 72 0d 06 c2 05 f8 0d 06 cc 2e 4d 4f 56 46 |zer.........MOVF|
00001210 20 73 63 61 6c 65 64 41 44 43 2c 57 20 20 5c 49 | scaledADC,W \I|
00001220 67 6e 6f 72 65 20 69 66 20 74 68 65 79 27 72 65 |gnore if they're|
00001230 20 65 71 75 61 6c 0d 06 d6 11 58 4f 52 57 46 20 | equal....XORWF |
00001240 61 6c 61 72 6d 2c 57 0d 06 e0 15 42 54 46 53 43 |alarm,W....BTFSC|
00001250 20 73 74 61 74 75 73 2c 7a 65 72 6f 0d 06 ea 05 | status,zero....|
00001260 f8 0d 06 f4 2f 4d 4f 56 46 20 73 63 61 6c 65 64 |..../MOVF scaled|
00001270 41 44 43 2c 57 20 20 5c 54 65 73 74 20 69 66 20 |ADC,W \Test if |
00001280 74 68 65 79 27 72 65 20 62 6f 74 68 20 2d 76 65 |they're both -ve|
00001290 0d 06 fe 0f 80 57 46 20 61 6c 61 72 6d 2c 57 0d |.....WF alarm,W.|
000012a0 07 08 0f 4d 4f 56 57 46 20 6d 61 74 68 73 0d 07 |...MOVWF maths..|
000012b0 12 26 42 54 46 53 43 20 6d 61 74 68 73 2c 37 20 |.&BTFSC maths,7 |
000012c0 20 5c 42 6f 74 68 20 68 61 64 20 62 69 74 20 37 | \Both had bit 7|
000012d0 20 73 65 74 0d 07 1c 0f e5 20 62 6f 74 68 6d 69 | set..... bothmi|
000012e0 6e 75 73 0d 07 26 14 4d 4f 56 46 20 73 63 61 6c |nus..&.MOVF scal|
000012f0 65 64 41 44 43 2c 57 0d 07 30 11 49 4f 52 57 46 |edADC,W..0.IORWF|
00001300 20 61 6c 61 72 6d 2c 57 0d 07 3a 0f 4d 4f 56 57 | alarm,W..:.MOVW|
00001310 46 20 6d 61 74 68 73 0d 07 44 28 42 54 46 53 53 |F maths..D(BTFSS|
00001320 20 6d 61 74 68 73 2c 37 20 20 5c 42 6f 74 68 20 | maths,7 \Both |
00001330 68 61 64 20 62 69 74 20 37 20 63 6c 65 61 72 0d |had bit 7 clear.|
00001340 07 4e 0e e5 20 62 6f 74 68 70 6c 75 73 0d 07 58 |.N.. bothplus..X|
00001350 0d 2e 6e 6f 6e 65 71 75 61 6c 0d 07 62 15 42 54 |..nonequal..b.BT|
00001360 46 53 53 20 73 63 61 6c 65 64 41 44 43 2c 37 0d |FSS scaledADC,7.|
00001370 07 6c 05 f8 0d 07 76 10 2e 74 75 72 6e 6f 6e 61 |.l....v..turnona|
00001380 6c 61 72 6d 0d 07 80 10 4d 4f 56 46 20 6f 73 72 |larm....MOVF osr|
00001390 61 6d 2c 57 0d 07 8a 34 80 4c 57 20 23 25 78 78 |am,W...4.LW #%xx|
000013a0 78 30 31 31 31 31 20 20 5c 47 72 6f 75 6e 64 20 |x01111 \Ground |
000013b0 74 68 65 20 62 75 7a 7a 65 72 20 74 6f 20 74 75 |the buzzer to tu|
000013c0 72 6e 20 69 74 20 6f 6e 0d 07 94 21 4d 4f 56 57 |rn it on...!MOVW|
000013d0 46 20 6f 73 72 61 6d 20 20 5c 55 70 64 61 74 65 |F osram \Update|
000013e0 20 72 61 6d 20 63 6f 70 79 0d 07 9e 14 42 43 46 | ram copy....BCF|
000013f0 20 70 6f 72 74 41 2c 62 75 7a 7a 65 72 0d 07 a8 | portA,buzzer...|
00001400 05 f8 0d 07 b2 0d 2e 62 6f 74 68 70 6c 75 73 0d |.......bothplus.|
00001410 07 bc 10 4d 4f 56 46 20 61 6c 61 72 6d 2c 57 0d |...MOVF alarm,W.|
00001420 07 c6 15 53 55 42 57 46 20 73 63 61 6c 65 64 41 |...SUBWF scaledA|
00001430 44 43 2c 46 0d 07 d0 3a 42 54 46 53 43 20 73 63 |DC,F...:BTFSC sc|
00001440 61 6c 65 64 41 44 43 2c 37 20 20 5c 42 65 63 6f |aledADC,7 \Beco|
00001450 6d 65 73 20 2d 76 65 20 69 66 20 74 65 6d 70 65 |mes -ve if tempe|
00001460 72 61 74 75 72 65 20 3c 20 61 6c 61 72 6d 0d 07 |rature < alarm..|
00001470 da 11 e5 20 74 75 72 6e 6f 6e 61 6c 61 72 6d 0d |... turnonalarm.|
00001480 07 e4 05 f8 0d 07 ee 0e 2e 62 6f 74 68 6d 69 6e |.........bothmin|
00001490 75 73 0d 07 f8 10 4d 4f 56 46 20 61 6c 61 72 6d |us....MOVF alarm|
000014a0 2c 57 0d 08 02 12 80 4c 57 20 23 25 30 31 31 31 |,W.....LW #%0111|
000014b0 31 31 31 31 0d 08 0c 23 4d 4f 56 57 46 20 6d 61 |1111...#MOVWF ma|
000014c0 74 68 73 20 20 5c 45 6e 73 75 72 65 73 20 69 74 |ths \Ensures it|
000014d0 20 69 73 20 2b 76 65 0d 08 16 13 42 43 46 20 73 | is +ve....BCF s|
000014e0 63 61 6c 65 64 41 44 43 2c 37 0d 08 20 14 4d 4f |caledADC,7.. .MO|
000014f0 56 46 20 73 63 61 6c 65 64 41 44 43 2c 57 0d 08 |VF scaledADC,W..|
00001500 2a 11 53 55 42 57 46 20 6d 61 74 68 73 2c 46 0d |*.SUBWF maths,F.|
00001510 08 34 36 42 54 46 53 43 20 6d 61 74 68 73 2c 37 |.46BTFSC maths,7|
00001520 20 20 5c 42 65 63 6f 6d 65 73 20 2d 76 65 20 69 | \Becomes -ve i|
00001530 66 20 74 65 6d 70 65 72 61 74 75 72 65 20 3c 20 |f temperature < |
00001540 61 6c 61 72 6d 0d 08 3e 11 e5 20 74 75 72 6e 6f |alarm..>.. turno|
00001550 6e 61 6c 61 72 6d 0d 08 48 05 f8 0d 08 52 05 3a |nalarm..H....R.:|
00001560 0d 08 5c 0b 2e 68 6f 77 68 6f 74 0d 08 66 11 d6 |..\..howhot..f..|
00001570 20 61 6e 61 6c 6f 67 75 65 69 6e 30 0d 08 70 0e | analoguein0..p.|
00001580 4d 4f 56 4c 57 20 23 32 35 35 0d 08 7a 14 42 54 |MOVLW #255..z.BT|
00001590 46 53 43 20 61 64 72 65 73 75 6c 74 2c 37 0d 08 |FSC adresult,7..|
000015a0 84 0e 4d 4f 56 4c 57 20 23 31 32 38 0d 08 8e 14 |..MOVLW #128....|
000015b0 58 4f 52 57 46 20 61 64 72 65 73 75 6c 74 2c 57 |XORWF adresult,W|
000015c0 0d 08 98 36 4d 4f 56 57 46 20 73 63 61 6c 65 64 |...6MOVWF scaled|
000015d0 41 44 43 20 20 5c 54 65 6d 70 65 72 61 74 75 72 |ADC \Temperatur|
000015e0 65 20 69 73 20 6e 6f 77 20 32 35 35 2e 2e 2e 30 |e is now 255...0|
000015f0 2e 2e 2e 31 32 37 0d 08 a2 14 42 43 46 20 73 74 |...127....BCF st|
00001600 61 74 75 73 2c 63 61 72 72 79 0d 08 ac 45 52 52 |atus,carry...ERR|
00001610 46 20 73 63 61 6c 65 64 41 44 43 2c 57 20 20 5c |F scaledADC,W \|
00001620 48 61 6c 76 65 20 74 68 65 20 74 65 6d 70 65 72 |Halve the temper|
00001630 61 74 75 72 65 2c 6e 6f 77 20 69 6e 20 72 61 6e |ature,now in ran|
00001640 67 65 20 31 32 37 2e 2e 2e 30 2e 2e 2e 36 33 0d |ge 127...0...63.|
00001650 08 b6 13 4d 4f 56 57 46 20 73 63 61 6c 65 64 41 |...MOVWF scaledA|
00001660 44 43 0d 08 c0 2a 42 43 46 20 73 63 61 6c 65 64 |DC...*BCF scaled|
00001670 41 44 43 2c 37 20 20 5c 45 6e 73 75 72 65 20 62 |ADC,7 \Ensure b|
00001680 69 74 37 20 69 73 20 63 6c 65 61 72 0d 08 ca 15 |it7 is clear....|
00001690 42 54 46 53 43 20 73 63 61 6c 65 64 41 44 43 2c |BTFSC scaledADC,|
000016a0 36 0d 08 d4 34 58 4f 52 4c 57 20 23 25 31 31 78 |6...4XORLW #%11x|
000016b0 78 78 78 78 78 20 20 5c 4d 61 6b 65 20 62 69 74 |xxxxx \Make bit|
000016c0 36 20 73 65 74 20 69 6e 74 6f 20 61 20 62 69 74 |6 set into a bit|
000016d0 37 20 73 65 74 0d 08 de 3d 4d 4f 56 57 46 20 73 |7 set...=MOVWF s|
000016e0 63 61 6c 65 64 41 44 43 20 20 5c 54 65 6d 70 65 |caledADC \Tempe|
000016f0 72 61 74 75 72 65 20 69 73 20 6e 6f 77 20 36 33 |rature is now 63|
00001700 2e 2e 2e 30 2e 2e 2e 36 33 20 26 20 73 69 67 6e |...0...63 & sign|
00001710 65 64 0d 08 e8 0e d6 20 62 69 6e 74 6f 42 43 44 |ed..... bintoBCD|
00001720 0d 08 f2 1a d6 20 64 69 67 69 74 73 20 20 5c 57 |..... digits \W|
00001730 72 69 74 65 20 62 79 74 65 73 0d 08 fc 05 f8 0d |rite bytes......|
00001740 09 06 05 3a 0d 09 10 10 2e 61 6e 61 6c 6f 67 75 |...:.....analogu|
00001750 65 69 6e 30 0d 09 1a 21 5c 47 65 74 20 41 44 43 |ein0...!\Get ADC|
00001760 20 76 61 6c 75 65 20 66 72 6f 6d 20 63 68 61 6e | value from chan|
00001770 6e 65 6c 20 30 0d 09 24 10 42 43 46 20 61 64 63 |nel 0..$.BCF adc|
00001780 6f 6e 30 2c 33 0d 09 2e 2a d6 20 61 6e 61 6c 6f |on0,3...*. analo|
00001790 67 75 65 69 6e 20 20 5c 4e 6f 77 20 75 73 65 20 |guein \Now use |
000017a0 67 65 6e 65 72 69 63 20 73 61 6d 70 6c 65 72 0d |generic sampler.|
000017b0 09 38 05 f8 0d 09 42 10 2e 61 6e 61 6c 6f 67 75 |.8....B..analogu|
000017c0 65 69 6e 31 0d 09 4c 21 5c 47 65 74 20 41 44 43 |ein1..L!\Get ADC|
000017d0 20 76 61 6c 75 65 20 66 72 6f 6d 20 63 68 61 6e | value from chan|
000017e0 6e 65 6c 20 31 0d 09 56 10 42 53 46 20 61 64 63 |nel 1..V.BSF adc|
000017f0 6f 6e 30 2c 33 0d 09 60 2a d6 20 61 6e 61 6c 6f |on0,3..`*. analo|
00001800 67 75 65 69 6e 20 20 5c 4e 6f 77 20 75 73 65 20 |guein \Now use |
00001810 67 65 6e 65 72 69 63 20 73 61 6d 70 6c 65 72 0d |generic sampler.|
00001820 09 6a 05 f8 0d 09 74 0f 2e 61 6e 61 6c 6f 67 75 |.j....t..analogu|
00001830 65 69 6e 0d 09 7e 28 42 53 46 20 61 64 63 6f 6e |ein..~(BSF adcon|
00001840 30 2c 67 6f 20 20 5c 54 65 6c 6c 20 74 68 65 20 |0,go \Tell the |
00001850 41 44 43 20 74 6f 20 27 67 6f 27 0d 09 88 0d 4d |ADC to 'go'....M|
00001860 4f 56 4c 57 20 23 33 32 0d 09 92 0f 4d 4f 56 57 |OVLW #32....MOVW|
00001870 46 20 64 65 6c 61 79 0d 09 9c 0e 2e 77 61 73 74 |F delay.....wast|
00001880 65 74 69 6d 65 0d 09 a6 3b 44 45 43 46 53 5a 20 |etime...;DECFSZ |
00001890 64 65 6c 61 79 2c 46 20 20 5c 41 6c 6c 6f 77 20 |delay,F \Allow |
000018a0 61 20 66 65 77 20 63 6c 6f 63 6b 20 63 79 63 6c |a few clock cycl|
000018b0 65 73 20 66 6f 72 20 41 44 43 20 73 65 74 75 70 |es for ADC setup|
000018c0 0d 09 b0 0f e5 20 77 61 73 74 65 74 69 6d 65 0d |..... wastetime.|
000018d0 09 ba 0c 2e 64 6f 6e 65 79 65 74 0d 09 c4 34 42 |....doneyet...4B|
000018e0 54 46 53 43 20 61 64 63 6f 6e 30 2c 67 6f 20 20 |TFSC adcon0,go |
000018f0 5c 53 65 65 20 69 66 20 74 68 65 20 27 67 6f 27 |\See if the 'go'|
00001900 20 62 69 74 20 69 73 20 63 6c 65 61 72 65 64 0d | bit is cleared.|
00001910 09 ce 0d e5 20 64 6f 6e 65 79 65 74 0d 09 d8 05 |.... doneyet....|
00001920 f8 0d 09 e2 05 3a 0d 09 ec 0d 2e 62 69 6e 74 6f |.....:.....binto|
00001930 42 43 44 0d 09 f6 20 43 4c 52 46 20 62 63 64 68 |BCD... CLRF bcdh|
00001940 69 20 20 5c 4d 75 73 74 20 73 74 61 72 74 20 61 |i \Must start a|
00001950 74 20 30 0d 0a 00 0f 4d 4f 56 57 46 20 62 63 64 |t 0....MOVWF bcd|
00001960 6c 6f 0d 0a 0a 24 42 54 46 53 43 20 62 63 64 6c |lo...$BTFSC bcdl|
00001970 6f 2c 37 20 20 5c 57 61 73 20 69 74 20 6e 65 67 |o,7 \Was it neg|
00001980 61 74 69 76 65 3f 0d 0a 14 39 42 53 46 20 62 63 |ative?...9BSF bc|
00001990 64 68 69 2c 33 20 20 5c 59 65 73 2c 73 6f 20 73 |dhi,3 \Yes,so s|
000019a0 65 74 20 77 68 61 74 20 77 69 6c 6c 20 62 65 63 |et what will bec|
000019b0 6f 6d 65 20 74 68 65 20 74 6f 70 20 62 69 74 0d |ome the top bit.|
000019c0 0a 1e 36 42 43 46 20 62 63 64 6c 6f 2c 37 20 20 |..6BCF bcdlo,7 |
000019d0 5c 45 6e 73 75 72 65 20 69 74 20 69 73 20 63 6c |\Ensure it is cl|
000019e0 65 61 72 20 74 6f 20 61 76 6f 69 64 20 6f 76 65 |ear to avoid ove|
000019f0 72 66 6c 6f 77 0d 0a 28 0c 2e 74 61 6b 65 74 65 |rflow..(..takete|
00001a00 6e 0d 0a 32 0d 4d 4f 56 4c 57 20 23 31 30 0d 0a |n..2.MOVLW #10..|
00001a10 3c 2a 53 55 42 57 46 20 62 63 64 6c 6f 2c 57 20 |<*SUBWF bcdlo,W |
00001a20 20 5c 52 65 70 65 61 74 65 64 6c 79 20 73 75 62 | \Repeatedly sub|
00001a30 74 72 61 63 74 20 31 30 0d 0a 46 16 42 54 46 53 |tract 10..F.BTFS|
00001a40 53 20 73 74 61 74 75 73 2c 63 61 72 72 79 0d 0a |S status,carry..|
00001a50 50 0f e5 20 63 6f 6d 70 6c 65 74 65 64 0d 0a 5a |P.. completed..Z|
00001a60 25 4d 4f 56 57 46 20 62 63 64 6c 6f 20 20 5c 53 |%MOVWF bcdlo \S|
00001a70 74 6f 72 65 20 72 65 73 75 6c 74 20 73 6f 20 66 |tore result so f|
00001a80 61 72 0d 0a 64 10 49 4e 43 46 20 62 63 64 68 69 |ar..d.INCF bcdhi|
00001a90 2c 46 0d 0a 6e 0d e5 20 74 61 6b 65 74 65 6e 0d |,F..n.. taketen.|
00001aa0 0a 78 0e 2e 63 6f 6d 70 6c 65 74 65 64 0d 0a 82 |.x..completed...|
00001ab0 31 53 57 61 50 46 20 62 63 64 68 69 2c 57 20 20 |1SWaPF bcdhi,W |
00001ac0 5c 54 68 69 73 20 62 65 63 6f 6d 65 73 20 74 68 |\This becomes th|
00001ad0 65 20 75 70 70 65 72 20 6e 79 62 62 6c 65 0d 0a |e upper nybble..|
00001ae0 8c 12 80 4c 57 20 23 25 31 31 31 31 30 30 30 30 |...LW #%11110000|
00001af0 0d 0a 96 25 49 4f 52 57 46 20 62 63 64 6c 6f 2c |...%IORWF bcdlo,|
00001b00 46 20 20 5c 43 6f 6d 62 69 6e 65 20 68 69 20 61 |F \Combine hi a|
00001b10 6e 64 20 6c 6f 0d 0a a0 0f 2e 72 61 6e 67 65 63 |nd lo.....rangec|
00001b20 68 65 63 6b 0d 0a aa 2c 42 54 46 53 43 20 62 63 |heck...,BTFSC bc|
00001b30 64 6c 6f 2c 36 20 20 5c 43 68 65 63 6b 20 74 68 |dlo,6 \Check th|
00001b40 61 74 20 74 6f 70 20 64 69 67 69 74 20 3c 20 34 |at top digit < 4|
00001b50 0d 0a b4 4b 52 45 54 4c 57 20 23 25 31 31 30 30 |...KRETLW #%1100|
00001b60 31 30 31 30 20 20 5c 4f 75 74 20 6f 66 20 72 61 |1010 \Out of ra|
00001b70 6e 67 65 20 72 65 74 75 72 6e 73 20 27 2d 34 41 |nge returns '-4A|
00001b80 27 20 77 68 69 63 68 20 62 65 63 6f 6d 65 73 20 |' which becomes |
00001b90 27 2d 2d 2d 27 20 6c 61 74 65 72 0d 0a be 2e 4d |'---' later....M|
00001ba0 4f 56 46 20 62 63 64 6c 6f 2c 57 20 20 5c 49 6e |OVF bcdlo,W \In|
00001bb0 20 72 61 6e 67 65 20 72 65 74 75 72 6e 73 20 63 | range returns c|
00001bc0 6f 6e 76 65 72 73 69 6f 6e 0d 0a c8 05 f8 0d 0a |onversion.......|
00001bd0 d2 05 3a 0d 0a dc 11 2e 74 75 72 6e 6f 6e 73 63 |..:.....turnonsc|
00001be0 72 65 65 6e 0d 0a e6 30 4d 4f 56 4c 57 20 23 30 |reen...0MOVLW #0|
00001bf0 20 20 5c 42 75 74 74 6f 6e 20 70 72 65 73 73 65 | \Button presse|
00001c00 64 20 73 6f 20 72 65 65 6e 61 62 6c 65 20 73 63 |d so reenable sc|
00001c10 72 65 65 6e 0d 0a f0 13 4d 4f 56 57 46 20 73 61 |reen....MOVWF sa|
00001c20 76 65 72 6d 61 73 6b 0d 0a fa 11 4d 4f 56 57 46 |vermask....MOVWF|
00001c30 20 74 69 6d 65 72 6c 6f 0d 0b 04 11 4d 4f 56 57 | timerlo....MOVW|
00001c40 46 20 74 69 6d 65 72 68 69 0d 0b 0e 05 f8 0d 0b |F timerhi.......|
00001c50 18 05 3a 0d 0b 22 0d 2e 77 72 69 74 65 6f 75 74 |..:.."..writeout|
00001c60 0d 0b 2c 39 49 4f 52 57 46 20 73 61 76 65 72 6d |..,9IORWF saverm|
00001c70 61 73 6b 2c 57 20 20 5c 54 61 6b 65 20 69 6e 74 |ask,W \Take int|
00001c80 6f 20 61 63 63 6f 75 6e 74 20 74 68 65 20 73 63 |o account the sc|
00001c90 72 65 65 6e 73 61 76 65 72 0d 0b 36 0f 4d 4f 56 |reensaver..6.MOV|
00001ca0 57 46 20 70 6f 72 74 42 0d 0b 40 29 4d 4f 56 46 |WF portB..@)MOVF|
00001cb0 20 6f 73 72 61 6d 2c 57 20 20 5c 52 65 61 64 20 | osram,W \Read |
00001cc0 4f 53 20 63 6f 70 79 20 6f 66 20 70 6f 72 74 20 |OS copy of port |
00001cd0 41 0d 0b 4a 2a 80 4c 57 20 23 25 78 78 78 31 30 |A..J*.LW #%xxx10|
00001ce0 78 78 78 20 20 5c 42 45 4c 20 73 74 61 74 75 73 |xxx \BEL status|
00001cf0 20 6d 61 69 6e 74 61 69 6e 65 64 0d 0b 54 0f 4d | maintained..T.M|
00001d00 4f 56 57 46 20 70 6f 72 74 41 0d 0b 5e 25 49 4f |OVWF portA..^%IO|
00001d10 52 4c 57 20 23 25 78 78 78 30 31 78 78 78 20 20 |RLW #%xxx01xxx |
00001d20 5c 4c 6f 63 6b 20 74 68 65 20 6c 61 74 63 68 0d |\Lock the latch.|
00001d30 0b 68 0f 4d 4f 56 57 46 20 70 6f 72 74 41 0d 0b |.h.MOVWF portA..|
00001d40 72 20 4d 4f 56 57 46 20 6f 73 72 61 6d 20 20 5c |r MOVWF osram \|
00001d50 55 70 64 61 74 65 20 4f 53 20 63 6f 70 79 0d 0b |Update OS copy..|
00001d60 7c 05 f8 0d 0b 86 05 3a 0d 0b 90 0b 2e 64 69 67 ||......:.....dig|
00001d70 69 74 73 0d 0b 9a 27 4d 4f 56 57 46 20 64 69 73 |its...'MOVWF dis|
00001d80 70 6c 61 79 62 79 74 65 20 20 5c 4d 61 6b 65 20 |playbyte \Make |
00001d90 61 20 52 41 4d 20 63 6f 70 79 0d 0b a4 0b 80 4c |a RAM copy.....L|
00001da0 57 20 23 31 35 0d 0b ae 24 d6 20 6c 6f 6f 6b 75 |W #15...$. looku|
00001db0 70 6c 6f 20 20 5c 42 6f 74 74 6f 6d 20 6e 79 62 |plo \Bottom nyb|
00001dc0 62 6c 65 20 66 69 72 73 74 0d 0b b8 0e d6 20 77 |ble first..... w|
00001dd0 72 69 74 65 6f 75 74 0d 0b c2 17 53 57 61 50 46 |riteout....SWaPF|
00001de0 20 64 69 73 70 6c 61 79 62 79 74 65 2c 57 0d 0b | displaybyte,W..|
00001df0 cc 0a 80 4c 57 20 23 37 0d 0b d6 23 d6 20 6c 6f |...LW #7...#. lo|
00001e00 6f 6b 75 70 68 69 20 20 5c 44 6f 20 68 69 67 68 |okuphi \Do high|
00001e10 20 64 69 67 69 74 20 6e 65 78 74 0d 0b e0 0e d6 | digit next.....|
00001e20 20 77 72 69 74 65 6f 75 74 0d 0b ea 05 f8 0d 0b | writeout.......|
00001e30 f4 05 3a 0d 0b fe 0d 2e 6c 6f 6f 6b 75 70 6c 6f |..:.....lookuplo|
00001e40 0d 0c 08 0e 41 44 44 57 46 20 50 43 2c 46 0d 0c |....ADDWF PC,F..|
00001e50 12 27 5c 42 69 74 73 20 20 25 6d 61 62 63 64 65 |.'\Bits %mabcde|
00001e60 66 67 20 20 77 68 65 72 65 20 6d 3d 6d 75 6c 74 |fg where m=mult|
00001e70 69 70 6c 65 78 0d 0c 1c 14 52 45 54 4c 57 20 23 |iplex....RETLW #|
00001e80 25 30 30 30 30 30 30 30 31 0d 0c 26 14 52 45 54 |%00000001..&.RET|
00001e90 4c 57 20 23 25 30 30 30 31 31 31 31 31 0d 0c 30 |LW #%00011111..0|
00001ea0 14 52 45 54 4c 57 20 23 25 30 30 31 30 30 31 30 |.RETLW #%0010010|
00001eb0 30 0d 0c 3a 14 52 45 54 4c 57 20 23 25 30 30 30 |0..:.RETLW #%000|
00001ec0 30 31 31 30 30 0d 0c 44 14 52 45 54 4c 57 20 23 |01100..D.RETLW #|
00001ed0 25 30 30 30 31 31 30 31 30 0d 0c 4e 14 52 45 54 |%00011010..N.RET|
00001ee0 4c 57 20 23 25 30 31 30 30 31 30 30 30 0d 0c 58 |LW #%01001000..X|
00001ef0 14 52 45 54 4c 57 20 23 25 30 31 30 30 30 30 30 |.RETLW #%0100000|
00001f00 30 0d 0c 62 14 52 45 54 4c 57 20 23 25 30 30 30 |0..b.RETLW #%000|
00001f10 31 31 31 30 31 0d 0c 6c 14 52 45 54 4c 57 20 23 |11101..l.RETLW #|
00001f20 25 30 30 30 30 30 30 30 30 0d 0c 76 14 52 45 54 |%00000000..v.RET|
00001f30 4c 57 20 23 25 30 30 30 31 31 30 30 30 0d 0c 80 |LW #%00011000...|
00001f40 32 52 45 54 4c 57 20 23 25 30 31 31 31 31 31 31 |2RETLW #%0111111|
00001f50 30 20 20 5c 53 70 65 63 69 61 6c 20 63 61 73 65 |0 \Special case|
00001f60 20 72 65 74 75 72 6e 73 20 68 79 70 68 65 6e 0d | returns hyphen.|
00001f70 0c 8a 05 3a 0d 0c 94 0d 2e 6c 6f 6f 6b 75 70 68 |...:.....lookuph|
00001f80 69 0d 0c 9e 17 42 54 46 53 43 20 64 69 73 70 6c |i....BTFSC displ|
00001f90 61 79 62 79 74 65 2c 37 0d 0c a8 0c 41 44 44 4c |aybyte,7....ADDL|
00001fa0 57 20 23 34 0d 0c b2 0e 41 44 44 57 46 20 50 43 |W #4....ADDWF PC|
00001fb0 2c 46 0d 0c bc 2e 5c 42 69 74 73 20 20 25 6d 61 |,F....\Bits %ma|
00001fc0 62 63 64 73 66 67 20 20 77 68 65 72 65 20 6d 3d |bcdsfg where m=|
00001fd0 6d 75 6c 74 69 70 6c 65 78 2c 73 3d 73 69 67 6e |multiplex,s=sign|
00001fe0 0d 0c c6 43 52 45 54 4c 57 20 23 25 31 31 31 31 |...CRETLW #%1111|
00001ff0 31 31 31 31 20 20 5c 4e 75 6d 62 65 72 73 20 30 |1111 \Numbers 0|
00002000 2c 31 2c 32 2c 33 20 77 69 74 68 20 6c 65 61 64 |,1,2,3 with lead|
00002010 69 6e 67 20 7a 65 72 6f 20 73 75 70 72 65 73 73 |ing zero supress|
00002020 69 6f 6e 0d 0c d0 14 52 45 54 4c 57 20 23 25 31 |ion....RETLW #%1|
00002030 30 30 31 31 31 31 31 0d 0c da 14 52 45 54 4c 57 |0011111....RETLW|
00002040 20 23 25 31 30 31 30 30 31 30 30 0d 0c e4 14 52 | #%10100100....R|
00002050 45 54 4c 57 20 23 25 31 30 30 30 31 31 30 30 0d |ETLW #%10001100.|
00002060 0c ee 47 52 45 54 4c 57 20 23 25 31 31 31 31 31 |..GRETLW #%11111|
00002070 31 31 30 20 20 5c 4e 75 6d 62 65 72 73 20 2d 30 |110 \Numbers -0|
00002080 2c 2d 31 2c 2d 32 2c 2d 33 20 77 69 74 68 20 6c |,-1,-2,-3 with l|
00002090 65 61 64 69 6e 67 20 7a 65 72 6f 20 73 75 70 72 |eading zero supr|
000020a0 65 73 73 69 6f 6e 0d 0c f8 14 52 45 54 4c 57 20 |ession....RETLW |
000020b0 23 25 31 30 30 31 31 30 31 31 0d 0d 02 14 52 45 |#%10011011....RE|
000020c0 54 4c 57 20 23 25 31 30 31 30 30 30 30 30 0d 0d |TLW #%10100000..|
000020d0 0c 14 52 45 54 4c 57 20 23 25 31 30 30 30 31 30 |..RETLW #%100010|
000020e0 30 30 0d 0d 16 33 52 45 54 4c 57 20 23 25 31 31 |00...3RETLW #%11|
000020f0 31 31 31 30 31 30 20 20 5c 53 70 65 63 69 61 6c |111010 \Special|
00002100 20 63 61 73 65 20 72 65 74 75 72 6e 73 20 68 79 | case returns hy|
00002110 70 68 65 6e 73 0d 0d 20 05 5d 0d 0d 2a 05 ed 0d |phens.. .]..*...|
00002120 ff |.|
00002121
.