                        .module firsttest.c
                        .area data
 0000           _T_counts::
 0000                   .blkb 2
                        .area idata
 0000 4E20              .word 20000
                        .area data
 0002           _per_on2::
 0002                   .blkb 2
                        .area idata
 0002 003C              .word 60
                        .area data
 0004           _per_on3::
 0004                   .blkb 2
                        .area idata
 0004 0046              .word 70
                        .area data
 0006           _cntflag::
 0006                   .blkb 2
                        .area idata
 0006 0000              .word 0
                        .area data
                        .area text
 0000           L4:
 0000 0000              .word 0
 0002 0037              .word 55
 0004 0046              .word 70
 0006 003C              .word 60
 0008           L5:
 0008 0000              .word 0
 000A 0046              .word 70
 000C 0037              .word 55
 000E 003C              .word 60
 0010           L6:
 0010 0000              .word 0
 0012 003C              .word 60
 0014 0046              .word 70
 0016 003C              .word 60
 0018           L7:
 0018 0000              .word 0
 001A 0046              .word 70
 001C 003C              .word 60
 001E 003C              .word 60
 0020           ;  IX -> 0,x
 0020           ;  rMEM -> 2,x
 0020           ;          ?temp -> +4,x
 0020           ;       leftline -> +6,x
 0020           ;      rightline -> +8,x
 0020           ;     anglethree -> +10,x
 0020           ;       angletwo -> +18,x
 0020           ;          three -> +26,x
 0020           ;            two -> +34,x
 0020           ;          temp2 -> +42,x
 0020           ;      sensorone -> +44,x
 0020           ;     sensorzero -> +46,x
 0020           ;          temp1 -> +48,x
 0020           _main::
 0020 BD0000            jsr __enterb
 0023 32                .byte 0x32
 0024           ; /* C Listing 11.4 */
 0024           ; 
 0024           ; #include <hc11.h>     /* Include register definitions */
 0024           ; #include <stdio.h>
 0024           ; #define motcont *(unsigned char volatile *)(0xB590)
 0024           ; #define linetrack *(unsigned char volatile *) (0XB5A0)
 0024           ; 
 0024           ; 
 0024           ; /* Declarations */
 0024           ; unsigned int OC2hi, OC2lo, OC3hi, OC3lo;      /* Duty cycle data */
 0024           ; unsigned int T_counts=0x4E20, per_on2=60, per_on3=70, cntflag=0;
 0024           ; 
 0024           ; 
 0024           ; /* Prototypes */
 0024           ; void initoc(void);
 0024           ; void rtoc2(void);
 0024           ; void rtoc3(void);
 0024           ; void cnts2(void);
 0024           ; void cnts3(void);
 0024           ; void RTIINTR (void);
 0024           ; 
 0024           ; 
 0024           ; void main(void)
 0024           ; {
 0024           ;       int temp1=0, temp2=0, sensorzero=0, sensorone=0;
 0024 CC0000            ldd #0
 0027 ED30              std 48,x
 0029 CC0000            ldd #0
 002C ED2A              std 42,x
 002E CC0000            ldd #0
 0031 ED2E              std 46,x
 0033 CC0000            ldd #0
 0036 ED2C              std 44,x
 0038           ;       int rightline = 0, leftline = 0;
 0038 CC0000            ldd #0
 003B ED08              std 8,x
 003D CC0000            ldd #0
 0040 ED06              std 6,x
 0042           ;       //             0  1 2  3  
 0042           ;       int two[4]=  {0,55,70,60};
 0042 EC00              ldd 0,x
 0044 C30022            addd #34
 0047 18CE0000          ldy #L4
 004B 3C                pshx
 004C 8F                xgdx
 004D CC0008            ldd #8
 0050 BD0000            jsr __asgnblk
 0053 38                pulx
 0054           ;       int three[4]={0,70,55,60};
 0054 EC00              ldd 0,x
 0056 C3001A            addd #26
 0059 18CE0008          ldy #L5
 005D 3C                pshx
 005E 8F                xgdx
 005F CC0008            ldd #8
 0062 BD0000            jsr __asgnblk
 0065 38                pulx
 0066           ;       //                  0  1  2  3
 0066           ;       int     angletwo[4]      ={00,60,70,60};                  
 0066 EC00              ldd 0,x
 0068 C30012            addd #18
 006B 18CE0010          ldy #L6
 006F 3C                pshx
 0070 8F                xgdx
 0071 CC0008            ldd #8
 0074 BD0000            jsr __asgnblk
 0077 38                pulx
 0078           ;       int anglethree[4]={00,70,60,60};
 0078 EC00              ldd 0,x
 007A C3000A            addd #10
 007D 18CE0018          ldy #L7
 0081 3C                pshx
 0082 8F                xgdx
 0083 CC0008            ldd #8
 0086 BD0000            jsr __asgnblk
 0089 38                pulx
 008A           ;       
 008A           ;       setbaud(BAUD9600);
 008A CC0030            ldd #48
 008D BD0000            jsr _setbaud
 0090           ;       INTR_OFF();
 0090 0F                                sei
 0091           
 0091           ;       /* set up jump vector for buffalo */
 0091           ;       asm("   ldaa #$7e");
 0091 867E                              ldaa #$7e
 0093           
 0093           ;       asm("   staa $dc");
 0093 97DC                              staa $dc
 0095           
 0095           ;       asm("   staa $eb");
 0095 97EB                              staa $eb
 0097           
 0097           ;       asm("   staa $d9");
 0097 97D9                              staa $d9
 0099           
 0099           ;       asm("   ldd #_rtoc2");
 0099 CC03A9                            ldd #_rtoc2
 009C           
 009C           ;       asm("   std $dd");
 009C DDDD                              std $dd
 009E           
 009E           ;       asm("   ldd #_rtoc3");
 009E CC03DF                            ldd #_rtoc3
 00A1           
 00A1           ;       asm("   std $da");
 00A1 DDDA                              std $da
 00A3           
 00A3           ;       asm("   ldd #_RTIINTR");
 00A3 CC05CF                            ldd #_RTIINTR
 00A6           
 00A6           ;       asm("   std $ec");
 00A6 DDEC                              std $ec
 00A8           
 00A8           ;       
 00A8           ;       TMSK2=0x40;
 00A8 C640              ldab #64
 00AA F71024            stab 0x1024
 00AD           ;       PACTL=PACTL & 0xFC;
 00AD 18CE1026          ldy #0x1026
 00B1 181D0003          bclr 0,y,#0x3
 00B5           ;       PACTL=PACTL | 0x00;
 00B5                   ; vol
 00B5 F61026            ldab 0x1026
 00B8 F71026            stab 0x1026
 00BB           ;       
 00BB           ;       motcont =0x03;
 00BB C603              ldab #3
 00BD F7B590            stab 0xb590
 00C0           ;       cnts2();
 00C0 BD0415            jsr _cnts2
 00C3           ;       cnts3();
 00C3 BD04F2            jsr _cnts3
 00C6           ;       
 00C6           ;       initoc();
 00C6 BD038E            jsr _initoc
 00C9           ;       
 00C9           ;       cntflag = 0;
 00C9 CC0000            ldd #0
 00CC FD0006            std _cntflag
 00CF 7E0384            jmp L9
 00D2           X0:
 00D2           ; 	
 00D2           ; 	while(1)
 00D2           ; 	{	 
 00D2           L11:
 00D2           ; 		 
 00D2           ; 		 while (cntflag == 1)
 00D2           ; 		 {
 00D2           ; 			temp2 = linetrack & 0x0C;	
 00D2           	; vol
 00D2 F6B5A0            ldab 0xb5a0
 00D5 4F                clra
 00D6 8400              anda #0
 00D8 C40C              andb #12
 00DA ED2A              std 42,x
 00DC           ;                       temp1 = linetrack & 0x03;
 00DC                   ; vol
 00DC F6B5A0            ldab 0xb5a0
 00DF 4F                clra
 00E0 8400              anda #0
 00E2 C403              andb #3
 00E4 ED30              std 48,x
 00E6           ;                       leftline = linetrack & 0xC0;
 00E6                   ; vol
 00E6 F6B5A0            ldab 0xb5a0
 00E9 4F                clra
 00EA 8400              anda #0
 00EC C4C0              andb #192
 00EE ED06              std 6,x
 00F0           ;                       rightline = linetrack & 0x30;
 00F0                   ; vol
 00F0 F6B5A0            ldab 0xb5a0
 00F3 4F                clra
 00F4 8400              anda #0
 00F6 C430              andb #48
 00F8 ED08              std 8,x
 00FA           ;                       motcont =0x03;  
 00FA C603              ldab #3
 00FC F7B590            stab 0xb590
 00FF 202B              bra L15
 0101           L14:
 0101 C660              ldab #96
 0103 F71022            stab 0x1022
 0106 CC0032            ldd #50
 0109 FD0002            std _per_on2
 010C CC0032            ldd #50
 010F FD0004            std _per_on3
 0112 BD0415            jsr _cnts2
 0115 BD04F2            jsr _cnts3
 0118                   ; vol
 0118 F6B5A0            ldab 0xb5a0
 011B 4F                clra
 011C 8400              anda #0
 011E C40C              andb #12
 0120 ED2A              std 42,x
 0122                   ; vol
 0122 F6B5A0            ldab 0xb5a0
 0125 4F                clra
 0126 8400              anda #0
 0128 C403              andb #3
 012A ED30              std 48,x
 012C           L15:
 012C           ; 		 
 012C           ; 		 	while ( (temp1 == 0x00)  &&  (temp2 == 0x00) )
 012C EC30              ldd 48,x
 012E 2604              bne L17
 0130 EC2A              ldd 42,x
 0132 27CD              beq L14
 0134           L17:
 0134 7E01DC            jmp L19
 0137           L18:
 0137           ; 			{
 0137           ; 		 	   TMSK1 = 0X60;
 0137           ; 			   per_on2 = 50;
 0137           ; 			   per_on3 = 50;
 0137           ; 			   cnts2();
 0137           ; 			   cnts3(); 
 0137           ; 			   temp2 = linetrack & 0x0C;	
 0137           ; 		 	   temp1 = linetrack & 0x03;
 0137           ; 			}
 0137           ; 		
 0137           ; 		    while ( (temp1 == 0x00) && (temp2 != 0x00) )
 0137           ; 		    {	  
 0137           ; 			  
 0137           ; 		 	  TMSK1= 0x00;
 0137 7F1022            clr 0x1022
 013A           ;                         PORTA = 0x00;
 013A 7F1000            clr 0x1000
 013D           ;                         cntflag = 0;
 013D CC0000            ldd #0
 0140 FD0006            std _cntflag
 0143           L21:
 0143           L22:
 0143           ; 			  
 0143           ; 			  while (cntflag <= 200)
 0143 FC0006            ldd _cntflag
 0146 1A8300C8          cpd #200
 014A 23F7              bls L21
 014C           ;                         {
 014C           ;                                       
 014C           ;                         }
 014C           ;                         cntflag = 0;
 014C CC0000            ldd #0
 014F FD0006            std _cntflag
 0152 2068              bra L25
 0154           L24:
 0154           ; 			  
 0154           ; 			  while (cntflag <= 120)
 0154           ; 			  {
 0154           ; 			  
 0154           ; 		  	   		if (sensorzero == 1)
 0154 EC2E              ldd 46,x
 0156 1A830001          cpd #1
 015A 2611              bne L27
 015C           ;                                       {
 015C           ;                                          motcont = 0x01;
 015C C601              ldab #1
 015E F7B590            stab 0xb590
 0161           ;                                          per_on2 = 60;
 0161 CC003C            ldd #60
 0164 FD0002            std _per_on2
 0167           ;                                          per_on3 = 70;
 0167 CC0046            ldd #70
 016A FD0004            std _per_on3
 016D           ;                                       }
 016D           L27:
 016D           ; 			  		if (sensorone == 1)
 016D EC2C              ldd 44,x
 016F 1A830001          cpd #1
 0173 2611              bne L29
 0175           ;                                       {
 0175           ;                                          motcont = 0x02;
 0175 C602              ldab #2
 0177 F7B590            stab 0xb590
 017A           ;                                          per_on2 = 70;
 017A CC0046            ldd #70
 017D FD0002            std _per_on2
 0180           ;                                          per_on3 = 60;
 0180 CC003C            ldd #60
 0183 FD0004            std _per_on3
 0186           ;                                       }
 0186           L29:
 0186           ; 			 		TMSK1 = 0x60;
 0186 C660              ldab #96
 0188 F71022            stab 0x1022
 018B           ;                                       cnts2();
 018B BD0415            jsr _cnts2
 018E           ;                                       cnts3();
 018E BD04F2            jsr _cnts3
 0191           ;                                       temp1 = linetrack & 0x03;
 0191                   ; vol
 0191 F6B5A0            ldab 0xb5a0
 0194 4F                clra
 0195 8400              anda #0
 0197 C403              andb #3
 0199 ED30              std 48,x
 019B           ;                                       cntflag = 0;
 019B CC0000            ldd #0
 019E FD0006            std _cntflag
 01A1 2006              bra L32
 01A3           L31:
 01A3 7F1022            clr 0x1022
 01A6 7F1000            clr 0x1000
 01A9           L32:
 01A9           ; 					while (cntflag <= 183)
 01A9 FC0006            ldd _cntflag
 01AC 1A8300B7          cpd #183
 01B0 23F1              bls L31
 01B2           ;                                       {
 01B2           ;                                         TMSK1 = 0x00;
 01B2           ;                                         PORTA = 0x00;
 01B2           ;                                       }
 01B2           ;                                       if (temp1 == 0)
 01B2 EC30              ldd 48,x
 01B4 2606              bne L34
 01B6           ;                                       {
 01B6           ;                                       cntflag = 0; 
 01B6 CC0000            ldd #0
 01B9 FD0006            std _cntflag
 01BC           ;                                       }
 01BC           L34:
 01BC           L25:
 01BC FC0006            ldd _cntflag
 01BF 1A830078          cpd #120
 01C3 2203              bhi X2
 01C5 7E0154            jmp L24
 01C8           X2:
 01C8           	; vol
 01C8 F6B5A0            ldab 0xb5a0
 01CB 4F                clra
 01CC 8400              anda #0
 01CE C403              andb #3
 01D0 ED30              std 48,x
 01D2                   ; vol
 01D2 F6B5A0            ldab 0xb5a0
 01D5 4F                clra
 01D6 8400              anda #0
 01D8 C40C              andb #12
 01DA ED2A              std 42,x
 01DC           L19:
 01DC EC30              ldd 48,x
 01DE 2607              bne L36
 01E0 EC2A              ldd 42,x
 01E2 2703              beq X3
 01E4 7E0137            jmp L18
 01E7           X3:
 01E7           L36:
 01E7 2068              bra L38
 01E9           L37:
 01E9           ; 					
 01E9           ; 					
 01E9           ;               }
 01E9           ; 			  temp1 = linetrack & 0x03;
 01E9           ; 			  temp2 = linetrack & 0x0C;
 01E9           ; 	          
 01E9           ; 			}
 01E9           ; 		while ( temp1 != 0x00 && temp2 == 0X00 )
 01E9           ; 		{
 01E9           ; 		   	if (sensorzero == 1)
 01E9 EC2E              ldd 46,x
 01EB 1A830001          cpd #1
 01EF 2611              bne L40
 01F1           ;                       {
 01F1           ;                          motcont = 0x03; 
 01F1 C603              ldab #3
 01F3 F7B590            stab 0xb590
 01F6           ;                          per_on2 = 50; 
 01F6 CC0032            ldd #50
 01F9 FD0002            std _per_on2
 01FC           ;                          per_on3 = 70;
 01FC CC0046            ldd #70
 01FF FD0004            std _per_on3
 0202           ;                       }
 0202           L40:
 0202           ; 			if (sensorone == 1)
 0202 EC2C              ldd 44,x
 0204 1A830001          cpd #1
 0208 2611              bne L42
 020A           ;                       {
 020A           ;                          motcont = 0x03;
 020A C603              ldab #3
 020C F7B590            stab 0xb590
 020F           ;                          per_on2 = 70; 
 020F CC0046            ldd #70
 0212 FD0002            std _per_on2
 0215           ;                          per_on3 = 50;
 0215 CC0032            ldd #50
 0218 FD0004            std _per_on3
 021B           ;                       }
 021B           L42:
 021B           ; 			TMSK1 = 0x60;
 021B C660              ldab #96
 021D F71022            stab 0x1022
 0220           ;                       cnts2();
 0220 BD0415            jsr _cnts2
 0223           ;                       cnts3();
 0223 BD04F2            jsr _cnts3
 0226           ;                       temp2 = linetrack & 0x0C; 
 0226                   ; vol
 0226 F6B5A0            ldab 0xb5a0
 0229 4F                clra
 022A 8400              anda #0
 022C C40C              andb #12
 022E ED2A              std 42,x
 0230           ;                       temp1 = linetrack & 0x03;
 0230                   ; vol
 0230 F6B5A0            ldab 0xb5a0
 0233 4F                clra
 0234 8400              anda #0
 0236 C403              andb #3
 0238 ED30              std 48,x
 023A 2006              bra L45
 023C           L44:
 023C 7F1022            clr 0x1022
 023F 7F1000            clr 0x1000
 0242           L45:
 0242 FC0006            ldd _cntflag
 0245 1A8300B7          cpd #183
 0249 23F1              bls L44
 024B CC0000            ldd #0
 024E FD0006            std _cntflag
 0251           L38:
 0251 EC30              ldd 48,x
 0253 2707              beq L47
 0255 EC2A              ldd 42,x
 0257 2603              bne X4
 0259 7E01E9            jmp L37
 025C           X4:
 025C           L47:
 025C 7E02D5            jmp L49
 025F           L48:
 025F           ; 			while (cntflag <= 183)
 025F           ; 			{
 025F           ; 			   TMSK1 = 0x00;
 025F           ; 			   PORTA = 0x00;
 025F           ; 			}
 025F           ; 			cntflag = 0;
 025F           ; 		}
 025F           ; 		/*while (temp1 == 0x03 && (temp2 == 0x08 || temp2 == 0x04))
 025F           ; 		{
 025F           ; 		 	  if (temp2 == 0x08)
 025F           ; 			  {
 025F           ; 			  motcont = 0x03; 
 025F           ; 			  per_on2 = 70;
 025F           ; 			  per_on3 = 30;
 025F           ; 			  }
 025F           ; 			  if (temp2 == 0x03)
 025F           ; 			  {
 025F           ; 			  motcont = 0x03; 
 025F           ; 			  per_on2 = 30;
 025F           ; 			  per_on3 = 70;
 025F           ; 			  }
 025F           ; 			  TMSK1 = 0x60;
 025F           ; 			  cnts2();
 025F           ; 			  cnts3();
 025F           ; 			  temp1 = linetrack & 0x03;
 025F           ; 			  temp2 = linetrack & 0x0C;
 025F           ; 			  while (cntflag <= 183)
 025F           ; 			  {
 025F           ; 				TMSK1 = 0x00;
 025F           ; 				PORTA = 0x00;
 025F           ; 			  }
 025F           ; 		}*/	
 025F           ; 		while ((two[temp1] != 0) && (three[temp1] != 0 ))
 025F           ; 		{   
 025F           ; 		  	  sensorzero = 0;
 025F CC0000            ldd #0
 0262 ED2E              std 46,x
 0264           ;                         sensorone = 0;
 0264 CC0000            ldd #0
 0267 ED2C              std 44,x
 0269           ;                         if(temp1 == 0x01)
 0269 EC30              ldd 48,x
 026B 1A830001          cpd #1
 026F 2605              bne L51
 0271           ;                         {
 0271           ;                         sensorzero = 1;
 0271 CC0001            ldd #1
 0274 ED2E              std 46,x
 0276           ;                         }
 0276           L51:
 0276           ; 		  	  if (temp1 == 0x02)
 0276 EC30              ldd 48,x
 0278 1A830002          cpd #2
 027C 2605              bne L53
 027E           ;                         {
 027E           ;                         sensorone = 1;
 027E CC0001            ldd #1
 0281 ED2C              std 44,x
 0283           ;                         }
 0283           L53:
 0283 C660              ldab #96
 0285 F71022            stab 0x1022
 0288 C603              ldab #3
 028A F7B590            stab 0xb590
 028D EC00              ldd 0,x
 028F C30022            addd #34
 0292 ED02              std 2,x
 0294 EC30              ldd 48,x
 0296 05                lsld
 0297 E302              addd 2,x
 0299 188F              xgdy
 029B 18EC00            ldd 0,y
 029E FD0002            std _per_on2
 02A1 EC00              ldd 0,x
 02A3 C3001A            addd #26
 02A6 ED02              std 2,x
 02A8 EC30              ldd 48,x
 02AA 05                lsld
 02AB E302              addd 2,x
 02AD 188F              xgdy
 02AF 18EC00            ldd 0,y
 02B2 FD0004            std _per_on3
 02B5 BD0415            jsr _cnts2
 02B8 BD04F2            jsr _cnts3
 02BB CC0000            ldd #0
 02BE FD0006            std _cntflag
 02C1                   ; vol
 02C1 F6B5A0            ldab 0xb5a0
 02C4 4F                clra
 02C5 8400              anda #0
 02C7 C403              andb #3
 02C9 ED30              std 48,x
 02CB                   ; vol
 02CB F6B5A0            ldab 0xb5a0
 02CE 4F                clra
 02CF 8400              anda #0
 02D1 C40C              andb #12
 02D3 ED2A              std 42,x
 02D5           L49:
 02D5 EC30              ldd 48,x
 02D7 05                lsld
 02D8 ED04              std 4,x
 02DA EC00              ldd 0,x
 02DC C30022            addd #34
 02DF ED02              std 2,x
 02E1 EC04              ldd 4,x
 02E3 E302              addd 2,x
 02E5 188F              xgdy
 02E7 18EC00            ldd 0,y
 02EA 2715              beq L55
 02EC EC00              ldd 0,x
 02EE C3001A            addd #26
 02F1 ED02              std 2,x
 02F3 EC04              ldd 4,x
 02F5 E302              addd 2,x
 02F7 188F              xgdy
 02F9 18EC00            ldd 0,y
 02FC 2703              beq X5
 02FE 7E025F            jmp L48
 0301           X5:
 0301           L55:
 0301 7E0367            jmp L57
 0304           L56:
 0304           ; 		  	  TMSK1 = 0x60;
 0304           ; 			  motcont = 0x03;
 0304           ; 		  	  per_on2 = two[temp1];
 0304           ; 		  	  per_on3 = three[temp1];
 0304           ; 		  	  cnts2();
 0304           ; 		  	  cnts3();
 0304           ; 			  cntflag = 0;
 0304           ; 			  temp1 = linetrack & 0x03;
 0304           ; 			  temp2 = linetrack & 0x0C;
 0304           ; 		 }
 0304           ;        	 while (temp1 == 0x03)
 0304           ; 		 {
 0304           ; 		   	  if (temp2 == 0x00)
 0304 EC2A              ldd 42,x
 0306 2622              bne L59
 0308           ;                         {
 0308           ;                               TMSK1 = 0x60;
 0308 C660              ldab #96
 030A F71022            stab 0x1022
 030D           ;                               motcont = 0x03;
 030D C603              ldab #3
 030F F7B590            stab 0xb590
 0312           ;                               per_on2 = 30;
 0312 CC001E            ldd #30
 0315 FD0002            std _per_on2
 0318           ;                               per_on3 = 30;
 0318 CC001E            ldd #30
 031B FD0004            std _per_on3
 031E           ;                               cnts2();
 031E BD0415            jsr _cnts2
 0321           ;                               cnts3();
 0321 BD04F2            jsr _cnts3
 0324           ;                               cntflag = 0;
 0324 CC0000            ldd #0
 0327 FD0006            std _cntflag
 032A           ;                               
 032A           ;                         }
 032A           L59:
 032A C603              ldab #3
 032C F7B590            stab 0xb590
 032F EC00              ldd 0,x
 0331 C30012            addd #18
 0334 ED02              std 2,x
 0336 EC2A              ldd 42,x
 0338 05                lsld
 0339 E302              addd 2,x
 033B 188F              xgdy
 033D 18EC00            ldd 0,y
 0340 FD0002            std _per_on2
 0343 EC00              ldd 0,x
 0345 C3000A            addd #10
 0348 ED02              std 2,x
 034A EC2A              ldd 42,x
 034C 05                lsld
 034D E302              addd 2,x
 034F 188F              xgdy
 0351 18EC00            ldd 0,y
 0354 FD0004            std _per_on3
 0357 BD0415            jsr _cnts2
 035A BD04F2            jsr _cnts3
 035D                   ; vol
 035D F6B5A0            ldab 0xb5a0
 0360 4F                clra
 0361 8400              anda #0
 0363 C403              andb #3
 0365 ED30              std 48,x
 0367           L57:
 0367 EC30              ldd 48,x
 0369 1A830003          cpd #3
 036D 2603              bne X6
 036F 7E0304            jmp L56
 0372           X6:
 0372 CC0000            ldd #0
 0375 FD0006            std _cntflag
 0378           L12:
 0378 FC0006            ldd _cntflag
 037B 1A830001          cpd #1
 037F 2603              bne X7
 0381 7E00D2            jmp L11
 0384           X7:
 0384           L9:
 0384 20F2              bra L12
 0386           X1:
 0386           ; 		  	 motcont = 0x03;
 0386           ; 		  	 per_on2 = angletwo[temp2];
 0386           ; 		  	 per_on3 = anglethree[temp2];
 0386           ; 		  	 cnts2();
 0386           ; 		 	 cnts3();
 0386           ; 			 temp1 = linetrack & 0x03; 
 0386           ; 		}
 0386           ; 		  
 0386           ; 
 0386           ; 	    cntflag = 0;
 0386           ; 	  }
 0386           ; 		
 0386           ;     }
 0386           ; 
 0386           ; 	
 0386           ; }
 0386           L3:
 0386 8F                xgdx
 0387 C30032            addd #50
 038A 8F                xgdx
 038B 35                txs
 038C 38                pulx
 038D                   .dbline 0 ; func end
 038D 39                rts
 038E           _initoc::
 038E           ; 
 038E           ; void initoc(void)
 038E           ; /* Initialize OC2 */
 038E           ; {
 038E           ; 	TOC2 = TCNT;
 038E           	; vol
 038E FC100E            ldd 0x100e
 0391 FD1018            std 0x1018
 0394           ;       TOC3 = TCNT;
 0394                   ; vol
 0394 FC100E            ldd 0x100e
 0397 FD101A            std 0x101a
 039A           ;       TCTL1 = 0x00;
 039A 7F1020            clr 0x1020
 039D           ;       TFLG1 = 0x60;
 039D C660              ldab #96
 039F F71023            stab 0x1023
 03A2           ;       TMSK1 = 0x60;
 03A2 C660              ldab #96
 03A4 F71022            stab 0x1022
 03A7           ;       INTR_ON();
 03A7 0E                                cli
 03A8           
 03A8           ; }
 03A8           L61:
 03A8                   .dbline 0 ; func end
 03A8 39                rts
 03A9           _rtoc2::
 03A9           ; 
 03A9           ; void rtoc2(void)
 03A9           ; /* Interrupt Service Routine for OC2 PWM */
 03A9           ; {   
 03A9           ; 	if ((PORTA & 0X40) == 0){ 
 03A9 18CE1000          ldy #0x1000
 03AD 181F004002        brclr 0,y,#64,X8
 03B2 2013              bra L63
 03B4           X8:
 03B4           ; 		TOC2 = TOC2 + OC2hi;
 03B4           	; vol
 03B4 FC1018            ldd 0x1018
 03B7 F30006            addd _OC2hi
 03BA FD1018            std 0x1018
 03BD           ;               PORTA = PORTA | 0x40;
 03BD 18CE1000          ldy #0x1000
 03C1 181C0040          bset 0,y,#64
 03C5           ;               }
 03C5 2011              bra L64
 03C7           L63:
 03C7           ; 	else{
 03C7           ; 		TOC2 = TOC2 + OC2lo;
 03C7           	; vol
 03C7 FC1018            ldd 0x1018
 03CA F30004            addd _OC2lo
 03CD FD1018            std 0x1018
 03D0           ;               PORTA = PORTA & 0xBF;
 03D0 18CE1000          ldy #0x1000
 03D4 181D0040          bclr 0,y,#0x40
 03D8           ;               }
 03D8           L64:
 03D8           ; 	//TCTL1 = TCTL1 ^ 0x40;	/* invert OL2 to toggle next OC2 edge */
 03D8           ; 	TFLG1 = 0x40;	/* Clear flag OC2F */
 03D8 C640              ldab #64
 03DA F71023            stab 0x1023
 03DD           ;       asm("   rti");  /* This is an interrupt service routine */
 03DD 3B                                rti
 03DE           
 03DE           ; }
 03DE           L62:
 03DE                   .dbline 0 ; func end
 03DE 39                rts
 03DF           _rtoc3::
 03DF           ; 
 03DF           ; void rtoc3(void)
 03DF           ; {	
 03DF           ; 	if ((PORTA & 0X20) == 0) {
 03DF 18CE1000          ldy #0x1000
 03E3 181F002002        brclr 0,y,#32,X9
 03E8 2013              bra L66
 03EA           X9:
 03EA           ; 		TOC3 = TOC3 + OC3hi;
 03EA           	; vol
 03EA FC101A            ldd 0x101a
 03ED F30002            addd _OC3hi
 03F0 FD101A            std 0x101a
 03F3           ;               PORTA = PORTA | 0x20;
 03F3 18CE1000          ldy #0x1000
 03F7 181C0020          bset 0,y,#32
 03FB           ;       }       
 03FB 2011              bra L67
 03FD           L66:
 03FD           ; 	else{
 03FD           ; 		TOC3 = TOC3 + OC3lo;
 03FD           	; vol
 03FD FC101A            ldd 0x101a
 0400 F30000            addd _OC3lo
 0403 FD101A            std 0x101a
 0406           ;               PORTA = PORTA & 0xDF;
 0406 18CE1000          ldy #0x1000
 040A 181D0020          bclr 0,y,#0x20
 040E           ;       }
 040E           L67:
 040E           ; 	//TCTL1 = TCTL1 ^ 0x10;	/* invert OL2 to toggle next OC2 edge */
 040E           ; 	TFLG1 = 0x20;	/* Clear flag OC2F */
 040E C620              ldab #32
 0410 F71023            stab 0x1023
 0413           ;       asm("   rti");  /* This is an interrupt service routine */
 0413 3B                                rti
 0414           
 0414           ; }
 0414           L65:
 0414                   .dbline 0 ; func end
 0414 39                rts
 0415           ;  lreg1 -> -4,x
 0415           ;  lreg2 -> -8,x
 0415           ;  IX -> 0,x
 0415           ;          ?temp -> +2,x
 0415           ;          ?temp -> +6,x
 0415           _cnts2::
 0415 BD0000            jsr __enterb
 0418 88                .byte 0x88
 0419           ; void cnts2 (void)
 0419           ; {
 0419           ;       OC2hi=T_counts * (float)per_on2/100;
 0419 FC0002            ldd _per_on2
 041C 04                lsrd
 041D BD0000            jsr __d2lreg
 0420 BD0000            jsr __long2fp
 0423 BD0000            jsr __fpmov
 0426 18CE05E7          ldy #L72
 042A BD0000            jsr __tofp1
 042D BD0000            jsr __fpmul
 0430 FC0002            ldd _per_on2
 0433 8400              anda #0
 0435 C401              andb #1
 0437 BD0000            jsr __d2lreg
 043A BD0000            jsr __pshfp1 ; spill
 043D BD0000            jsr __long2fp
 0440 BD0000            jsr __fpmov
 0443 BD0000            jsr __pulfp1 ; reload
 0446 BD0000            jsr __fpadd
 0449 BD0000            jsr __fpmov
 044C FC0000            ldd _T_counts
 044F 04                lsrd
 0450 BD0000            jsr __d2lreg
 0453 BD0000            jsr __long2fp
 0456 BD0000            jsr __pshfp2 ; spill
 0459 BD0000            jsr __fpmov
 045C 18CE05E7          ldy #L72
 0460 BD0000            jsr __tofp1
 0463 BD0000            jsr __fpmul
 0466 FC0000            ldd _T_counts
 0469 8400              anda #0
 046B C401              andb #1
 046D BD0000            jsr __d2lreg
 0470 BD0000            jsr __pshfp1 ; spill
 0473 BD0000            jsr __long2fp
 0476 BD0000            jsr __fpmov
 0479 BD0000            jsr __pulfp1 ; reload
 047C BD0000            jsr __fpadd
 047F BD0000            jsr __pulfp2 ; reload
 0482 BD0000            jsr __fpmul
 0485 18CE05E3          ldy #L73
 0489 BD0000            jsr __tofp2
 048C BD0000            jsr __fpdiv
 048F EC00              ldd 0,x
 0491 C30002            addd #2
 0494 188F              xgdy
 0496 BD0000            jsr __fromfp1
 0499 EC00              ldd 0,x
 049B C30002            addd #2
 049E 188F              xgdy
 04A0 BD0000            jsr __tofp1
 04A3 18CE05DF          ldy #L74
 04A7 BD0000            jsr __tofp2
 04AA BD0000            jsr __fpcmp
 04AD 2D1E              blt L70
 04AF EC00              ldd 0,x
 04B1 C30002            addd #2
 04B4 188F              xgdy
 04B6 BD0000            jsr __tofp1
 04B9 18CE05DF          ldy #L74
 04BD BD0000            jsr __tofp2
 04C0 BD0000            jsr __fpsub
 04C3 BD0000            jsr __fp2int
 04C6 C38000            addd #0x8000
 04C9 ED06              std 6,x
 04CB 200F              bra L71
 04CD           L70:
 04CD EC00              ldd 0,x
 04CF C30002            addd #2
 04D2 188F              xgdy
 04D4 BD0000            jsr __tofp1
 04D7 BD0000            jsr __fp2int
 04DA ED06              std 6,x
 04DC           L71:
 04DC EC06              ldd 6,x
 04DE FD0006            std _OC2hi
 04E1           ;       OC2lo=T_counts - OC2hi;
 04E1 FC0000            ldd _T_counts
 04E4 B30006            subd _OC2hi
 04E7 FD0004            std _OC2lo
 04EA           ; }
 04EA           L68:
 04EA 8F                xgdx
 04EB C30008            addd #8
 04EE 8F                xgdx
 04EF 35                txs
 04F0 38                pulx
 04F1                   .dbline 0 ; func end
 04F1 39                rts
 04F2           ;  lreg1 -> -4,x
 04F2           ;  lreg2 -> -8,x
 04F2           ;  IX -> 0,x
 04F2           ;          ?temp -> +2,x
 04F2           ;          ?temp -> +6,x
 04F2           _cnts3::
 04F2 BD0000            jsr __enterb
 04F5 88                .byte 0x88
 04F6           ; 
 04F6           ; void cnts3 (void)
 04F6           ; {
 04F6           ;       OC3hi=T_counts * (float)per_on3/100;
 04F6 FC0004            ldd _per_on3
 04F9 04                lsrd
 04FA BD0000            jsr __d2lreg
 04FD BD0000            jsr __long2fp
 0500 BD0000            jsr __fpmov
 0503 18CE05E7          ldy #L72
 0507 BD0000            jsr __tofp1
 050A BD0000            jsr __fpmul
 050D FC0004            ldd _per_on3
 0510 8400              anda #0
 0512 C401              andb #1
 0514 BD0000            jsr __d2lreg
 0517 BD0000            jsr __pshfp1 ; spill
 051A BD0000            jsr __long2fp
 051D BD0000            jsr __fpmov
 0520 BD0000            jsr __pulfp1 ; reload
 0523 BD0000            jsr __fpadd
 0526 BD0000            jsr __fpmov
 0529 FC0000            ldd _T_counts
 052C 04                lsrd
 052D BD0000            jsr __d2lreg
 0530 BD0000            jsr __long2fp
 0533 BD0000            jsr __pshfp2 ; spill
 0536 BD0000            jsr __fpmov
 0539 18CE05E7          ldy #L72
 053D BD0000            jsr __tofp1
 0540 BD0000            jsr __fpmul
 0543 FC0000            ldd _T_counts
 0546 8400              anda #0
 0548 C401              andb #1
 054A BD0000            jsr __d2lreg
 054D BD0000            jsr __pshfp1 ; spill
 0550 BD0000            jsr __long2fp
 0553 BD0000            jsr __fpmov
 0556 BD0000            jsr __pulfp1 ; reload
 0559 BD0000            jsr __fpadd
 055C BD0000            jsr __pulfp2 ; reload
 055F BD0000            jsr __fpmul
 0562 18CE05E3          ldy #L73
 0566 BD0000            jsr __tofp2
 0569 BD0000            jsr __fpdiv
 056C EC00              ldd 0,x
 056E C30002            addd #2
 0571 188F              xgdy
 0573 BD0000            jsr __fromfp1
 0576 EC00              ldd 0,x
 0578 C30002            addd #2
 057B 188F              xgdy
 057D BD0000            jsr __tofp1
 0580 18CE05DF          ldy #L74
 0584 BD0000            jsr __tofp2
 0587 BD0000            jsr __fpcmp
 058A 2D1E              blt L77
 058C EC00              ldd 0,x
 058E C30002            addd #2
 0591 188F              xgdy
 0593 BD0000            jsr __tofp1
 0596 18CE05DF          ldy #L74
 059A BD0000            jsr __tofp2
 059D BD0000            jsr __fpsub
 05A0 BD0000            jsr __fp2int
 05A3 C38000            addd #0x8000
 05A6 ED06              std 6,x
 05A8 200F              bra L78
 05AA           L77:
 05AA EC00              ldd 0,x
 05AC C30002            addd #2
 05AF 188F              xgdy
 05B1 BD0000            jsr __tofp1
 05B4 BD0000            jsr __fp2int
 05B7 ED06              std 6,x
 05B9           L78:
 05B9 EC06              ldd 6,x
 05BB FD0002            std _OC3hi
 05BE           ;       OC3lo=T_counts - OC3hi;
 05BE FC0000            ldd _T_counts
 05C1 B30002            subd _OC3hi
 05C4 FD0000            std _OC3lo
 05C7           ; }     
 05C7           L75:
 05C7 8F                xgdx
 05C8 C30008            addd #8
 05CB 8F                xgdx
 05CC 35                txs
 05CD 38                pulx
 05CE                   .dbline 0 ; func end
 05CE 39                rts
 05CF           _RTIINTR::
 05CF           ; 
 05CF           ; void RTIINTR (void)
 05CF           ; {
 05CF           ;   TFLG2 = 0x40;
 05CF C640              ldab #64
 05D1 F71025            stab 0x1025
 05D4           ;   
 05D4           ;   cntflag ++;
 05D4 FC0006            ldd _cntflag
 05D7 C30001            addd #1
 05DA FD0006            std _cntflag
 05DD           ;   
 05DD           ;   asm("         rti");
 05DD 3B                                  rti
 05DE           
 05DE           ; }
 05DE           L79:
 05DE                   .dbline 0 ; func end
 05DE 39                rts
                        .area bss
 0000           _OC3lo::
 0000                   .blkb 2
 0002           _OC3hi::
 0002                   .blkb 2
 0004           _OC2lo::
 0004                   .blkb 2
 0006           _OC2hi::
 0006                   .blkb 2
                        .area text
 05DF           L74:
 05DF 47000000          .word 0x4700,0x0
 05E3           L73:
 05E3 42C80000          .word 0x42c8,0x0
 05E7           L72:
 05E7 40000000          .word 0x4000,0x0
