$NOMACRO
$SEGMENTED CASE MOD167
;
; '..\RAM\INC\INT.SRC' GENERATED FROM INPUT FILE '..\RAM\INC\INT.C'
; COMPILER INVOKED BY:
;	C:\C166\BIN\C166.EXE ..\RAM\INC\INT.C MOD167 NOINIT LARGE FLOAT64 SYMBOLS CODE PREPRINT SRC
;
$MODINF (55)
		 NAME INT

         CC19IC  DEFR  0F166H
         CC28IC  DEFR  0F178H
        BUSCON1  DEFR  0FF14H
         CC18IC  DEFR  0F164H
         CC27IC  DEFR  0F176H
        BUSCON0  DEFR  0FF0CH
         CC17IC  DEFR  0F162H
         CC26IC  DEFR  0F174H
         CC16IC  DEFR  0F160H
         CC25IC  DEFR  0F172H
            PSW  DEFR  0FF10H
         CC15IC  DEFR  0FF96H
         CC24IC  DEFR  0F170H
         CC14IC  DEFR  0FF94H
         CC23IC  DEFR  0F16EH
         CC13IC  DEFR  0FF92H
         CC22IC  DEFR  0F16CH
         CC31IC  DEFR  0F194H
         CC12IC  DEFR  0FF90H
         CC21IC  DEFR  0F16AH
         CC30IC  DEFR  0F18CH
         CC11IC  DEFR  0FF8EH
         CC20IC  DEFR  0F168H
         CC10IC  DEFR  0FF8CH
            TFR  DEFR  0FFACH
          T6CON  DEFR  0FF48H
          T5CON  DEFR  0FF46H
          T4CON  DEFR  0FF44H
          T3CON  DEFR  0FF42H
          XP3IC  DEFR  0F19EH
          T2CON  DEFR  0FF40H
          XP2IC  DEFR  0F196H
          ADCON  DEFR  0FFA0H
          XP1IC  DEFR  0F18EH
          XP0IC  DEFR  0F186H
          S0CON  DEFR  0FFB0H
          S0TIC  DEFR  0FF6CH
          S0RIC  DEFR  0FF6EH
         SYSCON  DEFR  0FF12H
          ADEIC  DEFR  0FF9AH
          ADCIC  DEFR  0FF98H
          S0EIC  DEFR  0FF70H
            MDC  DEFR  0FF0EH
         WDTCON  DEFR  0FFAEH
          CC9IC  DEFR  0FF8AH
            DP8  DEFR  0FFD6H
          CC8IC  DEFR  0FF88H
            DP7  DEFR  0FFD2H
         SSCTIC  DEFR  0FF72H
         SSCCON  DEFR  0FFB2H
          CC7IC  DEFR  0FF86H
          CC6IC  DEFR  0FF84H
         SSCRIC  DEFR  0FF74H
          CC5IC  DEFR  0FF82H
          CC4IC  DEFR  0FF80H
            DP3  DEFR  0FFC6H
          CC3IC  DEFR  0FF7EH
            DP2  DEFR  0FFC2H
          CC2IC  DEFR  0FF7CH
          CC1IC  DEFR  0FF7AH
          CC0IC  DEFR  0FF78H
         SSCEIC  DEFR  0FF76H
         S0TBUF  DEFR  0FEB0H
         S0RBUF  DEFR  0FEB2H
           ISNC  DEFR  0F1DEH
         S0TBIC  DEFR  0F19CH
         T78CON  DEFR  0FF20H
           CRIC  DEFR  0FF6AH
           T8IC  DEFR  0F17CH
           T7IC  DEFR  0F17AH
         T01CON  DEFR  0FF50H
           T6IC  DEFR  0FF68H
           T5IC  DEFR  0FF66H
           T4IC  DEFR  0FF64H
           T3IC  DEFR  0FF62H
           T2IC  DEFR  0FF60H
           T1IC  DEFR  0FF9EH
           T0IC  DEFR  0FF9CH
           S0BG  DEFR  0FEB4H
           CCM7  DEFR  0FF28H
           CCM6  DEFR  0FF26H
           CCM5  DEFR  0FF24H
           CCM4  DEFR  0FF22H
             T4  DEFR  0FE44H
        PWMCON1  DEFR  0FF32H
           CCM3  DEFR  0FF58H
             T3  DEFR  0FE42H
        PWMCON0  DEFR  0FF30H
           CCM2  DEFR  0FF56H
           CCM1  DEFR  0FF54H
             P5  DEFR  0FFA2H
           CCM0  DEFR  0FF52H
             P3  DEFR  0FFC4H
             P2  DEFR  0FFC0H
          PWMIC  DEFR  0F17EH
        BUSCON4  DEFR  0FF1AH
        BUSCON3  DEFR  0FF18H
         CC29IC  DEFR  0F184H
        BUSCON2  DEFR  0FF16H
           DTxD  BIT   DP3.10
           DRxD  BIT   DP3.11
            TxD  BIT   P3.10

          NDATA  DGROUP  ?ND?INT
          SDATA  DGROUP  ?ID?INT,SYSTEM

                 ASSUME  DPP2 : NDATA
                 ASSUME  DPP3 : SDATA

        ?ND?INT  SECTION  DATA WORD 'NDATA'
     seroutflag  DSW  1
         PUBLIC  seroutflag
      serinflag  DSW  1
         PUBLIC  serinflag
    seroutbufct  DSW  1
         PUBLIC  seroutbufct
     serinbufct  DSW  1
         PUBLIC  serinbufct
        ?ND?INT  ENDS

        ?FD?INT  SECTION  DATA WORD 'FDATA'
      seroutbuf  DSB  132
         PUBLIC  seroutbuf
       serinbuf  DSB  132
         PUBLIC  serinbuf
        ?FD?INT  ENDS

        ?ID?INT  SECTION  DATA WORD 'IDATA'
        TIMER10  DSW  1
         PUBLIC  TIMER10
            DAY  DSW  1
         PUBLIC  DAY
         MINUTE  DSW  1
         PUBLIC  MINUTE
           HOUR  DSW  1
         PUBLIC  HOUR
         SECOND  DSW  1
         PUBLIC  SECOND
      THISMDAYS  DSW  1
         PUBLIC  THISMDAYS
           YEAR  DSW  1
         PUBLIC  YEAR
        MSECOND  DSW  1
         PUBLIC  MSECOND
          MONTH  DSW  1
         PUBLIC  MONTH
        ?ID?INT  ENDS


                 REGDEF   R0 - R15
      bankSORIC  REGBANK  R0 - R15
      bankSOTIC  REGBANK  R0 - R15
     TIMER_BANK  REGBANK  R0 - R15


        ?PR?INT  SECTION  CODE WORD 'FCODE'
; line 1: 
; line 2: #ifndef  _int_c_
; line 3: #define  _int_c_
; line 4: 
; line 5: #include "int.h"
; line 6: 
; line 7: #pragma SRC
; line 8: 
; line 9: 
; line 10: volatile int idata YEAR;
; line 11: volatile int idata MONTH;
; line 12: volatile int idata DAY;
; line 13: volatile int idata HOUR;
; line 14: volatile int idata MINUTE;
; line 15: volatile int idata SECOND;
; line 16: volatile int idata MSECOND;
; line 17: 
; line 18: volatile int idata TIMER10;
; line 19: volatile int idata THISMDAYS;
; line 20: 
; line 21: 
; line 22: 
; line 23: void init_serial(unsigned int baud)

	init_serial  PROC  FAR
	PUBLIC  init_serial
; FUNCTION init_serial (BEGIN  RMASK = @0x8000)
;---- Variable 'baud' assigned to Register 'R8' ----
; line 24: {
; line 25:     TxD = 1;
	BSET	TxD
; line 26:     DTxD = 1;
	BSET	DTxD
; line 27:     DRxD = 0;
	BCLR	DRxD
; line 28: 
; line 29:     S0RIC = 0x0a;
	MOV	S0RIC,#10
; line 30:     S0TIC = 0x0b;
	MOV	S0TIC,#11
; line 31: 
; line 32: 	serinbufct  = 0;
	MOV	WORD serinbufct,ZEROS
; line 33: 	serinflag   = 0;
	MOV	WORD serinflag,ZEROS
; line 34: 	seroutbufct = 0;
	MOV	WORD seroutbufct,ZEROS
; line 35: 	seroutflag  = 0;
	MOV	WORD seroutflag,ZEROS
; line 36: 
; line 37:     S0BG  = baud;
	MOV	S0BG,R8
; line 38:     S0CON = 0x8011;
	MOV	S0CON,#32785
; line 39: }
	RETS	
; FUNCTION init_serial (END    RMASK = @0x8000)
	init_serial  ENDP
; line 40: 
; line 41: 
; line 42: void deinit_serial( void )

	deinit_serial  PROC  FAR
	PUBLIC  deinit_serial
; FUNCTION deinit_serial (BEGIN  RMASK = @0x8000)
; line 43: {
; line 44: 	S0RIC 		= 0x0a;
	MOV	S0RIC,#10
; line 45: 	S0TIC 		= 0x0b;
	MOV	S0TIC,#11
; line 46: 	S0CON 		= 0;
	MOV	S0CON,#0
; line 47: 	serinflag	= 0;
	MOV	WORD serinflag,ZEROS
; line 48: 	seroutflag	= 0;
	MOV	WORD seroutflag,ZEROS
; line 49: }
	RETS	
; FUNCTION deinit_serial (END    RMASK = @0x8000)
	deinit_serial  ENDP
; line 50: 
; line 51: 
; line 52: void serial_receive( int wait )

	serial_receive  PROC  FAR
	PUBLIC  serial_receive
; FUNCTION serial_receive (BEGIN  RMASK = @0x0010)
;---- Variable 'wait' assigned to Register 'R8' ----
; line 53: {
; line 54: 
; line 55: 	while( serinflag == 1 ) {
; line 56: 		;
; line 57: 	}
?C0001:
	MOV	R4,WORD serinflag
	CMP	R4,#1
	JMP	cc_Z,?C0001
?C0002:
; line 58: 
; line 59: 	serinbufct = 0;
	MOV	WORD serinbufct,ZEROS
; line 60: 	serinflag  = 1;
	MOV	R4,#1
	MOV	WORD serinflag,R4
; line 61: 	S0RIC      = 0x4a;
	MOV	S0RIC,#74
; line 62: 	
; line 63: 	if( wait ){
	CMP	R8,#0
	JMP	cc_Z,?C0005
; line 64: 		while( serinflag < 2 ){
?C0009:
; line 65: 			;
; line 66: 		}
?C0006:
	MOV	R4,WORD serinflag
	CMP	R4,#2
	JMP	cc_ULT,?C0006
?C0007:
; line 67: 	}
?C0005:
	RETS	
; FUNCTION serial_receive (END    RMASK = @0x0010)
	serial_receive  ENDP
; line 68: }
; line 69: 
; line 70: 
; line 71: void serial_transmit( int wait )

	serial_transmit  PROC  FAR
	PUBLIC  serial_transmit
; FUNCTION serial_transmit (BEGIN  RMASK = @0x0010)
;---- Variable 'wait' assigned to Register 'R8' ----
; line 72: {
; line 73: 
; line 74: 	while( seroutflag == 1 ) {
; line 75: 		;
; line 76: 	}
?C0010:
	MOV	R4,WORD seroutflag
	CMP	R4,#1
	JMP	cc_Z,?C0010
?C0011:
; line 77: 	
; line 78: 	seroutbufct = 0;
	MOV	WORD seroutbufct,ZEROS
; line 79: 	seroutflag  = 1;
	MOV	R4,#1
	MOV	WORD seroutflag,R4
; line 80: 
; line 81: 	S0TIC       = 0x4b;
	MOV	S0TIC,#75
; line 82: 	S0TBUF      = seroutbuf[0];
	EXTP	#PAG (seroutbuf),#1
	MOVB	RL4,POF (seroutbuf)
	MOVBZ	R4,RL4
	MOV	S0TBUF,R4
; line 83: 	
; line 84: 	if( wait ){
	CMP	R8,#0
	JMP	cc_Z,?C0014
; line 85: 		while( seroutflag < 2 ){
?C0018:
; line 86: 			;
; line 87: 		}
?C0015:
	MOV	R4,WORD seroutflag
	CMP	R4,#2
	JMP	cc_ULT,?C0015
?C0016:
; line 88: 	}
?C0014:
	RETS	
; FUNCTION serial_transmit (END    RMASK = @0x0010)
	serial_transmit  ENDP
; line 89: }
; line 90: 
; line 91: 
; line 92: 
; line 93: 
; line 94: 
; line 95: unsigned char serinbuf[ SERIALMAXLENGTH + 2 ];
; line 96: unsigned int serinbufct;
; line 97: unsigned int serinflag;
; line 98: void ser_receive_int (void) interrupt SERIAL_RECEIVE_INT = 0x2B using bankSORIC {

	ser_receive_int  PROC  INTERRUPT SERIAL_RECEIVE_INT = 43 USING bankSORIC
	GLOBAL  ser_receive_int
; FUNCTION ser_receive_int (BEGIN  RMASK = @0x0070)
	SCXT	DPP3,#3
	NOP	
	MOV	bankSORIC,R0
	SCXT	CP,#bankSORIC
	NOP	
; line 99: 
; line 100: 	serinbuf[serinbufct] = S0RBUF;
	MOV	R4,S0RBUF
	MOVB	RL5,RL4
	MOV	R6,WORD serinbufct
	EXTP	#PAG (serinbuf),#2
	MOVB	[R6+#POF(serinbuf)],RL5
; line 101: 	
; line 102: 	if( ( serinbuf[serinbufct] < 0x20 ) || ( serinbufct >= SERIALMAXLENGTH ) ){
	MOVB	RL4,[R6+#POF(serinbuf)]
	CMPB	RL4,#32
	JMP	cc_ULT,?C0020
	CMP	R6,#130
	JMP	cc_ULT,?C0019
?C0020:
; line 103: 		S0RIC = 0x0a;
	MOV	S0RIC,#10
; line 104: 		serinbuf[serinbufct] = 0;
	MOVB	RL5,#0
	EXTP	#PAG (serinbuf),#1
	MOVB	[R6+#POF(serinbuf)],RL5
; line 105: 		serinbufct++;
	SUB	serinbufct,ONES
; line 106: 		serinflag = 2;
	MOV	R4,#2
	MOV	WORD serinflag,R4
; line 107: 	}
	JMP	cc_UC,?C0021
?C0019:
; line 108: 	else {
; line 109: 		serinbufct++;
	SUB	serinbufct,ONES
; line 110: 		serinflag = 1;
	MOV	R4,#1
	MOV	WORD serinflag,R4
; line 111: 	}
?C0021:
; line 112: 
; line 113: }
	POP	CP
	POP	DPP3
	RETI	
; FUNCTION ser_receive_int (END    RMASK = @0x0070)
	ser_receive_int  ENDP
; line 114: 
; line 115: 
; line 116: 
; line 117: unsigned char seroutbuf[ SERIALMAXLENGTH + 2 ];
; line 118: unsigned int seroutbufct;
; line 119: unsigned int seroutflag;
; line 120: void ser_transmit_int (void) interrupt SERIAL_TRANSMIT_INT = 0x2A using bankSOTIC {

	ser_transmit_int  PROC  INTERRUPT SERIAL_TRANSMIT_INT = 42 USING bankSOTIC
	GLOBAL  ser_transmit_int
; FUNCTION ser_transmit_int (BEGIN  RMASK = @0x0030)
	SCXT	DPP3,#3
	NOP	
	MOV	bankSOTIC,R0
	SCXT	CP,#bankSOTIC
	NOP	
; line 121: 
; line 122: 	if( ( seroutbuf[seroutbufct] < 0x20 ) || ( seroutbufct >= SERIALMAXLENGTH ) ){
	MOV	R5,WORD seroutbufct
	EXTP	#PAG (seroutbuf),#1
	MOVB	RL4,[R5+#POF(seroutbuf)]
	CMPB	RL4,#32
	JMP	cc_ULT,?C0023
	CMP	R5,#130
	JMP	cc_ULT,?C0022
?C0023:
; line 123: 		S0TIC = 0x0b;
	MOV	S0TIC,#11
; line 124: 		seroutflag = 2;
	MOV	R4,#2
	MOV	WORD seroutflag,R4
; line 125: 	}
	JMP	cc_UC,?C0024
?C0022:
; line 126: 	else {
; line 127: 		seroutbufct++;
	SUB	seroutbufct,ONES
; line 128: 		seroutflag = 1;
	MOV	R4,#1
	MOV	WORD seroutflag,R4
; line 129: 		S0TBUF = seroutbuf[seroutbufct];
	MOV	R4,WORD seroutbufct
	EXTP	#PAG (seroutbuf),#1
	MOVB	RL4,[R4+#POF(seroutbuf)]
	MOVBZ	R4,RL4
	MOV	S0TBUF,R4
; line 130: 	}
?C0024:
; line 131: 
; line 132: }
	POP	CP
	POP	DPP3
	RETI	
; FUNCTION ser_transmit_int (END    RMASK = @0x0030)
	ser_transmit_int  ENDP
; line 133: 
; line 134: 
; line 135: 
; line 136: void initTimerInt( void ) {

	initTimerInt  PROC  FAR
	PUBLIC  initTimerInt
; FUNCTION initTimerInt (BEGIN  RMASK = @0x8000)
; line 137: 	
; line 138: 	T3IC  = TIMERINTOFF;
	MOV	T3IC,#167
; line 139: 	T3CON = TIMERSTOP;
	MOV	T3CON,#1025
; line 140: 	T4CON = TIMERSET;
	MOV	T4CON,#39
; line 141: 	T4	  = TIMERRELOAD;
	MOV	T4,#65411
; line 142: 	T3	  = TIMERRELOAD;
	MOV	T3,#65411
; line 143: 
; line 144: }
	RETS	
; FUNCTION initTimerInt (END    RMASK = @0x8000)
	initTimerInt  ENDP
; line 145: 
; line 146: 
; line 147: void startTimerInt( void ) {

	startTimerInt  PROC  FAR
	PUBLIC  startTimerInt
; FUNCTION startTimerInt (BEGIN  RMASK = @0x8000)
; line 148: 
; line 149: 	TIMER10 = 0;
	MOV	WORD TIMER10,ZEROS
; line 150: 	T3		= TIMERRELOAD;
	MOV	T3,#65411
; line 151: 	T4		= TIMERRELOAD;
	MOV	T4,#65411
; line 152: 	T3CON	= TIMERSTART;
	MOV	T3CON,#1089
; line 153: 	T3IC	= TIMERINTON;
	MOV	T3IC,#231
; line 154: }
	RETS	
; FUNCTION startTimerInt (END    RMASK = @0x8000)
	startTimerInt  ENDP
; line 155: 
; line 156: 
; line 157: 
; line 158: 
; line 159: void stopTimerInt( void ) {

	stopTimerInt  PROC  FAR
	PUBLIC  stopTimerInt
; FUNCTION stopTimerInt (BEGIN  RMASK = @0x8000)
; line 160: 
; line 161: 	T3IC	= TIMERINTOFF;
	MOV	T3IC,#167
; line 162: 	T3CON	= TIMERSTOP;
	MOV	T3CON,#1025
; line 163: }
	RETS	
; FUNCTION stopTimerInt (END    RMASK = @0x8000)
	stopTimerInt  ENDP
; line 164: 
; line 165: 
; line 166: 
; line 167: #pragma ASM
; line 168: 
; line 169: ;P2	DEFR	0FFC0H
	;P2	DEFR	0FFC0H
; line 170: P7	DEFR	0FFD0H
	P7	DEFR	0FFD0H
; line 171: P8	DEFR	0FFD4H
	P8	DEFR	0FFD4H
; line 172: 
; line 173: #pragma ENDASM
; line 174: 
; line 175: 
; line 176: 
; line 177: //interrupt every 1/10000 second
; line 178: void timer_int (void) interrupt TIMER_INT = 0x23 using TIMER_BANK {

	timer_int  PROC  INTERRUPT TIMER_INT = 35 USING TIMER_BANK
	GLOBAL  timer_int
; FUNCTION timer_int (BEGIN  RMASK = @0x0010)
	SCXT	DPP3,#3
	NOP	
	MOV	TIMER_BANK,R0
	SCXT	CP,#TIMER_BANK
	NOP	
; line 179: 
; line 180: 	TIMER10++;
	SUB	TIMER10,ONES
; line 181: 
; line 182: 	if( TIMER10 >= 10 ){
	MOV	R4,WORD TIMER10
	CMP	R4,#10
	JMP	cc_SLT,?C0025
; line 183: 	
; line 184: 		TIMER10 = 0;
	MOV	WORD TIMER10,ZEROS
; line 185: 		MSECOND++;
	SUB	MSECOND,ONES
; line 186: 
; line 187: 		if( MSECOND >= 1000 ){
	MOV	R4,WORD MSECOND
	CMP	R4,#1000
	JMP	cc_SLT,?C0025
; line 188: 		
; line 189: 			MSECOND = 0;
	MOV	WORD MSECOND,ZEROS
; line 190: 			SECOND++;
	SUB	SECOND,ONES
; line 191: 			
; line 192: 			if( SECOND >= 60 ){
	MOV	R4,WORD SECOND
	CMP	R4,#60
	JMP	cc_SLT,?C0025
; line 193: 
; line 194: 				SECOND = 0;
	MOV	WORD SECOND,ZEROS
; line 195: 				MINUTE++;
	SUB	MINUTE,ONES
; line 196: 				
; line 197: 				if( MINUTE >= 60 ){
	MOV	R4,WORD MINUTE
	CMP	R4,#60
	JMP	cc_SLT,?C0025
; line 198: 
; line 199: 					MINUTE = 0;
	MOV	WORD MINUTE,ZEROS
; line 200: 					HOUR++;
	SUB	HOUR,ONES
; line 201: 					
; line 202: 					if( HOUR >= 24 ){
	MOV	R4,WORD HOUR
	CMP	R4,#24
	JMP	cc_SLT,?C0025
; line 203: 
; line 204: 						HOUR = 0;
	MOV	WORD HOUR,ZEROS
; line 205: 						DAY++;
	SUB	DAY,ONES
; line 206: 						
; line 207: 						if( DAY > THISMDAYS ) {
	MOV	R4,WORD THISMDAYS
	CMP	R4,WORD DAY
	JMP	cc_SGE,?C0025
; line 208: 						
; line 209: 							DAY = 1;
	MOV	R4,#1
	MOV	WORD DAY,R4
; line 210: 							MONTH++;
	SUB	MONTH,ONES
; line 211: 							
; line 212: 							if( MONTH > 12 ){
	MOV	R4,WORD MONTH
	CMP	R4,#12
	JMP	cc_SLE,?C0025
; line 213: 
; line 214: 								MONTH = 1;
	MOV	R4,#1
	MOV	WORD MONTH,R4
; line 215: 								YEAR++;							
	SUB	YEAR,ONES
; line 216: 							}
; line 217: 						}						
; line 218: 					}
; line 219: 				}
; line 220: 			}
; line 221: 		}
; line 222: 	}
?C0025:
; line 223: 
; line 224: 	
; line 225: 	/// so updating of date/time is down	
; line 226: 	/// here we do the other work
; line 227: 	///
; line 228: 	///
; line 229: 
; line 230: 
; line 231: 
; line 232: }
	POP	CP
	POP	DPP3
	RETI	
; FUNCTION timer_int (END    RMASK = @0x0010)
	timer_int  ENDP
        ?PR?INT  ENDS


; line 233: 
; line 234: 
; line 235: 
; line 236: #endif
; line 237: 
; line 238: 
; line 239: 
; line 240: 
; line 241: 
; line 242: 
; line 243: 
; line 244: 

	END
