	.module again.c
	.dbfile again.c
	.area text
;  IX -> 0,x
_SCI_isr::
	.dbfile C:\ICCTJP\include/isrdecl.h
	.dbfunc SCI_isr
	.dbline 41
; ///////////////////////////////////////////////////////////
; //	Program:		again.c
; //	Description:	Another test program
; //	Programmer:		Scott Nortman
; //	Date:			3/24/00
; ///////////////////////////////////////////////////////////
; 
; /**************************** Constants *********************************/
; #define pulse_handler TOC2_isr
; #define TOLERANCE 10 
; #define valve_sensor analog(1)
; /**************************** End of Constants **************************/
; 
; /*************************** Interrupts *********************************/
; #pragma interrupt_handler TOC2_isr, RTI_isr, TOF_isr;
; /*************************** End of Interrupts **************************/
; 
; /************************** Includes ************************************/
; #include <tjpbase.h>
; #include <analog.h>
; #include <vectors.h>
; #include <mil.h>
; #include <hc11.h>
; /************************ End of includes *******************************/
; /************************** Global Variables*****************************/
; long duty_cycle;	//duty_cycle in e clocks
; long period;		//period in e clocks
; int desired;		
; long count = 0;	
; /************************ End of Global Variables ***********************/
; 
; /**************************** Main **************************************/
; void main(void)
; {
; 	
; 	/* VT100 clear screen */ 
; 	char clear[]= "\x1b\x5B\x32\x4A\x04"; 
; 	
; 	/* VT100 position cursor at (x,y) = (3,12) command is "\x1b[3;12H"*/
;   	char place[]= "\x1b[1;1H";	/*Home*/
;  
L2:
	rti
;  IX -> 0,x
_SPI_isr::
	.dbfunc SPI_isr
	.dbline 47
; 	//SET_BIT(TMSK2, 0x40);		//Enble RTI interrupt
; 	SET_BIT(TCTL1, 0x40);		//TOC2 toggle
; 	CLEAR_BIT(TCTL1, 0x80);  	//Enable toggle on TOC2
; 
; 	INTR_OFF();
; 	printf("%s", clear);  
L3:
	rti
;  IX -> 0,x
_PAIE_isr::
	.dbfunc PAIE_isr
	.dbline 53
;   	printf("%s", place);
;   	printf("Enter the desired period in e clocks / 1000:\n");
; 	period = (read_int() * 1000);
; 	TOC2 = 0;
; 	desired = 150;
; 	INTR_ON();
L4:
	rti
;  IX -> 0,x
_PAV_isr::
	.dbfunc PAV_isr
	.dbline 59
; 	
; 	while(1)
; 	{
; 		SET_BIT(TMSK1, 0x40);	//Enable TOC		
; 		if (desired < valve_sensor)
; 		{
L5:
	rti
;  IX -> 0,x
_TOC3_isr::
	.dbfunc TOC3_isr
	.dbline 89
; 			CLEAR_BIT(PORTA, 0x20);
; 		}
; 		else if (desired > valve_sensor) 
; 		{
; 			SET_BIT(PORTA, 0x20);
; 		}
; 		else if ((desired <= valve_sensor + TOLERANCE) && (desired >= valve_sensor - TOLERANCE))
; 		{
; 			CLEAR_BIT(TMSK1, 0x40);		//Disable TOC2
; 		}
; 		
; 	}/*End While*/
;   	
; }/*End Main*/
; 
; /**************************** End of Main *******************************/
; void pulse_handler()
; {
; 	TOC2 += (period / 2);		//Add period / 2
; 	CLEAR_FLAG(TFLG1, 0x40)		//Clear the interrupt flag
; }
; 
; void RTI_isr(void)
; {
; 	printf("%d\n", valve_sensor);
; 	count += 1;
; 	if (count >=500)
; 	{
; 		count = 0;
; 		if (desired == 150)
L6:
	rti
;  IX -> 0,x
_TIC3_isr::
	.dbfunc TIC3_isr
	.dbline 101
; 		{
; 			desired = 100;
; 		}
; 		
; 		else if (desired == 100)
; 		{
; 			desired = 150;
; 		}
; 	}
; 	CLEAR_FLAG(TFLG2, 0x40);
; }
; 
L7:
	rti
;  IX -> 0,x
_TIC2_isr::
	.dbfunc TIC2_isr
	.dbline 107
; void TOF_isr(void)
; {
; 	CLEAR_FLAG(TFLG1, 0x80);
; }
; }
; }
L8:
	rti
;  IX -> 0,x
_TIC1_isr::
	.dbfunc TIC1_isr
	.dbline 113
; }
; }
; }
; }
; }
; }
L9:
	rti
;  IX -> 0,x
_IRQ_isr::
	.dbfunc IRQ_isr
	.dbline 125
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
L10:
	rti
;  IX -> 0,x
_XIRQ_isr::
	.dbfunc XIRQ_isr
	.dbline 131
; }
; }
; }
; }
; }
; }
L11:
	rti
;  IX -> 0,x
_SWI_isr::
	.dbfunc SWI_isr
	.dbline 137
; }
; }
; }
; }
; }
; }
L12:
	rti
;  IX -> 0,x
_ILLOP_isr::
	.dbfunc ILLOP_isr
	.dbline 143
; }
; }
; }
; }
; }
; }
L13:
	rti
;  IX -> 0,x
_COP_isr::
	.dbfunc COP_isr
	.dbline 149
; }
; }
; }
; }
; }
; }
L14:
	rti
;  IX -> 0,x
_CLMON_isr::
	.dbfunc CLMON_isr
	.dbline 155
; }
; }
; }
; }
; }
; }
L15:
	rti
	.area data
_drew::
	.blkw 1
	.area idata
	.word _interrupt_vectors
	.area data
_count::
	.blkb 4
	.area idata
	.word 0,0
	.area text
L17:
	.byte 27,91,50,'J,4,0
L18:
	.byte 27,91,49,59,49,'H,0
;  lreg1 -> -4,x
;  lreg2 -> -8,x
;  IX -> 0,x
;  rMEM -> 2,x
;  func temp: 4,x - 10,x
;          place -> 11,x
;          clear -> 18,x
_main::
	jsr __enterb
	.byte 0x98
	.dbfile again.c
	.dbfunc main
	.dbline 37
	ldd 0,x
	addd #18
	ldy #L17
	pshx
	xgdx
	ldd #6
	jsr __asgnblk
	pulx
	.dbline 40
	ldd 0,x
	addd #11
	ldy #L18
	pshx
	xgdx
	ldd #7
	jsr __asgnblk
	pulx
	.dbline 43
	ldy #0x1020
	bset 0,y,#64
	.dbline 44
	ldy #0x1020
	bclr 0,y,#0x80
			sei

	.dbline 47
	ldd 0,x
	addd #18
	pshb
	psha
	ldd #L19
	jsr _printf
	puly
	.dbline 48
	ldd 0,x
	addd #11
	pshb
	psha
	ldd #L19
	jsr _printf
	puly
	.dbline 49
	ldd #L20
	jsr _printf
	.dbline 50
	jsr _read_int
	std 4,x
	ldd #1000
	ldy 4,x
	jsr __muli
	jsr __d2lreg
	ldy #_period
	jsr __lreg2y
	.dbline 51
	ldd #0
	std 0x1018
	.dbline 52
	ldd #150
	std _desired
			cli

	.dbline 53
	bra L22
L21:
	.dbline 57
	ldy #0x1022
	bset 0,y,#64
	.dbline 58
	ldd #1
	jsr _analog
	std 6,x
	ldd _desired
	cpd 6,x
	bge L24
	.dbline 60
	ldy #0x1000
	bclr 0,y,#0x20
	.dbline 61
	bra L25
L24:
	.dbline 62
	ldd #1
	jsr _analog
	std 8,x
	ldd _desired
	cpd 8,x
	ble L26
	.dbline 64
	ldy #0x1000
	bset 0,y,#32
	.dbline 65
	bra L27
L26:
	.dbline 66
	ldd #1
	jsr _analog
	addd #10
	std 2,x
	ldd _desired
	cpd 2,x
	bgt L28
	ldd #1
	jsr _analog
	subd #10
	std 2,x
	ldd _desired
	cpd 2,x
	blt L28
	.dbline 68
	ldy #0x1022
	bclr 0,y,#0x40
	.dbline 69
L28:
L27:
L25:
	.dbline 71
L22:
	.dbline 55
	bra L21
L16:
	xgdx
	addd #24
	xgdx
	txs
	pulx
	rts
;  lreg1 -> -4,x
;  lreg2 -> -8,x
;  IX -> 0,x
_TOC2_isr::
	jsr __enterb
	.byte 0x82
	.dbfunc TOC2_isr
	.dbline 78
	ldy #_period
	jsr __ly2reg
	ldy #L31
	jsr __ly2reg2
	jsr __ldiv
	jsr __lregmov
	; vol
	ldd 0x1018
	jsr __ud2lreg
	jsr __ladd
	jsr __lreg2d
	std 0x1018
	.dbline 79
	ldy #0x1023
	bclr 0,y,#0xbf
	.dbline 80
L30:
	inx
	inx
	txs
	pulx
	rti
;  lreg1 -> -4,x
;  lreg2 -> -8,x
;  IX -> 0,x
_RTI_isr::
	jsr __enterb
	.byte 0x82
	.dbfunc RTI_isr
	.dbline 84
	ldd #1
	jsr _analog
	pshb
	psha
	ldd #L33
	jsr _printf
	puly
	.dbline 85
	ldy #_count
	jsr __ly2reg
	ldy #L34
	jsr __ly2reg2
	jsr __ladd
	ldy #_count
	jsr __lreg2y
	.dbline 86
	ldy #_count
	jsr __ly2reg
	ldy #L37
	jsr __ly2reg2
	jsr __lcmp
	blt L35
	.dbline 88
	ldy #L38
	jsr __ly2reg
	ldy #_count
	jsr __lreg2y
	.dbline 89
	ldd _desired
	cpd #150
	bne L39
	.dbline 91
	ldd #100
	std _desired
	.dbline 92
	bra L40
L39:
	.dbline 94
	ldd _desired
	cpd #100
	bne L41
	.dbline 96
	ldd #150
	std _desired
	.dbline 97
L41:
L40:
	.dbline 98
L35:
	.dbline 99
	ldy #0x1025
	bclr 0,y,#0xbf
	.dbline 100
L32:
	inx
	inx
	txs
	pulx
	rti
;  IX -> 0,x
_TOF_isr::
	.dbfunc TOF_isr
	.dbline 104
	ldy #0x1023
	bclr 0,y,#0x7f
	.dbline 105
L43:
	rti
	.area bss
_desired::
	.blkb 2
_period::
	.blkb 4
_duty_cycle::
	.blkb 4
_timertjp::
	.blkb 2
_days::
	.blkb 2
_hours::
	.blkb 2
_minutes::
	.blkb 2
_seconds::
	.blkb 2
_msec::
	.blkb 2
	.area text
L38:
	.word 0,0
L37:
	.word 0,500
L34:
	.word 0,1
L33:
	.byte 37,'d,10,0
L31:
	.word 0,2
L20:
	.byte 'E,'n,'t,'e,'r,32,'t,'h,'e,32,'d,'e,'s,'i,'r,'e
	.byte 'd,32,'p,'e,'r,'i,'o,'d,32,'i,'n,32,'e,32,'c,'l
	.byte 'o,'c,'k,'s,32,47,32,49,48,48,48,58,10,0
L19:
	.byte 37,'s,0
