ASxxxx Assembler V02.10  (Motorola 6809), page 1.
PHS Constant definitions
Acquisition Module

                              1 	.sbttl	Acquisition Module
                              2 
                              3 	.module	acq
                              4 
ASxxxx Assembler V02.10  (Motorola 6809), page 2.
PHS Constant definitions
Acquisition Module

                              5 	.include	/area.def/
                              1 	.sbttl	Area Definitions and Linking Order
                              2 
                              3 	; indexed label definitions
                              4 
                              5 	.area	PORTDATA	(ABS,OVR)
                              6 	.area	ACQBUFR		(ABS,OVR)
                              7 	.area	ACQVARBL	(ABS,OVR)
                              8 
                              9 	; data areas
                             10 
                             11 	.area	WORKPG		(REL,CON)
                             12 	.area	BUFSAV		(REL,CON)
                             13 	.area	ACQDATA		(REL,CON)
                             14 
                             15 	; program areas
                             16 
                             17 	.area	PGMSAV		(REL,CON)
                             18 	.area	ACIA		(REL,CON)
                             19 	.area	ACQ		(REL,CON)
                             20 	.area	HVCTRL		(REL,CON)
                             21 	.area	TERMIO		(REL,CON)
                             22 	.area	SELECT		(REL,CON)
                             23 	.area	SCREEN		(REL,CON)
                             24 	.area	SCRNUPDT	(REL,CON)
                             25 	.area	AICONV		(REL,CON)
                             26 	.area	MONDEB		(REL,CON)
                             27 	.area	IRQVEC		(REL,CON)
                             28 
                             29 	.sbttl	Default Direct Page
                             30 
                             31 	.setdp	0,PORTDATA
                             32 
ASxxxx Assembler V02.10  (Motorola 6809), page 3.
PHS Constant definitions
Default Direct Page

                              6 	.include	/define.def/
                              1 	.title	PHS Constant definitions
                              2 
                              3 
                              4 	.sbttl	VT1xx screen definitions
                              5 
                              6 	.radix	d
                              7 
                              8 ;
                              9 ;	VT1xx screen definitions
                             10 ;
                             11 
                    0050     12 	SCRNW	==	80		; screen width
                             13 
                    0000     14 	SCRNTP	==	 0		; ypos for top    line of edit area
                    0017     15 	SCRNBT	==	23		; ypos for bottom line of edit area
                    0000     16 	STATUS	==	 0		; ypos for status/command-input line
                             17 
                    0018     18 	SCRNL	==	24		; screen length
                             19 
                             20 
                             21 ; ----------------------------------------------------------
                             22 ; Definitions for various parameters
                             23 
                    FFFF     24 	ERR	==	(-1)
                    FFFE     25 	END	==	(-2)
                             26 
                    0000     27 	EOS	==	0
                    0001     28 	OK	==	1
                             29 
                    0000     30 	NO	==	0
                    0001     31 	YES	==	1
                             32 
                             33 ; ----------------------------------------------------------
                             34 ; Definitions for the Keypad
                             35 
                             36 			; zero not allowed
                    FFFF     37 	SELECT	==	 (-1)
                    FFFE     38 	CUT	==	 (-2)
                    FFFD     39 	APPEND	==	 (-3)
                    FFFC     40 	FNDNXT	==	 (-4)
                    FFFB     41 	GOLD	==	 (-5)
                    FFFA     42 	HELP	==	 (-6)
                    FFF9     43 	ENTER	==	 (-7)
                    0008     44 	SCRLL	==	   8	; backspace = 8
                    0009     45 	TAB	==	   9	; horizontal tab = 9
                    000A     46 	LF	==	  10	; linefeed = 10
                    000B     47 	SCRLU	==	  11	; vertical tab = 11
                    000C     48 	FF	==	  12	; formfeed = 12
                    000D     49 	CR	==	  13	; carriage return = 13
                    FFF2     50 	CHAR	==	(-14)
                    FFF1     51 	WORD	==	(-15)
                    FFF0     52 	LINE	==	(-16)
                    FFEF     53 	DELC	==	(-17)
                    FFEE     54 	DELW	==	(-18)
                    FFED     55 	DELL	==	(-19)
ASxxxx Assembler V02.10  (Motorola 6809), page 4.
PHS Constant definitions
VT1xx screen definitions

                    FFEC     56 	EOL	==	(-20)
                    0015     57 	CTRLU	==	  21	; ^U
                    FFEA     58 	ADVANCE	==	(-22)
                    0017     59 	CTRLW	==	  23	; ^W
                    FFE8     60 	SECTION	==	(-24)
                    FFE7     61 	PAGE	==	(-25)
                    001A     62 	CTRLZ	==	  26	; ^Z
                    001B     63 	ESCAPE	==	  27	; esc character
                    FFE4     64 	SCRLD	==	(-28)
                    FFE3     65 	SCRLR	==	(-29)
                    FFE2     66 	BACKUP	==	(-30)
                    FFE1     67 	ERROR	==	(-31)
                             68 				; characters 32-126 are valid
                    007F     69 	DELETE	==	 127	; delete to left of cursor
                    007F     70 	CRLF	==	0x7F	; internal line termination
                    0080     71 	REVERSE	==	0x80	; internal reverse video bit
                    0000     72 	NORMAL	==	0x00	; internal normal  video
                             73 
                             74 ; ----------------------------------------------------------
                             75 
                             76 	; VT1xx keypad definitions
                             77 	;
                             78 	;	(ESC O l)	--> (DELC)
                             79 	;	(ESC O m)	--> (DELW)
                             80 	;	(ESC O n)	--> (SELECT)
                             81 	;	(ESC O p)	--> (LINE)
                             82 	;	(ESC O q)	--> (WORD)
                             83 	;	(ESC O r)	--> (EOL)
                             84 	;	(ESC O s)	--> (CHAR)
                             85 	;	(ESC O t)	--> (ADVANCE)
                             86 	;	(ESC O u)	--> (BACKUP)
                             87 	;	(ESC O v)	--> (CUT)
                             88 	;	(ESC O w)	--> (PAGE)
                             89 	;	(ESC O x)	--> (SECTION)
                             90 	;	(ESC O y)	--> (APPEND)
                             91 	;	(ESC O M)	--> (ENTER)
                             92 	;	(ESC O P)	--> (GOLD)
                             93 	;	(ESC O Q)	--> (HELP)
                             94 	;	(ESC O R)	--> (FNDNXT)
                             95 	;	(ESC O S)	--> (DELL)
                             96 	;	(ESC O other)	--> (ERROR)
                             97 	;
                             98 	;	(GOLD)(DELC)	--> (UNDEL C)
                             99 	;	(GOLD)(DELW)	--> (UNDEL W)
                            100 	;	(GOLD)(SELECT)	--> (RESET)
                            101 	;	(GOLD)(LINE)	--> (OPENLINE)
                            102 	;	(GOLD)(WORD)	--> (CHNGCASE)
                            103 	;	(GOLD)(EOL)	--> (DEL EOL)
                            104 	;	(GOLD)(CHAR)	--> (BOTTOM)
                            105 	;	(GOLD)(BACKUP)	--> (TOP)
                            106 	;	(GOLD)(CUT)	--> (PASTE)
                            107 	;	(GOLD)(PAGE)	--> (COMMAND)
                            108 	;	(GOLD)(SECTION)	--> (MOVE CURSOR)
                            109 	;	(GOLD)(APPEND)	--> (REPLACE)
                            110 	;	(GOLD)(ENTER)	--> (SUBS)
                            111 	;	(GOLD)(GOLD)	--> (GOLD)
ASxxxx Assembler V02.10  (Motorola 6809), page 5.
PHS Constant definitions
VT1xx screen definitions

                            112 	;	(GOLD)(HELP)	--> (HELP)
                            113 	;	(GOLD)(FNDNXT)	--> (FIND)
                            114 	;	(GOLD)(DELL)	--> (UNDEL L)
                            115 	;
                            116 	;	(ESC [ A)	--> (SCRLU)
                            117 	;	(ESC [ B)	--> (SCRLD)
                            118 	;	(ESC [ C)	--> (SCRLL)
                            119 	;	(ESC [ D)	--> (SCRLR)
                            120 	;	(ESC [ other)	--> (ERROR)
                            121 
                            122 
                            123 	.sbttl	Acquisition Definitions
                            124 
                    0000    125 	$STOP	==	0b00000000	; acq$sts bits
                    0001    126 	$SCAN	==	0b00000001
                    0002    127 	$FAILED	==	0b00000010
                    0004    128 	$HOLD	==	0b00000100
                    0008    129 	$ACTIVE	==	0b00001000
                            130 
                    0003    131 	$OFF	==	0b00000011	; LED control bits
                    0000    132 	$YELLOW	==	0b00000000
                    0003    133 	$YFLASH	==	0b00000011
                    0001    134 	$RED	==	0b00000001
                    0002    135 	$RFLASH	==	0b00000010
                    0002    136 	$GREEN	==	0b00000010
                    0001    137 	$GFLASH	==	0b00000001
                            138 
                            139 	.sbttl	HV-Status
                            140 
                    0000    141 	$HVQMRK	==	0		; unknown state
                    0001    142 	$HVOFF	==	1
                    0002    143 	$HVON	==	2
                    0003    144 	$HVZERO	==	3
                    0004    145 	$HVFAIL	==	4
                            146 
                            147 	.sbttl	HV-Queue Functions
                            148 
                    0001    149 	M16F	==	1		; HV-Off
                    0002    150 	M16N	==	2		; HV-On
                    0003    151 	M16S	==	3		; HV-Status
                    0004    152 	M16D	==	4		; Demand Voltages
                    0005    153 	M16V	==	5		; Voltage Readings
                    0006    154 	M16CxxG	==	6		; Get Channel Voltage
                    0007    155 	M16CxxS	==	7		; Set Channel Voltage
                    0008    156 	M16CxxZ	==	8		; Zero Channel
                    0009    157 	M16CxxR	==	9		; Restore Channel
                    000A    158 	M16UPDT	==	10		; Update Sequence
                    000B    159 	M16WAIT	==	11		; 5 Second Wait
                            160 
                            161 
ASxxxx Assembler V02.10  (Motorola 6809), page 6.
PHS Constant definitions
HV-Queue Functions

                              7 
                              8 
                              9 	.area	ACQVARBL(ABS,OVR)
                             10 
                             11 	;  This area contains the variable definitions for the
                             12 	; each of the channels in the acquisition module.
                             13 
   0000                      14 	.org	0x0000
   0000                      15 acq$sum::	.blkb	2		; sum of acq$avrg array
   0002                      16 acq$index::	.blkb	1		; index into acq$avrg
   0003                      17 acq$sts::	.blkb	1		; acquisition status
                             18 
   0004                      19 phs$avrg::	.blkb	2		; pulse height average of last scan
                             20 
   0006                      21 phs$index::	.blkb	1		; pulse height array index
   0007                      22 phs$hofs::	.blkb	2		; pulse height horizontal offset
   0009                      23 phs$hscl::	.blkb	1		; pulse height horizontal scale
   000A                      24 phs$vofs::	.blkb	2		; pulse height vertical offset
   000C                      25 phs$vscl::	.blkb	1		; pulse height vertical scale
                             26 					; bit	<7>	non auto scaling
                             27 					; bits	<3:0>	scale factor
                             28 
   000D                      29 avg$vofs::	.blkb	2		; averaging vertical offset
   000F                      30 avg$vscl::	.blkb	1		; averaging vertical scale
                             31 					; bit	<7>	non auto scaling
                             32 					; bits	<3:0>	scale factor
                             33 
   0010                      34 run$index::	.blkb	1		; running array index
                             35 
   0011                      36 tmp$flag::	.blkb	1		; temperature active flag
                             37 
   0012                      38 hv$sts::	.blkb	1		; high voltage status
   0013                      39 hvc$sts::	.blkb	1		; high voltage command status
                             40 					; The temperature channel high voltage
                             41 					; status is for Power ON / OFF
                             42 
                    0014     43 	TMPVARSZ  = . - acq$sum		; size of temperature variable segment
                             44 
   0014                      45 hv$index::	.blkb	1		; high voltage array index
   0015                      46 hv$vofs::	.blkb	2		; high voltage vertical offset
   0017                      47 hv$vscl::	.blkb	1		; high voltage vertical scale
                             48 					; bit	<7>	non auto scaling
                             49 					; bits	<3:0>	scale factor
   0018                      50 hv$dmnd::	.blkb	2		; HV4032A high voltage demand
   001A                      51 hv$volt::	.blkb	2		; HV4032A high voltage reading
   001C                      52 hv$setv::	.blkb	2		; PHS HV-SET value
                             53 
   001E                      54 dlta$min::	.blkb	1		; Minimum voltage change
   001F                      55 dlta$err::	.blkb	1		; Error voltage change
   0020                      56 dlta$vlt::	.blkb	1		; Voltage change per %
                             57 
   0021                      58 hv$chng::	.blkb	2		; Updating HV-Change
   0023                      59 hv$qued::	.blkb	1		; Updating queue flag
                             60 
   0024                      61 phs$lpht::	.blkb	2		; Pulse Height Calibration
   0026                      62 cal$lpht::	.blkb	2		; LED Calibration amplitude
ASxxxx Assembler V02.10  (Motorola 6809), page 7.
PHS Constant definitions
HV-Queue Functions

   0028                      63 tmp$lpht::	.blkb	2		; LED Calibration Temperature
   002A                      64 cor$lpht::	.blkb	2		; Corrected LED amplitude
                             65 
                    002C     66 	ACQVARSZ  = . - acq$sum		; size of acquisition variable segment
                             67 
                             68 
ASxxxx Assembler V02.10  (Motorola 6809), page 8.
PHS Constant definitions
HV-Queue Functions

                             70 	.area	ACQBUFR(ABS,OVR)
                             71 
                             72 	;  This area contains the buffer definitions for the
                             73 	; acquisition module.
                             74 
   0000                      75 	.org	0x0000
                             76 
   0000                      77 acq$phs::	.blkw	0d64		; pulse height spectrum
   0080                      78 acq$avrg::	.blkw	0d64		; averaged pulse height responses
                             79 
                    0100     80 	TMPBUFSZ  = . - acq$phs		; size of temperature segment
                             81 
   0100                      82 acq$vltg::	.blkw	0d64		; HV4032A voltage levels
   0180                      83 acq$time::	.blkw	0d64		; time of update (1 minute increments)
                             84 
                    0200     85 	ACQBUFSZ  = . - acq$phs		; size of acquisition segment
                             86 
                             87 
                             88 	.area	ACQDATA(REL,CON)
                             89 
   3724                      90 upd$inh::	.blkb	1		; acquisition inhibited flag
   3725                      91 upd$seq::	.blkb	1		; sequence state
   3726                      92 upd$chn::	.blkb	1		; updating channel
   3727                      93 upd$cntr::	.blkb	1		; updating counter
   3728                      94 upd$bufp::	.blkb	2		; current buffer pointer
   372A                      95 upd$varp::	.blkb	2		; current variable pointer
   372C                      96 upd$back::	.blkb	2		; background data
   372E                      97 upd$smpl::	.blkb	2		; sample data
   3730                      98 upd$sum::	.blkb	2		; sum of (sample - background)
   3732                      99 upd$sque::	.blkb	2		; status queue
   3734                     100 upd$temp::	.blkb	1		; temperature updated flag
   3735                     101 svd$flg::	.blkb	1		; saved channel flag
   3736                     102 svd$chn::	.blkb	1		; saved channel
   3737                     103 dac$bit::	.blkb	2		; calibration bit
   3739                     104 tictoc::	.blkb	1		; LED updating ticker
                            105 
   373A                     106 divcnt::	.blkb	1		;division bit counter
   373B                     107 dsign::		.blkb	1		;dividend sign
   373C                     108 dnd::		.blkb	2		;dividend
   373E                     109 dsr::		.blkb	2		;divisor
   3740                     110 qt::		.blkb	1		;quotient
                            111 
                            112 
   3741                     113 acqbufr::
   3741                     114 		.blkb	ACQBUFSZ * 0d32	; allocation for acquisition buffers
   7741                     115 acqvar::
   7741                     116 		.blkb	ACQVARSZ * 0d32	; allocation for acquisition variables
                            117 
                            118 
ASxxxx Assembler V02.10  (Motorola 6809), page 9.
PHS Constant definitions
HV-Queue Functions

                            120 	.area	ACQ(REL,CON)
                            121 
                            122 	;  This module contains the acquisition code used to
                            123 	; acquire data from the LED pulsed scintillators.
                            124 
                            125 	;  Table of acquisition pointers
                            126 
   8BD4                     127 acqbtbl::
   8BD4 37 41               128 	.word	acqbufr + (ACQBUFSZ * 0d0)
   8BD6 39 41               129 	.word	acqbufr + (ACQBUFSZ * 0d1)
   8BD8 3B 41               130 	.word	acqbufr + (ACQBUFSZ * 0d2)
   8BDA 3D 41               131 	.word	acqbufr + (ACQBUFSZ * 0d3)
   8BDC 3F 41               132 	.word	acqbufr + (ACQBUFSZ * 0d4)
   8BDE 41 41               133 	.word	acqbufr + (ACQBUFSZ * 0d5)
   8BE0 43 41               134 	.word	acqbufr + (ACQBUFSZ * 0d6)
   8BE2 45 41               135 	.word	acqbufr + (ACQBUFSZ * 0d7)
   8BE4 47 41               136 	.word	acqbufr + (ACQBUFSZ * 0d8)
   8BE6 49 41               137 	.word	acqbufr + (ACQBUFSZ * 0d9)
   8BE8 4B 41               138 	.word	acqbufr + (ACQBUFSZ * 0d10)
   8BEA 4D 41               139 	.word	acqbufr + (ACQBUFSZ * 0d11)
   8BEC 4F 41               140 	.word	acqbufr + (ACQBUFSZ * 0d12)
   8BEE 51 41               141 	.word	acqbufr + (ACQBUFSZ * 0d13)
   8BF0 53 41               142 	.word	acqbufr + (ACQBUFSZ * 0d14)
   8BF2 55 41               143 	.word	acqbufr + (ACQBUFSZ * 0d15)
   8BF4 57 41               144 	.word	acqbufr + (ACQBUFSZ * 0d16)
   8BF6 59 41               145 	.word	acqbufr + (ACQBUFSZ * 0d17)
   8BF8 5B 41               146 	.word	acqbufr + (ACQBUFSZ * 0d18)
   8BFA 5D 41               147 	.word	acqbufr + (ACQBUFSZ * 0d19)
   8BFC 5F 41               148 	.word	acqbufr + (ACQBUFSZ * 0d20)
   8BFE 61 41               149 	.word	acqbufr + (ACQBUFSZ * 0d21)
   8C00 63 41               150 	.word	acqbufr + (ACQBUFSZ * 0d22)
   8C02 65 41               151 	.word	acqbufr + (ACQBUFSZ * 0d23)
   8C04 67 41               152 	.word	acqbufr + (ACQBUFSZ * 0d24)
   8C06 69 41               153 	.word	acqbufr + (ACQBUFSZ * 0d25)
   8C08 6B 41               154 	.word	acqbufr + (ACQBUFSZ * 0d26)
   8C0A 6D 41               155 	.word	acqbufr + (ACQBUFSZ * 0d27)
   8C0C 6F 41               156 	.word	acqbufr + (ACQBUFSZ * 0d28)
   8C0E 71 41               157 	.word	acqbufr + (ACQBUFSZ * 0d29)
   8C10 73 41               158 	.word	acqbufr + (ACQBUFSZ * 0d30)
   8C12 75 41               159 	.word	acqbufr + (ACQBUFSZ * 0d31)
   8C14 7C C1               160 	.word	tmpbufr
                            161 
ASxxxx Assembler V02.10  (Motorola 6809), page 10.
PHS Constant definitions
HV-Queue Functions

   8C16                     163 acqvtbl::
   8C16 77 41               164 	.word	acqvar + (ACQVARSZ * 0d0)
   8C18 77 6D               165 	.word	acqvar + (ACQVARSZ * 0d1)
   8C1A 77 99               166 	.word	acqvar + (ACQVARSZ * 0d2)
   8C1C 77 C5               167 	.word	acqvar + (ACQVARSZ * 0d3)
   8C1E 77 F1               168 	.word	acqvar + (ACQVARSZ * 0d4)
   8C20 78 1D               169 	.word	acqvar + (ACQVARSZ * 0d5)
   8C22 78 49               170 	.word	acqvar + (ACQVARSZ * 0d6)
   8C24 78 75               171 	.word	acqvar + (ACQVARSZ * 0d7)
   8C26 78 A1               172 	.word	acqvar + (ACQVARSZ * 0d8)
   8C28 78 CD               173 	.word	acqvar + (ACQVARSZ * 0d9)
   8C2A 78 F9               174 	.word	acqvar + (ACQVARSZ * 0d10)
   8C2C 79 25               175 	.word	acqvar + (ACQVARSZ * 0d11)
   8C2E 79 51               176 	.word	acqvar + (ACQVARSZ * 0d12)
   8C30 79 7D               177 	.word	acqvar + (ACQVARSZ * 0d13)
   8C32 79 A9               178 	.word	acqvar + (ACQVARSZ * 0d14)
   8C34 79 D5               179 	.word	acqvar + (ACQVARSZ * 0d15)
   8C36 7A 01               180 	.word	acqvar + (ACQVARSZ * 0d16)
   8C38 7A 2D               181 	.word	acqvar + (ACQVARSZ * 0d17)
   8C3A 7A 59               182 	.word	acqvar + (ACQVARSZ * 0d18)
   8C3C 7A 85               183 	.word	acqvar + (ACQVARSZ * 0d19)
   8C3E 7A B1               184 	.word	acqvar + (ACQVARSZ * 0d20)
   8C40 7A DD               185 	.word	acqvar + (ACQVARSZ * 0d21)
   8C42 7B 09               186 	.word	acqvar + (ACQVARSZ * 0d22)
   8C44 7B 35               187 	.word	acqvar + (ACQVARSZ * 0d23)
   8C46 7B 61               188 	.word	acqvar + (ACQVARSZ * 0d24)
   8C48 7B 8D               189 	.word	acqvar + (ACQVARSZ * 0d25)
   8C4A 7B B9               190 	.word	acqvar + (ACQVARSZ * 0d26)
   8C4C 7B E5               191 	.word	acqvar + (ACQVARSZ * 0d27)
   8C4E 7C 11               192 	.word	acqvar + (ACQVARSZ * 0d28)
   8C50 7C 3D               193 	.word	acqvar + (ACQVARSZ * 0d29)
   8C52 7C 69               194 	.word	acqvar + (ACQVARSZ * 0d30)
   8C54 7C 95               195 	.word	acqvar + (ACQVARSZ * 0d31)
   8C56 7D C1               196 	.word	tmpvar
                            197 
ASxxxx Assembler V02.10  (Motorola 6809), page 11.
PHS Constant definitions
Change and Read Acquisition Status

                            199 	.sbttl	Change and Read Acquisition Status
                            200 
                            201 	;  chng$sts
                            202 	;
                            203 	;   The change status routine waits for the acquisition
                            204 	;  routine to complete any pending update before loading
                            205 	;  the change queue.
                            206 	;
                            207 	;  wait$sts
                            208 	;
                            209 	;   The wait status routine waits for the aqcuisition routine
                            210 	;  to emtpy the update queue.
                            211 	;
                            212 	;  rd$sts
                            213 	;
                            214 	;   The read status routine returns the specified acquisition
                            215 	;  channels status.
                            216 	;
                            217 	
                            218 	;  a	-	channel number to change status
                            219 	;  b	-	channel status
                            220 	;	bit 0	initiate single scan / scanning
                            221 	;	bit 1	channel failed
                            222 	;	bit 2	channel on hold
                            223 	;	bit 3	channel active
                            224 	;
                            225 	;	bit 7	internal flag
                            226 
   8C58                     227 chng$sts::
   8C58 34 06               228 	pshs	d
   8C5A 34 01               229 1$:	pshs	cc		; save condition codes
   8C5C 1A 50               230 	orcc	#0q120		; hold interrupts
   8C5E FC 37 32            231 	ldd	upd$sque	; check queued request
   8C61 27 04               232 	beq	2$		; none - ok
   8C63 35 01               233 	puls	cc		; else wait
   8C65 20 F3               234 	bra	1$
                            235 
   8C67 EC 61               236 2$:	ldd	1,s
   8C69 CA 80               237 	orb	#0q200		; flag it
   8C6B FD 37 32            238 	std	upd$sque	; load update status queue
   8C6E 35 01               239 	puls	cc		; restore cc's
   8C70 35 06               240 	puls	d
   8C72 39                  241 	rts
                            242 
   8C73                     243 wait$sts::
   8C73 34 06               244 	pshs	d
   8C75 FC 37 32            245 1$:	ldd	upd$sque	; wait for queue to empty
   8C78 26 FB               246 	bne	1$
   8C7A 35 06               247 	puls	d
   8C7C 39                  248 	rts
                            249 
   8C7D                     250 rd$sts::
   8C7D 34 12               251 	pshs	a,x
   8C7F 81 20               252 	cmpa	#0d32		; check channel
   8C81 23 03               253 	blos	1$		; ok - skip
   8C83 5F                  254 	clrb			; invalid channel #
ASxxxx Assembler V02.10  (Motorola 6809), page 12.
PHS Constant definitions
Change and Read Acquisition Status

   8C84 20 0A               255 	bra	2$
                            256 
   8C86 48                  257 1$:	asla			; make index
   8C87 8E 8C 16            258 	ldx	#acqvtbl	; table of variable pointers
   8C8A 30 96               259 	leax	[a,x]		; get current channel variable base
   8C8C E6 89 00 03         260 	ldb	acq$sts,x	; get the current status
   8C90 35 12               261 2$:	puls	a,x
   8C92 39                  262 	rts
                            263 
                            264 
ASxxxx Assembler V02.10  (Motorola 6809), page 13.
PHS Constant definitions
phs$set - LED Pulse Height Set

                            266 	.sbttl	phs$set - LED Pulse Height Set
                            267 
                            268 	;
                            269 	;  a	-	Channel to Calibrate
                            270 	;  x	-	LED DAC set value
                            271 	;
                            272 	;  Sequence:	Same as phs$cal except steps 2 & 3 replaced
                            273 	;		with DAC set value.
                            274 	;
                            275 	;	Note:	This sequence never fails.
                            276 	;
                            277 
   8C93                     278 phs$set::
                            279 
                            280 	;	1	Stop acquisition on this channel.
                            281 
   8C93 34 04               282 	pshs	b
   8C95 C6 00               283 	ldb	#$STOP		; DAC set must stop any acquisition
   8C97 BD 8C 58            284 	jsr	chng$sts	; stop acquisition on this channel
   8C9A BD 8C 73            285 	jsr	wait$sts	; wait for status queue to empty
   8C9D 35 04               286 	puls	b
                            287 
   8C9F 34 36               288 	pshs	d,x,y
   8CA1 34 02               289 	pshs	a		; save channel number
   8CA3 34 10               290 	pshs	x		; save DAC set value
   8CA5 48                  291 	asla
   8CA6 8E 8C 16            292 	ldx	#acqvtbl	; variables pointer
   8CA9 30 96               293 	leax	[a,x]
   8CAB 10 8E 8B D4         294 	ldy	#acqbtbl	; arrays pointer
   8CAF 31 B6               295 	leay	[a,y]
                            296 
   8CB1 35 06               297 	puls	d		; get DAC set value
   8CB3 ED 89 00 26         298 	std	cal$lpht,x	; load
   8CB7 ED 89 00 2A         299 	std	cor$lpht,x
   8CBB 20 7B               300 	bra	phs$sete	; go complete setup
                            301 
                            302 
ASxxxx Assembler V02.10  (Motorola 6809), page 14.
PHS Constant definitions
phs$cal - LED Pulse Height Calibration

                            304 	.sbttl	phs$cal - LED Pulse Height Calibration
                            305 
                            306 	;
                            307 	;  a	-	Channel to Calibrate
                            308 	;
                            309 	;  Sequence:
                            310 	;
                            311 	;	1	Stop acquisition on this channel.
                            312 	;
                            313 	;	2	Perform a 12-bit successive approximation
                            314 	;		calibration of the LED drive output to
                            315 	;		produce a 1/2 full scale pulse height response.
                            316 	;
                            317 	;	3	If DAC level is > .95 * Full Scale or
                            318 	;		If DAC level is < .10 * Full Scale
                            319 	;			then the calibration FAILS
                            320 	;
                            321 	;	4	Load current temperature into tmp$lpht
                            322 	;		and set tmp$flag to enable temperature checks
                            323 	;
                            324 	;	5	Prepare channel's data arrays
                            325 	;			Clear histogram region
                            326 	;			Do a single scan for some real data
                            327 	;			Load acq$avrg array with the phs$avrg result
                            328 	;			Load acq$sum with 64. * phs$avrg
                            329 	;
                            330 	;	6	Activate Channel
                            331 	;
                            332 	;	7	After completion of 64 channel updates
                            333 	;		the reference pulse height calibration
                            334 	;		is set in phs$lpht
                            335 	;
                            336 
   8CBD                     337 phs$cal::
   8CBD 34 36               338 	pshs	d,x,y
   8CBF 34 02               339 	pshs	a		; save channel
   8CC1 48                  340 	asla
   8CC2 8E 8C 16            341 	ldx	#acqvtbl	; variables pointer
   8CC5 30 96               342 	leax	[a,x]
   8CC7 10 8E 8B D4         343 	ldy	#acqbtbl	; arrays pointer
   8CCB 31 B6               344 	leay	[a,y]
                            345 
                            346 	;	1	Stop acquisition on this channel.
                            347 
   8CCD A6 E4               348 	lda	,s		; restore channel number
   8CCF C6 00               349 	ldb	#$STOP		; calibration must stop any acquisition
   8CD1 BD 8C 58            350 	jsr	chng$sts	; stop acquisition on this channel
   8CD4 BD 8C 73            351 	jsr	wait$sts	; wait for status queue to empty
                            352 
                            353 	;	2	Perform a 12-bit successive approximation
                            354 	;		calibration of the LED drive output to
                            355 	;		produce a 1/2 full scale pulse height response.
                            356 
   8CD7 CC 08 00            357 	ldd	#0x0800		; msb of LED pulse height DAC
   8CDA FD 37 37            358 	std	dac$bit
   8CDD ED 89 00 26         359 	std	cal$lpht,x	; set dac amplitude
ASxxxx Assembler V02.10  (Motorola 6809), page 15.
PHS Constant definitions
phs$cal - LED Pulse Height Calibration

   8CE1 ED 89 00 2A         360 	std	cor$lpht,x
                            361 
   8CE5 A6 E4               362 1$:	lda	,s		; restore channel number
   8CE7 C6 01               363 	ldb	#$SCAN		; single scan mode
   8CE9 BD 8C 58            364 	jsr	chng$sts	; start operation
   8CEC BD 8C 73            365 	jsr	wait$sts	; wait for status queue to empty
   8CEF E6 89 00 03         366 2$:	ldb	acq$sts,x	; get channel status
   8CF3 C5 01               367 	bitb	#1		; wait for scan to complete
   8CF5 26 F8               368 	bne	2$
                            369 
   8CF7 EC 89 00 04         370 	ldd	phs$avrg,x	; average of 64. samples
   8CFB 10 83 02 00         371 	cmpd	#0x0200		; if below 1/2 full scale - skip
   8CFF 25 0F               372 	blo	3$
   8D01 EC 89 00 26         373 	ldd	cal$lpht,x	; else back off
   8D05 B3 37 37            374 	subd	dac$bit
   8D08 ED 89 00 26         375 	std	cal$lpht,x
   8D0C ED 89 00 2A         376 	std	cor$lpht,x
   8D10 FC 37 37            377 3$:	ldd	dac$bit		; update to next msb
   8D13 47                  378 	asra
   8D14 56                  379 	rorb
   8D15 FD 37 37            380 	std	dac$bit
   8D18 27 0E               381 	beq	4$		; finished
   8D1A E3 89 00 26         382 	addd	cal$lpht,x
   8D1E ED 89 00 26         383 	std	cal$lpht,x
   8D22 ED 89 00 2A         384 	std	cor$lpht,x
   8D26 20 BD               385 	bra	1$
                            386 
                            387 	;	3	If DAC level is > .95 * Full Scale or
                            388 	;		If DAC level is < .10 * Full Scale
                            389 	;			then the calibration FAILS
                            390 
   8D28 EC 89 00 26         391 4$:	ldd	cal$lpht,x	; get DAC level
   8D2C 10 83 0F 33         392 	cmpd	#0d3891		; .95 * Full Scale
   8D30 22 79               393 	bhi	9$		; FAIL
   8D32 10 83 01 9A         394 	cmpd	#0d410		; .10 * Full Scale
   8D36 25 73               395 	blo	9$		; FAIL
                            396 
                            397 	;	4	Load current temperature into tmp$lpht
                            398 	;		and set tmp$flag to enable temperature checks
                            399 
                    0164    400 phs$sete == .			; entry from phs$set
   8D38 34 20               401 	pshs	y		; save buffer address
   8D3A 10 8E 7D C1         402 	ldy	#tmpvar
   8D3E EC A9 00 00         403 	ldd	acq$sum,y	; get sum of temperature array
   8D42 59                  404 	rolb			; divide by 64
   8D43 49                  405 	rola
   8D44 59                  406 	rolb
   8D45 49                  407 	rola
   8D46 59                  408 	rolb
   8D47 1E 89               409 	exg	a,b
   8D49 84 03               410 	anda	#0x03
   8D4B ED 89 00 28         411 	std	tmp$lpht,x	; current temperature
   8D4F A6 A9 00 11         412 	lda	tmp$flag,y
   8D53 A7 89 00 11         413 	sta	tmp$flag,x	; temperature flag
   8D57 35 20               414 	puls	y		; restore buffer address
                            415 
ASxxxx Assembler V02.10  (Motorola 6809), page 16.
PHS Constant definitions
phs$cal - LED Pulse Height Calibration

                            416 	;	5	Prepare channel's data arrays
                            417 	;			Clear histogram region
                            418 	;			Do a single scan for some real data
                            419 	;			Load acq$avrg array with the phs$avrg result
                            420 	;			Load acq$sum with 64. * phs$avrg
                            421 
   8D59 34 20               422 	pshs	y		; save buffer address
   8D5B 31 A9 00 80         423 	leay	acq$phs+0d128,y	; end of histogram buffer + 1
   8D5F 86 80               424 	lda	#0d128		; buffer length
   8D61 6F A2               425 6$:	clr	,-y		; clear array
   8D63 4A                  426 	deca
   8D64 26 FB               427 	bne	6$
   8D66 35 20               428 	puls	y		; restore buffer address
                            429 
   8D68 A6 E4               430 	lda	,s		; restore channel number
   8D6A C6 01               431 	ldb	#$SCAN		; single scan
   8D6C BD 8C 58            432 	jsr	chng$sts	; start operation
   8D6F BD 8C 73            433 	jsr	wait$sts	; wait for status queue to empty
   8D72 E6 89 00 03         434 7$:	ldb	acq$sts,x	; get channel status
   8D76 C5 01               435 	bitb	#1		; wait for scan to complete
   8D78 26 F8               436 	bne	7$
                            437 
   8D7A 34 30               438 	pshs	x,y		; save addresses
   8D7C 31 A9 00 80         439 	leay	acq$avrg,y	; array of averages
   8D80 AE 89 00 04         440 	ldx	phs$avrg,x	; average of 64. samples
   8D84 86 40               441 	lda	#0d64		; buffer length
   8D86 AF A1               442 8$:	stx	,y++		; load the array
   8D88 4A                  443 	deca
   8D89 2E FB               444 	bgt	8$
   8D8B 35 30               445 	puls	x,y		; restore addresses
                            446 
   8D8D EC 89 00 04         447 	ldd	phs$avrg,x
   8D91 47                  448 	asra
   8D92 56                  449 	rorb
   8D93 46                  450 	rora
   8D94 56                  451 	rorb
   8D95 46                  452 	rora
   8D96 1E 89               453 	exg	a,b		; 64. * phs$avrg
   8D98 ED 89 00 00         454 	std	acq$sum,x	; save result
                            455 
   8D9C 6F 89 00 02         456 	clr	acq$index,x	; clear the index
                            457 
   8DA0 CC 00 00            458 	ldd	#0
   8DA3 ED 89 00 24         459 	std	phs$lpht,x	; Zero Pulse Height Calibration
                            460 
                            461 	;	6	Activate Channel
                            462 
   8DA7 C6 08               463 	ldb	#$ACTIVE	; activate this channel
   8DA9 20 02               464 	bra	10$
                            465 
   8DAB C6 02               466 9$:	ldb	#$FAILED	; FAILED
   8DAD 35 02               467 10$:	puls	a		; restore channel number
   8DAF BD 8C 58            468 	jsr	chng$sts	; set acquisition status on this channel
   8DB2 BD 8C 73            469 	jsr	wait$sts	; wait for status queue to empty
   8DB5 35 36               470 	puls	d,x,y
   8DB7 39                  471 	rts
ASxxxx Assembler V02.10  (Motorola 6809), page 17.
PHS Constant definitions
phs$cal - LED Pulse Height Calibration

                            472 
                            473 
ASxxxx Assembler V02.10  (Motorola 6809), page 18.
PHS Constant definitions
Channel Update

                            475 	.sbttl	Channel Update
                            476 
                            477 	;  Channel update code:
                            478 	;
                            479 	;	 This code acquires 64 samples and averages the
                            480 	;	results to produce a representation of the current
                            481 	;	pulse height response.  The code maintains a list
                            482 	;	of the last 64 pulse height responses.  Normally
                            483 	;	a 64 sample response for each active channel
                            484 	;	requires about .5-.6 seconds.  Thus if 32 channels
                            485 	;	were active, approximately 15-20 seconds are required
                            486 	;	to scan all active channels.
                            487 	;
                            488 	;	 After all channels have been scanned the temperature
                            489 	;	is scanned.
                            490 	;
                            491 	;	 Each call to chan$upd also updates one channel
                            492 	;	of the LED display.
                            493 	;
                            494 
   8DB8                     495 chan$upd::
                            496 
   8DB8 7D 37 24            497 	tst	upd$inh		; have we been inhibited ?
   8DBB 10 26 01 53         498 	lbne	14$		; yes - just exit
                            499 
                            500 	; LED update
                            501 
   8DBF B6 37 39            502 	lda	tictoc
   8DC2 84 1F               503 	anda	#0x1F
                            504 
   8DC4 8E 7F 20            505 	ldx	#sys$led	; LED address
   8DC7 30 86               506 	leax	a,x
                            507 
   8DC9 48                  508 	asla
   8DCA 10 8E 8C 16         509 	ldy	#acqvtbl	; variable address table
   8DCE 31 B6               510 	leay	[a,y]
   8DD0 A6 A9 00 03         511 	lda	acq$sts,y
                            512 
   8DD4 85 04               513 	bita	#$HOLD		; holding ?
   8DD6 27 44               514 	beq	3$		; no - skip
                            515 
                            516 	; Holding LED Modes
                            517 
   8DD8 C6 03               518 	ldb	#$OFF		; default
                            519 
   8DDA 85 01               520 	bita	#$SCAN		; scanning ?
   8DDC 27 12               521 	beq	1$		; no - skip
   8DDE C6 03               522 	ldb	#$YFLASH	; flashing if scanning
   8DE0 86 00               523 	lda	#$YELLOW
   8DE2 A1 84               524 	cmpa	,x
   8DE4 27 4C               525 	beq	4$
   8DE6 86 03               526 	lda	#$OFF
   8DE8 A1 84               527 	cmpa	,x
   8DEA 27 46               528 	beq	4$
   8DEC A7 84               529 	sta	,x
   8DEE 20 42               530 	bra	4$
ASxxxx Assembler V02.10  (Motorola 6809), page 19.
PHS Constant definitions
Channel Update

                            531 
   8DF0 85 02               532 1$:	bita	#$FAILED	; FAILED ?
   8DF2 27 12               533 	beq	2$		; no - skip
   8DF4 C6 02               534 	ldb	#$RFLASH	; red flashing if FAILED
   8DF6 86 01               535 	lda	#$RED
   8DF8 A1 84               536 	cmpa	,x
   8DFA 27 36               537 	beq	4$
   8DFC 86 03               538 	lda	#$OFF
   8DFE A1 84               539 	cmpa	,x
   8E00 27 30               540 	beq	4$
   8E02 A7 84               541 	sta	,x
   8E04 20 2C               542 	bra	4$
                            543 
   8E06 85 08               544 2$:	bita	#$ACTIVE	; active ?
   8E08 27 2A               545 	beq	5$		; no - skip to update
   8E0A C6 01               546 	ldb	#$GFLASH	; green flashing if active
   8E0C 86 02               547 	lda	#$GREEN
   8E0E A1 84               548 	cmpa	,x
   8E10 27 20               549 	beq	4$
   8E12 86 03               550 	lda	#$OFF
   8E14 A1 84               551 	cmpa	,x
   8E16 27 1A               552 	beq	4$
   8E18 A7 84               553 	sta	,x
   8E1A 20 16               554 	bra	4$
                            555 
                            556 	; Non Holding LED Modes
                            557 
   8E1C C6 00               558 3$:	ldb	#$YELLOW	; yellow if scanning
   8E1E 85 01               559 	bita	#$SCAN		; scanning ?
   8E20 26 12               560 	bne	5$		; yes - skip to update
                            561 
   8E22 C6 01               562 	ldb	#$RED		; red if FAILED
   8E24 85 02               563 	bita	#$FAILED	; FAILED ?
   8E26 26 0C               564 	bne	5$		; yes - skip to update
                            565 
   8E28 C6 02               566 	ldb	#$GREEN		; green if active
   8E2A 85 08               567 	bita	#$ACTIVE	; active ?
   8E2C 26 06               568 	bne	5$		; yes - skip to update
                            569 
   8E2E C6 03               570 	ldb	#$OFF		; none on
   8E30 20 02               571 	bra	5$		; go update
                            572 
   8E32 E8 84               573 4$:	eorb	,x
   8E34 E7 84               574 5$:	stb	,x
                            575 
                            576 	; Queue Updating
                            577 
   8E36 6D A9 00 23         578 	tst	hv$qued,y	; ready for update ?
   8E3A 27 2D               579 	beq	6$		; no - skip
   8E3C 34 20               580 	pshs	y		; get number of queue
   8E3E 10 8E 34 00         581 	ldy	#port2		; elements used
   8E42 E6 A9 00 D0         582 	ldb	que$cntr,y
   8E46 35 20               583 	puls	y
   8E48 C1 10               584 	cmpb	#0d16		; space ?
   8E4A 24 1D               585 	bhis	6$		; no - try again later
   8E4C F6 37 39            586 	ldb	tictoc		; channel number
ASxxxx Assembler V02.10  (Motorola 6809), page 20.
PHS Constant definitions
Channel Update

   8E4F C4 1F               587 	andb	#0x1F
   8E51 86 06               588 	lda	#M16CxxG
   8E53 BD 92 FF            589 	jsr	en$que
   8E56 86 0A               590 	lda	#M16UPDT
   8E58 BD 92 FF            591 	jsr	en$que
   8E5B 86 0B               592 	lda	#M16WAIT
   8E5D BD 92 FF            593 	jsr	en$que
   8E60 86 06               594 	lda	#M16CxxG
   8E62 BD 92 FF            595 	jsr	en$que
   8E65 6F A9 00 23         596 	clr	hv$qued,y	; queued
                            597 
                            598 	; end of this tic's updating
                            599 
   8E69 7C 37 39            600 6$:	inc	tictoc		; another tic
                            601 
                            602 	; channel update
                            603 
   8E6C B6 37 26            604 	lda	upd$chn		; time for temperature ?
   8E6F 81 1F               605 	cmpa	#0x1F
   8E71 23 03               606 	blos	7$		; no -  do a channel
   8E73 7E 90 CB            607 	jmp	temp$upd	; yes - do temperature
                            608 
   8E76 B6 37 25            609 7$:	lda	upd$seq
   8E79 10 26 00 81         610 	lbne	12$
                            611 
                            612 ;state0
   8E7D 7D 37 35            613 	tst	svd$flg		; a saved update ?
   8E80 27 09               614 	beq	8$		; no - skip
   8E82 B6 37 36            615 	lda	svd$chn		; reload saved channel
   8E85 7F 37 35            616 	clr	svd$flg		; clear entry
   8E88 B7 37 26            617 	sta	upd$chn		; save it
                            618 
   8E8B FC 37 32            619 8$:	ldd	upd$sque	; update a status ?
   8E8E 27 30               620 	beq	11$		; no - skip
   8E90 81 1F               621 	cmpa	#0x1F		; valid channel ?
   8E92 23 07               622 	blos	9$		; yes - skip
   8E94 CC 00 00            623 	ldd	#0
   8E97 FD 37 32            624 	std	upd$sque	; clear the entry
   8E9A 39                  625 	rts
                            626 
   8E9B 48                  627 9$:	asla			; make index
   8E9C 8E 8C 16            628 	ldx	#acqvtbl	; table of variable pointers
   8E9F 30 96               629 	leax	[a,x]		; get current channel variable base
   8EA1 C4 7F               630 	andb	#0q177		; mask internal flag
   8EA3 E7 89 00 03         631 	stb	acq$sts,x	; save the new status
   8EA7 C5 01               632 	bitb	#1		; immediate scan ?
   8EA9 27 0F               633 	beq	10$		; no - skip
   8EAB F6 37 26            634 	ldb	upd$chn		; yes - save upd$chn
   8EAE F7 37 36            635 	stb	svd$chn
   8EB1 7C 37 35            636 	inc	svd$flg		; and flag it
   8EB4 FC 37 32            637 	ldd	upd$sque	; get immediate channel
   8EB7 B7 37 26            638 	sta	upd$chn		; do this channel
   8EBA CC 00 00            639 10$:	ldd	#0		; clear status queue
   8EBD FD 37 32            640 	std	upd$sque
                            641  
   8EC0 B6 37 26            642 11$:	lda	upd$chn		; get current channel being processed
ASxxxx Assembler V02.10  (Motorola 6809), page 21.
PHS Constant definitions
Channel Update

   8EC3 48                  643 	asla			; make index
   8EC4 8E 8B D4            644 	ldx	#acqbtbl	; table of buffer pointers
   8EC7 30 96               645 	leax	[a,x]		; get current channel buffer base
   8EC9 BF 37 28            646 	stx	upd$bufp	; save buffer pointer
   8ECC 8E 8C 16            647 	ldx	#acqvtbl	; table of variable pointers
   8ECF 30 96               648 	leax	[a,x]		; get current channel variable base
   8ED1 BF 37 2A            649 	stx	upd$varp	; save the variable pointer
   8ED4 A6 89 00 03         650 	lda	acq$sts,x	; this channel active ?
   8ED8 85 04               651 	bita	#$HOLD		; holding ?
   8EDA 26 33               652 	bne	13$		; yes - skip channel
   8EDC 85 09               653 	bita	#$ACTIVE|$SCAN	; active / single scan
   8EDE 27 2F               654 	beq	13$		; no  - skip channel
   8EE0 CC 00 00            655 	ldd	#0
   8EE3 B7 37 27            656 	sta	upd$cntr	; clear the counter
   8EE6 FD 37 30            657 	std	upd$sum		; clear the sum
   8EE9 EC 89 00 2A         658 	ldd	cor$lpht,x	; load current channel
   8EED FD 7F 02            659 	std	acq$dac		; LED pulse amplitude
   8EF0 A6 89 00 03         660 	lda	acq$sts,x	; set scan flag
   8EF4 8A 01               661 	ora	#1
   8EF6 A7 89 00 03         662 	sta	acq$sts,x
   8EFA 7C 37 25            663 	inc	upd$seq		; next sequence after a clock tick
   8EFD 39                  664 	rts
                            665 
   8EFE 81 01               666 12$:	cmpa	#1		; state1 ?
   8F00 26 10               667 	bne	14$
                            668 ;state1
   8F02 CC 8F 16            669 	ldd	#15$		; load FIRQ address
   8F05 FD 37 08            670 	std	exfirq
   8F08 B6 37 26            671 	lda	upd$chn		; select byte with no pulsing
   8F0B B7 7F 04            672 	sta	acq$slct	; start acquisition
   8F0E 39                  673 	rts
                            674 
                            675 ;skip channel
   8F0F 7C 37 26            676 13$:	inc	upd$chn
                            677 
                            678 ;state - invalid
   8F12 7F 37 25            679 14$:	clr	upd$seq
   8F15 39                  680 	rts
                            681 
                            682 
                            683 ;firqseq1
   8F16 34 06               684 15$:	pshs	d		; save register
   8F18 FC 7F 06            685 	ldd	acq$adc		; get background data
   8F1B 1E 89               686 	exg	a,b		; oops !
   8F1D FD 37 2C            687 	std	upd$back	; save background
   8F20 10 2B 01 03         688 	lbmi	25$		; acquisition inhibitted
   8F24 CC 8F 35            689 	ldd	#16$		; load FIRQ address
   8F27 FD 37 08            690 	std	exfirq
   8F2A B6 37 26            691 	lda	upd$chn		; select byte with no pulsing
   8F2D 8A 80               692 	ora	#0x80		; enable LED pulsing
   8F2F B7 7F 04            693 	sta	acq$slct	; start acquisition
   8F32 35 06               694 	puls	d
   8F34 3B                  695 	rti
                            696 
                            697 ;firqseq2
   8F35 34 06               698 16$:	pshs	d		; save register
ASxxxx Assembler V02.10  (Motorola 6809), page 22.
PHS Constant definitions
Channel Update

   8F37 FC 7F 06            699 	ldd	acq$adc		; get data sample
   8F3A 1E 89               700 	exg	a,b		; oops !
   8F3C FD 37 2E            701 	std	upd$smpl	; save sample
   8F3F 10 2B 00 E4         702 	lbmi	25$		; acquisition inhibitted
   8F43 B3 37 2C            703 	subd	upd$back	; subtract background
   8F46 2A 03               704 	bpl	17$		; only upd$smpl-upd$back > 0 accepted
   8F48 CC 00 00            705 	ldd	#0
   8F4B F3 37 30            706 17$:	addd	upd$sum		; add to sum
   8F4E FD 37 30            707 	std	upd$sum
                            708 
   8F51 34 70               709 	pshs	x,y,u		; save registers
   8F53 FE 37 28            710 	ldu	upd$bufp	; get channel buffer pointer
   8F56 10 BE 37 2A         711 	ldy	upd$varp	; get channel variable pointer
                            712 
                            713 	; update the channels pulse height histogram
                            714 
   8F5A E6 A9 00 09         715 	ldb	phs$hscl,y	; get the display range
   8F5E C1 04               716 	cmpb	#0d4		; 0 - 1024, 1 - 512, 2 - 256, 3 - 128, 4 -64
   8F60 23 01               717 	blos	18$
   8F62 5F                  718 	clrb
   8F63 30 8C 16            719 18$:	leax	20$,pcr		; compute entry
   8F66 58                  720 	aslb
   8F67 30 85               721 	leax	b,x
   8F69 FC 37 2E            722 	ldd	upd$smpl	; get sample
   8F6C B3 37 2C            723 	subd	upd$back	; subtract background
   8F6F 2A 03               724 	bpl	19$		; only upd$smpl-upd$back > 0 accepted
   8F71 CC 00 00            725 	ldd	#0
   8F74 A3 A9 00 07         726 19$:	subd	phs$hofs,y	; start from this point
   8F78 2B 36               727 	bmi	22$		; out of range - skip
   8F7A 6E 84               728 	jmp	,x		; go to proper entry
   8F7C 47                  729 20$:	asra			; 1024 range
   8F7D 56                  730 	rorb
   8F7E 47                  731 	asra			; 512 range
   8F7F 56                  732 	rorb
   8F80 47                  733 	asra			; 256 range
   8F81 56                  734 	rorb
   8F82 47                  735 	asra			; 128 range
   8F83 56                  736 	rorb
   8F84 10 83 00 3F         737 	cmpd	#0x3F		; 64 range
   8F88 22 26               738 	bhi	22$		; out of range - skip
   8F8A 58                  739 	aslb			; *2
   8F8B 30 C9 00 00         740 	leax	acq$phs,u	; pulse height spectrum address
   8F8F 30 85               741 	leax	b,x		; channel address
   8F91 EC 84               742 	ldd	,x		; increment channel
   8F93 C3 00 01            743 	addd	#1
   8F96 ED 84               744 	std	,x
   8F98 2A 16               745 	bpl	22$		; skip rescale if no overflow
                            746 
                            747 	; rescale histogram array
                            748 
   8F9A 86 40               749 	lda	#0d64		; length of array
   8F9C A7 E2               750 	sta	,-s
   8F9E 30 C9 00 00         751 	leax	acq$phs,u	; pulse height spectrum address
   8FA2 EC 84               752 21$:	ldd	,x		; divide array by 2
   8FA4 1C FE               753 	clc
   8FA6 46                  754 	rora
ASxxxx Assembler V02.10  (Motorola 6809), page 23.
PHS Constant definitions
Channel Update

   8FA7 56                  755 	rorb
   8FA8 ED 81               756 	std	,x++
   8FAA 6A E4               757 	dec	,s
   8FAC 26 F4               758 	bne	21$
   8FAE 32 61               759 	leas	1,s		; pop temporary
                            760 
                            761 	; end of sample update
                            762 
   8FB0 B6 37 27            763 22$:	lda	upd$cntr	; update the sample counter
   8FB3 4C                  764 	inca			; next sample
   8FB4 84 3F               765 	anda	#0x3F		; mod 64
   8FB6 B7 37 27            766 	sta	upd$cntr	; and save
   8FB9 26 67               767 	bne	24$		; not finished - exit
                            768 
                            769 	; divide upd$sum by 64
                            770 
   8FBB FC 37 30            771 	ldd	upd$sum		; get sum
   8FBE 59                  772 	rolb			; divide by 64
   8FBF 49                  773 	rola
   8FC0 59                  774 	rolb
   8FC1 49                  775 	rola
   8FC2 59                  776 	rolb
   8FC3 1E 89               777 	exg	a,b
   8FC5 84 03               778 	anda	#0x03
   8FC7 ED A9 00 04         779 	std	phs$avrg,y	; save average pulse height
                            780 
                            781 	; update the response array and the running average
                            782 
   8FCB 30 C9 00 80         783 	leax	acq$avrg,u	; averaged spectrum address
   8FCF A6 A9 00 02         784 	lda	acq$index,y	; current index into response array
   8FD3 30 86               785 	leax	a,x		; response spectrum address
   8FD5 30 86               786 	leax	a,x
   8FD7 EC A9 00 00         787 	ldd	acq$sum,y	; get sum
   8FDB A3 84               788 	subd	,x		; subtract oldest
   8FDD E3 A9 00 04         789 	addd	phs$avrg,y	; add new response
   8FE1 ED A9 00 00         790 	std	acq$sum,y	; and save
   8FE5 EC A9 00 04         791 	ldd	phs$avrg,y	; get new response
   8FE9 ED 84               792 	std	,x		; save in array
                            793 
                            794 	; update the index
                            795 
   8FEB A6 A9 00 02         796 	lda	acq$index,y	; current index into response array
   8FEF 4C                  797 	inca			; update index
   8FF0 84 3F               798 	anda	#0x3F
   8FF2 A7 A9 00 02         799 	sta	acq$index,y
   8FF6 26 1A               800 	bne	23$
                            801 
                            802 	; update High Voltage
                            803 
   8FF8 BD 90 2D            804 	jsr	phs$comp
                            805 
                            806 	; after first 64 scans set final calibration value
                            807 
   8FFB EC A9 00 24         808 	ldd	phs$lpht,y	; set ?
   8FFF 26 11               809 	bne	23$	
                            810 
ASxxxx Assembler V02.10  (Motorola 6809), page 24.
PHS Constant definitions
Channel Update

                            811 	; divide acq$sum by 64
                            812 
   9001 EC A9 00 00         813 	ldd	acq$sum,y	; get sum
   9005 59                  814 	rolb			; divide by 64
   9006 49                  815 	rola
   9007 59                  816 	rolb
   9008 49                  817 	rola
   9009 59                  818 	rolb
   900A 1E 89               819 	exg	a,b
   900C 84 03               820 	anda	#0x03
   900E ED A9 00 24         821 	std	phs$lpht,y	; save final pulse height calibration
                            822 
                            823 	; finished scanning this channel
                            824 
   9012 A6 A9 00 03         825 23$:	lda	acq$sts,y	; clear scan flag
   9016 84 FE               826 	anda	#~1
   9018 A7 A9 00 03         827 	sta	acq$sts,y
                            828 
   901C 7C 37 26            829 	inc	upd$chn
   901F 7F 37 25            830 	clr	upd$seq		; restart sequence
                            831 
   9022 35 70               832 24$:	puls	x,y,u		; restore registers
   9024 35 06               833 	puls	d
   9026 3B                  834 	rti
                            835 
   9027 BD 92 4D            836 25$:	jsr	abrt$upd
   902A 35 06               837 	puls	d		; restore register
   902C 3B                  838 	rti
                            839 
                            840 
ASxxxx Assembler V02.10  (Motorola 6809), page 25.
PHS Constant definitions
PHS -> High Voltage Update

                            842 	.sbttl	PHS -> High Voltage Update
                            843 
                            844 	; This routine compares the just completed pulse height
                            845 	; scan with the original calibration.
                            846 	;
                            847 	; The voltage is adjusted dlta$vlt volts / 1%
                            848 	; change in response.
                            849 	;
                            850 	; If the computed voltage change exceeds dlta$err volts then
                            851 	; the channel is flagged as failed and the PHS updating
                            852 	; is terminated.
                            853 	;
                            854 	; If the computed voltage change between dlta$min and dlta$err
                            855 	; volts then the HV4032A is updated to restore the
                            856 	; original calibration.
                            857 	;
                            858 
   902D                     859 phs$comp::
   902D EC A9 00 24         860 	ldd	phs$lpht,y	; calibration
   9031 FD 37 3E            861 	std	dsr
   9034 27 6F               862 	beq	5$		; calibration incomplete
                            863 
   9036 EC A9 00 00         864 	ldd	acq$sum,y	; get sum of acquisition array
   903A 59                  865 	rolb			; divide by 64
   903B 49                  866 	rola
   903C 59                  867 	rolb
   903D 49                  868 	rola
   903E 59                  869 	rolb
   903F 1E 89               870 	exg	a,b
   9041 84 03               871 	anda	#0x03
                            872 
   9043 7F 37 3B            873 	clr	dsign		; (-)
   9046 B3 37 3E            874 	subd	dsr		; -(cal - current)
   9049 2A 08               875 	bpl	1$
   904B 73 37 3B            876 	com	dsign		; (+)
   904E 43                  877 	coma
   904F 53                  878 	comb
   9050 C3 00 01            879 	addd	#1
   9053 FD 37 3C            880 1$:	std	dnd
   9056 73 37 3B            881 	com	dsign		; (+ <--> -)
                            882 
                            883 	; compute (cal - current)/cal to 8-bits
                            884 
   9059 86 08               885 	lda	#0d8		; bit counter
   905B B7 37 3A            886 	sta	divcnt
   905E FC 37 3C            887 	ldd	dnd		; get dividend
   9061 58                  888 	aslb			; initial shift
   9062 49                  889 	rola
   9063 B3 37 3E            890 2$:	subd	dsr		; subtract divisor
   9066 24 03               891 	bcc	3$		; if carry clear - good test
   9068 F3 37 3E            892 	addd	dsr		; else restore dividend
   906B 79 37 40            893 3$:	rol	qt		; shift in computed bit
   906E 58                  894 	aslb			; shift dnd
   906F 49                  895 	rola
   9070 7A 37 3A            896 	dec	divcnt		; 8 bits generated yet ?
   9073 26 EE               897 	bne	2$		; loop until done
ASxxxx Assembler V02.10  (Motorola 6809), page 26.
PHS Constant definitions
PHS -> High Voltage Update

   9075 73 37 40            898 	com	qt		; get true result
                            899 
                            900 	; Compute voltage change
                            901 
   9078 A6 A9 00 20         902 	lda	dlta$vlt,y	; 0 - 255  -->> 0 - 5.0 volts / %
   907C F6 37 40            903 	ldb	qt		; 0 - .996 -->> 0 - 100%
   907F 3D                  904 	mul
   9080 58                  905 	aslb			; *2
   9081 49                  906 	rola
   9082 25 22               907 	bcs	6$		; change greater than 256 volts
   9084 1F 89               908 	tfr	a,b		; integer change in b in volts
   9086 4F                  909 	clra
                            910 
                            911 	; Check for a change larger than error limit
                            912 
   9087 E1 A9 00 1F         913 	cmpb	dlta$err,y	; default is 25% / 64 volts
   908B 24 19               914 	bhis	6$		; yes - skip
                            915 
                            916 	; Check for a change less than minimum
                            917 
   908D E1 A9 00 1E         918 	cmpb	dlta$min,y	; default is 2% / 5 volts
   9091 25 12               919 	blo	5$		; yes - skip
                            920 
                            921 	; correct for sign
                            922 
   9093 7D 37 3B            923 	tst	dsign
   9096 27 05               924 	beq	4$
   9098 43                  925 	coma
   9099 53                  926 	comb
   909A C3 00 01            927 	addd	#1
                            928 
                            929 	; save HV change and flag it
                            930 
   909D ED A9 00 21         931 4$:	std	hv$chng,y	; save change
   90A1 6C A9 00 23         932 	inc	hv$qued,y	; queue it
   90A5 39                  933 5$:	rts			; finished
                            934 
                            935 	; PHS Channel Failure
                            936 
   90A6 86 02               937 6$:	lda	#$FAILED	; channel failed
   90A8 A7 A9 00 03         938 	sta	acq$sts,y
   90AC 39                  939 	rts			; finished
                            940 
                            941 
ASxxxx Assembler V02.10  (Motorola 6809), page 27.
PHS Constant definitions
PHS Update Value Initialization

                            943 	.sbttl	PHS Update Value Initialization
                            944 
   90AD                     945 phs$init::
   90AD 8E 77 41            946 	ldx	#acqvar		; variables
   90B0 86 20               947 	lda	#0d32		; entries
                            948 
   90B2 C6 05               949 1$:	ldb	#0d5		; default 5 volt minimum change
   90B4 E7 89 00 1E         950 	stb	dlta$min,x
   90B8 C6 40               951 	ldb	#0d64		; default 64 volt error change
   90BA E7 89 00 1F         952 	stb	dlta$err,x
   90BE C6 80               953 	ldb	#0d128		; default 2.5 volts / %
   90C0 E7 89 00 20         954 	stb	dlta$vlt,x
                            955 
   90C4 30 88 2C            956 	leax	ACQVARSZ,x
   90C7 4A                  957 	deca
   90C8 2E E8               958 	bgt	1$
   90CA 39                  959 	rts
                            960 
                            961 
ASxxxx Assembler V02.10  (Motorola 6809), page 28.
PHS Constant definitions
Temperature channel update

                            963 	.sbttl	Temperature channel update
                            964 
                            965 	.area	ACQDATA(REL,CON)
                            966 
   7CC1                     967 tmpbufr::
   7CC1                     968 		.blkb	TMPBUFSZ	; allocation for temperature buffers
   7DC1                     969 tmpvar::
   7DC1                     970 		.blkb	TMPVARSZ	; allocation for temperature variables
                            971 
                            972 
                            973 
                            974 	.area	ACQ(REL,CON)
                            975 
                            976 
                            977 	;  Temperature update code:
                            978 	;
                            979 	;	 This code acquires 64 samples and averages the
                            980 	;	results to produce a representation of the current
                            981 	;	external temperature. The code maintains a list
                            982 	;	of the last 64 temperature readings.  Normally
                            983 	;	a 64 sample of the temperature requires about
                            984 	;	.5-.6 seconds.
                            985 	;
                            986 	;	 If the temperature status is not active then
                            987 	;	an initialization of the temperature arrays is
                            988 	;	performed and the status is made active.  If the
                            989 	;	temperature sensor appears to be disconnected then
                            990 	;	the temperature updating flag is cleared.
                            991 
   90CB                     992 temp$upd::
   90CB B6 37 25            993 	lda	upd$seq
   90CE 26 0F               994 	bne	1$
                            995 
                            996 ;state0
   90D0 CC 00 00            997 	ldd	#0
   90D3 B7 37 27            998 	sta	upd$cntr	; clear the counter
   90D6 FD 37 30            999 	std	upd$sum		; clear the sum
   90D9 7C 37 25           1000 	inc	upd$seq		; next sequence immediately
   90DC B6 37 25           1001 	lda	upd$seq
                           1002 
   90DF 81 01              1003 1$:	cmpa	#1		; state1 ?
   90E1 26 0C              1004 	bne	2$
                           1005 
                           1006 ;state1
   90E3 CC 90 F3           1007 	ldd	#3$		; load FIRQ address
   90E6 FD 37 08           1008 	std	exfirq
   90E9 86 20              1009 	lda	#0x20		; select temperature with out sampling
   90EB B7 7F 04           1010 	sta	acq$slct	; start acquisition
   90EE 39                 1011 	rts
                           1012 
                           1013 ;state - invalid
   90EF 7F 37 25           1014 2$:	clr	upd$seq
   90F2 39                 1015 	rts
                           1016 
                           1017 ;firqseq1
   90F3 34 06              1018 3$:	pshs	d		; save register
ASxxxx Assembler V02.10  (Motorola 6809), page 29.
PHS Constant definitions
Temperature channel update

   90F5 FC 7F 06           1019 	ldd	acq$adc		; get background data
   90F8 1E 89              1020 	exg	a,b		; oops !
   90FA FD 37 2C           1021 	std	upd$back	; save background
   90FD 10 2B 01 46        1022 	lbmi	17$		; acquisition inhibitted
   9101 CC 91 0F           1023 	ldd	#4$		; load FIRQ address
   9104 FD 37 08           1024 	std	exfirq
   9107 86 30              1025 	lda	#0x30		; temperature select with sampling
   9109 B7 7F 04           1026 	sta	acq$slct	; start acquisition
   910C 35 06              1027 	puls	d
   910E 3B                 1028 	rti
                           1029 
                           1030 ;firqseq2
   910F 34 06              1031 4$:	pshs	d		; save register
   9111 FC 7F 06           1032 	ldd	acq$adc		; get data sample
   9114 1E 89              1033 	exg	a,b		; oops !
   9116 FD 37 2E           1034 	std	upd$smpl	; save data
   9119 10 2B 01 2A        1035 	lbmi	17$		; acquisition inhibitted
   911D B3 37 2C           1036 	subd	upd$back	; subtract background
   9120 2A 03              1037 	bpl	5$		; only upd$smpl-upd$back > 0 accepted
   9122 CC 00 00           1038 	ldd	#0
   9125 10 83 03 9A        1039 5$:	cmpd	#0d922		; > .90 * Full Scale ?
   9129 10 22 00 F6        1040 	lbhi	14$		; yes - stop temperature acquisition
   912D F3 37 30           1041 	addd	upd$sum		; add to sum
   9130 FD 37 30           1042 	std	upd$sum
                           1043 
   9133 34 70              1044 	pshs	x,y,u		; save registers
   9135 CE 7C C1           1045 	ldu	#tmpbufr	; get temperature buffer pointer
   9138 10 8E 7D C1        1046 	ldy	#tmpvar		; get temperature variable pointer
                           1047 
                           1048 	; update the temperature pulse height histogram
                           1049 
   913C E6 A9 00 09        1050 	ldb	phs$hscl,y	; get the display range
   9140 C1 04              1051 	cmpb	#0d4		; 0 - 1024, 1 - 512, 2 - 256, 3 - 128, 4 -64
   9142 23 01              1052 	blos	6$
   9144 5F                 1053 	clrb
   9145 30 8C 16           1054 6$:	leax	8$,pcr		; compute entry
   9148 58                 1055 	aslb
   9149 30 85              1056 	leax	b,x
   914B FC 37 2E           1057 	ldd	upd$smpl	; get sample
   914E B3 37 2C           1058 	subd	upd$back	; subtract background
   9151 2A 03              1059 	bpl	7$		; only upd$smpl-upd$back > 0 accepted
   9153 CC 00 00           1060 	ldd	#0
   9156 A3 A9 00 07        1061 7$:	subd	phs$hofs,y	; start from this point
   915A 2B 36              1062 	bmi	10$		; out of range - skip
   915C 6E 84              1063 	jmp	,x		; go to proper entry
   915E 47                 1064 8$:	asra			; 1024 range
   915F 56                 1065 	rorb
   9160 47                 1066 	asra			; 512 range
   9161 56                 1067 	rorb
   9162 47                 1068 	asra			; 256 range
   9163 56                 1069 	rorb
   9164 47                 1070 	asra			; 128 range
   9165 56                 1071 	rorb
   9166 10 83 00 3F        1072 	cmpd	#0x3F		; 64 range
   916A 22 26              1073 	bhi	10$		; out of range - skip
   916C 58                 1074 	aslb			; *2
ASxxxx Assembler V02.10  (Motorola 6809), page 30.
PHS Constant definitions
Temperature channel update

   916D 30 C9 00 00        1075 	leax	acq$phs,u	; pulse height spectrum address
   9171 30 85              1076 	leax	b,x		; channel address
   9173 EC 84              1077 	ldd	,x		; increment channel
   9175 C3 00 01           1078 	addd	#1
   9178 ED 84              1079 	std	,x
   917A 2A 16              1080 	bpl	10$		; skip rescale if no overflow
                           1081 
                           1082 	; rescale histogram array
                           1083 
   917C 86 40              1084 	lda	#0d64		; length of array
   917E A7 E2              1085 	sta	,-s
   9180 30 C9 00 00        1086 	leax	acq$phs,u	; pulse height spectrum address
   9184 EC 84              1087 9$:	ldd	,x		; divide array by 2
   9186 1C FE              1088 	clc
   9188 46                 1089 	rora
   9189 56                 1090 	rorb
   918A ED 81              1091 	std	,x++
   918C 6A E4              1092 	dec	,s
   918E 26 F4              1093 	bne	9$
   9190 32 61              1094 	leas	1,s		; pop temporary
                           1095 
                           1096 	; end of sample update
                           1097 
   9192 B6 37 27           1098 10$:	lda	upd$cntr	; update the sample counter
   9195 4C                 1099 	inca			; next sample
   9196 84 3F              1100 	anda	#0x3F		; mod 64
   9198 B7 37 27           1101 	sta	upd$cntr	; and save
   919B 10 26 00 A3        1102 	lbne	16$		; not finished - exit
                           1103 
                           1104 	; divide upd$sum by 64
                           1105 
   919F FC 37 30           1106 	ldd	upd$sum		; get sum
   91A2 59                 1107 	rolb			; divide by 64
   91A3 49                 1108 	rola
   91A4 59                 1109 	rolb
   91A5 49                 1110 	rola
   91A6 59                 1111 	rolb
   91A7 1E 89              1112 	exg	a,b
   91A9 84 03              1113 	anda	#0x03
   91AB ED A9 00 04        1114 	std	phs$avrg,y	; save average pulse height
                           1115 
   91AF A6 A9 00 03        1116 	lda	acq$sts,y
   91B3 85 08              1117 	bita	#$ACTIVE	; active ?
   91B5 26 43              1118 	bne	13$		; yes - skip
                           1119 
                           1120 	; initialize the arrays
                           1121 
   91B7 34 40              1122 	pshs	u		; save buffer address
   91B9 33 C9 00 80        1123 	leau	acq$phs+0d128,u	; end of histogram buffer + 1
   91BD 86 80              1124 	lda	#0d128		; buffer length
   91BF 6F C2              1125 11$:	clr	,-u		; clear array
   91C1 4A                 1126 	deca
   91C2 2E FB              1127 	bgt	11$
   91C4 35 40              1128 	puls	u		; restore buffer address
                           1129 
   91C6 34 40              1130 	pshs	u		; save address
ASxxxx Assembler V02.10  (Motorola 6809), page 31.
PHS Constant definitions
Temperature channel update

   91C8 33 C9 00 80        1131 	leau	acq$avrg,u	; array of averages
   91CC AE A9 00 04        1132 	ldx	phs$avrg,y	; average of 64. samples
   91D0 86 40              1133 	lda	#0d64		; buffer length
   91D2 AF C1              1134 12$:	stx	,u++		; load the array
   91D4 4A                 1135 	deca
   91D5 2E FB              1136 	bgt	12$
   91D7 35 40              1137 	puls	u		; restore address
                           1138 
   91D9 EC A9 00 04        1139 	ldd	phs$avrg,y
   91DD 47                 1140 	asra
   91DE 56                 1141 	rorb
   91DF 46                 1142 	rora
   91E0 56                 1143 	rorb
   91E1 46                 1144 	rora
   91E2 1E 89              1145 	exg	a,b		; 64. * phs$avrg
   91E4 ED A9 00 00        1146 	std	acq$sum,y	; save result
                           1147 
   91E8 6F A9 00 02        1148 	clr	acq$index,y	; clear the index
                           1149 
                           1150 	; Activate Channel
                           1151 
   91EC 86 08              1152 	lda	#$ACTIVE	; active
   91EE A7 A9 00 03        1153 	sta	acq$sts,y
   91F2 C6 08              1154 	ldb	#$ACTIVE	; enable temperature updating
   91F4 E7 A9 00 11        1155 	stb	tmp$flag,y
   91F8 20 3B              1156 	bra	15$
                           1157 
                           1158 	; update the response array and the running average
                           1159 
   91FA 30 C9 00 80        1160 13$:	leax	acq$avrg,u	; averaged spectrum address
   91FE A6 A9 00 02        1161 	lda	acq$index,y	; current index into response array
   9202 30 86              1162 	leax	a,x		; response spectrum address
   9204 30 86              1163 	leax	a,x
   9206 4C                 1164 	inca			; update index
   9207 84 3F              1165 	anda	#0x3F
   9209 A7 A9 00 02        1166 	sta	acq$index,y
   920D EC A9 00 00        1167 	ldd	acq$sum,y	; get sum
   9211 A3 84              1168 	subd	,x		; subtract oldest
   9213 E3 A9 00 04        1169 	addd	phs$avrg,y	; add new response
   9217 ED A9 00 00        1170 	std	acq$sum,y	; and save
   921B EC A9 00 04        1171 	ldd	phs$avrg,y	; get new response
   921F ED 84              1172 	std	,x		; save in array
   9221 20 12              1173 	bra	15$
                           1174 
                           1175 	; Sensor Disconnected
                           1176 
   9223 34 70              1177 14$:	pshs	x,y,u		; save registers
   9225 10 8E 7D C1        1178 	ldy	#tmpvar		; get temperature variable pointer
                           1179 
   9229 86 02              1180 	lda	#$FAILED	; FAILED
   922B A7 A9 00 03        1181 	sta	acq$sts,y
   922F C6 00              1182 	ldb	#$STOP		; disable temperature updating
   9231 E7 A9 00 11        1183 	stb	tmp$flag,y
                           1184 
   9235 E6 A9 00 11        1185 15$:	ldb	tmp$flag,y	; copy to upd$temp
   9239 F7 37 34           1186 	stb	upd$temp	; temperature updated
ASxxxx Assembler V02.10  (Motorola 6809), page 32.
PHS Constant definitions
Temperature channel update

   923C 7F 37 25           1187 	clr	upd$seq		; restart sequence
   923F 7F 37 26           1188 	clr	upd$chn		; and start with channel 0
                           1189 
   9242 35 70              1190 16$:	puls	x,y,u		; restore registers
   9244 35 06              1191 	puls	d
   9246 3B                 1192 	rti
                           1193 
   9247 BD 92 4D           1194 17$:	jsr	abrt$upd
   924A 35 06              1195 	puls	d		; restore register
   924C 3B                 1196 	rti
                           1197 
                           1198 
ASxxxx Assembler V02.10  (Motorola 6809), page 33.
PHS Constant definitions
Acquisition Abort

                           1200 	.sbttl	Acquisition Abort
                           1201 
                           1202 	;    Abort acquisition by resetting the 'firq' vector
                           1203 
   924D                    1204 abrt$upd::
   924D CC 92 54           1205 	ldd	#1$		; load abort FIRQ address	
   9250 FD 37 08           1206 	std	exfirq
   9253 39                 1207 	rts
                           1208 
                           1209 ;firqabort
   9254 7D 7F 06           1210 1$:	tst	acq$adc		; clear FIRQ request
   9257 3B                 1211 	rti
                           1212 
                           1213 
ASxxxx Assembler V02.10  (Motorola 6809), page 34.
PHS Constant definitions
LED Drive Temperature Compensation

                           1215 	.sbttl	LED Drive Temperature Compensation
                           1216 
                           1217 	; The correction for temperature is .5% per degree C.
                           1218 	;
                           1219 	; The temperature channel calibration is 20 counts per degree C.
                           1220 	;
                           1221 	; DELC = current temperature - tmp$lpht
                           1222 	;
                           1223 	; DEL ~ .005 * DELC * cal$lpht
                           1224 	;
                           1225 	; cor$lpht = cal$lpht + DEL
                           1226 
   9258                    1227 led$comp::
   9258 34 16              1228 	pshs	d,x
                           1229 
   925A 7D 37 34           1230 	tst	upd$temp	; temperature updated ?
   925D 10 27 00 9B        1231 	lbeq	9$		; no - skip updates
                           1232 
   9261 8E 7D C1           1233 	ldx	#tmpvar		; temperature variables
   9264 6D 89 00 11        1234 	tst	tmp$flag,x	; active ?
   9268 10 27 00 90        1235 	lbeq	9$		; no - skip updates
                           1236 
                           1237 	; Create a stack frame for updating
                           1238 
   926C EC 89 00 00        1239 	ldd	acq$sum,x	; get sum of temperature array
   9270 59                 1240 	rolb			; divide by 64
   9271 49                 1241 	rola
   9272 59                 1242 	rolb
   9273 49                 1243 	rola
   9274 59                 1244 	rolb
   9275 1E 89              1245 	exg	a,b
   9277 84 03              1246 	anda	#0x03
   9279 ED E3              1247 	std	,--s		; current temperature
                           1248 
   927B 32 76              1249 	leas	-0d10,s		; temporaries
                           1250 
                           1251 	; temporary definitions
                           1252 
                    0000   1253 	$DELC	=	0d0	; Absolute Change in temperature
                    0000   1254 	$DELCH	=	0d0
                    0001   1255 	$DELCL	=	0d1
                    0002   1256 	$LDRV	=	0d2	; LED Drive Calibration Value
                    0002   1257 	$LDRVH	=	0d2
                    0003   1258 	$LDRVL	=	0d3
                    0004   1259 	$32BT0	=	0d4	; msb of 32-bit result
                    0005   1260 	$32BT1	=	0d5
                    0006   1261 	$32BT2	=	0d6
                    0007   1262 	$32BT3	=	0d7	; lsb of 32-bit result
                    0008   1263 	$DELSGN	=	0d8	; sign of temperature change
                    0009   1264 	$CNTR	=	0d9	; loop counter
                    000A   1265 	$CURTMP	=	0d10	; current temperature
                           1266 
   927D 8E 77 41           1267 	ldx	#acqvar		; variables
   9280 86 20              1268 	lda	#0d32		; counter
   9282 A7 69              1269 	sta	$CNTR,s
                           1270 
ASxxxx Assembler V02.10  (Motorola 6809), page 35.
PHS Constant definitions
LED Drive Temperature Compensation

   9284 6D 89 00 11        1271 1$:	tst	tmp$flag,x	; active ?
   9288 27 69              1272 	beq	8$		; no - skip this channel
                           1273 
                           1274 	; Calculate temperature change DELC
                           1275 
   928A 6F 68              1276 	clr	$DELSGN,s	; assume +
   928C EC 6A              1277 	ldd	$CURTMP,s	; current temperature
   928E A3 89 00 28        1278 	subd	tmp$lpht,x	; - calibration temperature
   9292 2A 08              1279 	bpl	2$		; + ok
   9294 6C 68              1280 	inc	$DELSGN,s	; else -
   9296 EC 89 00 28        1281 	ldd	tmp$lpht,x
   929A A3 6A              1282 	subd	$CURTMP,s
                           1283 
                           1284 	; Do .005 * DELC with scaling
                           1285 
   929C 58                 1286 2$:	aslb			; .005/20 == .00025
   929D 49                 1287 	rola			; scaling method
   929E 58                 1288 	aslb			; 1.0     -->> 65536
   929F 49                 1289 	rola			; .005/20 -->> 16
   92A0 58                 1290 	aslb			; thus
   92A1 49                 1291 	rola			; DELC * 16
   92A2 58                 1292 	aslb
   92A3 49                 1293 	rola
   92A4 ED 60              1294 	std	$DELC,s		; save temperature change
                           1295 
                           1296 	; Copy LED calibration value cal$lpht
                           1297 
   92A6 EC 89 00 26        1298 	ldd	cal$lpht,x
   92AA ED 62              1299 	std	$LDRV,s
                           1300 
                           1301 	; Do 32-bit multiplication
                           1302 
   92AC A6 61              1303 	lda	$DELCL,s	; lsb * lsb
   92AE E6 63              1304 	ldb	$LDRVL,s
   92B0 3D                 1305 	mul
   92B1 ED 66              1306 	std	$32BT2,s
                           1307 
   92B3 A6 60              1308 	lda	$DELCH,s	; msb * msb
   92B5 E6 62              1309 	ldb	$LDRVH,s
   92B7 3D                 1310 	mul
   92B8 ED 64              1311 	std	$32BT0,s
                           1312 	
   92BA A6 61              1313 	lda	$DELCL,s	; lsb * msb
   92BC E6 62              1314 	ldb	$LDRVH,s
   92BE 3D                 1315 	mul
   92BF E3 65              1316 	addd	$32BT1,s
   92C1 ED 65              1317 	std	$32BT1,s
   92C3 24 02              1318 	bcc	3$
   92C5 6C 64              1319 	inc	$32BT0,s
                           1320 
   92C7 A6 60              1321 3$:	lda	$DELCH,s	; msb * lsb
   92C9 E6 63              1322 	ldb	$LDRVL,s
   92CB 3D                 1323 	mul
   92CC E3 65              1324 	addd	$32BT1,s
   92CE ED 65              1325 	std	$32BT1,s
   92D0 24 02              1326 	bcc	4$
ASxxxx Assembler V02.10  (Motorola 6809), page 36.
PHS Constant definitions
LED Drive Temperature Compensation

   92D2 6C 64              1327 	inc	$32BT0,s
                           1328 
   92D4 EC 64              1329 4$:	ldd	$32BT0,s	; correction in DAC units
   92D6 6D 68              1330 	tst	$DELSGN,s	; +
   92D8 27 05              1331 	beq	5$		; yes - skip
   92DA 43                 1332 	coma			; -
   92DB 53                 1333 	comb
   92DC C3 00 01           1334 	addd	#1
   92DF E3 62              1335 5$:	addd	$LDRV,s
   92E1 2A 03              1336 	bpl	6$		; underflow not allowed
   92E3 CC 00 00           1337 	ldd	#0
   92E6 10 83 0F FF        1338 6$:	cmpd	#0d4095		; overflow  not allowed
   92EA 23 03              1339 	blos	7$
   92EC CC 0F FF           1340 	ldd	#0d4095
   92EF ED 89 00 2A        1341 7$:	std	cor$lpht,x	; corrected LED Drive level
                           1342 
   92F3 30 88 2C           1343 8$:	leax	ACQVARSZ,x
   92F6 6A 69              1344 	dec	$CNTR,s
   92F8 26 8A              1345 	bne	1$
                           1346 
   92FA 32 6C              1347 	leas	0d12,s
                           1348 
   92FC 35 16              1349 9$:	puls	d,x
   92FE 39                 1350 	rts
                           1351 
