                        .module TESTMO~1.C
                        .area text
 0000           _main::
 0000           ; #include<stdio.h>
 0000           ; #include<mc9s12dp256.h>
 0000           ; 
 0000           ; void delay_100us();
 0000           ; 
 0000           ; char c;
 0000           ; 
 0000           ; main()
 0000           ; {
 0000           ; 
 0000           ;    SCI1BDL = 0x46;  // sets Baud rate to 2400 
 0000 C646              ldab #70
 0002 7B00D1            stab 0xd1
 0005           ;    SCI1BDH = 0x01;  //
 0005 C601              ldab #1
 0007 7B00D0            stab 0xd0
 000A           ;    SCI1CR1 = 0x00;  // sets 8-bit communication, w/o parity
 000A 7900D2            clr 0xd2
 000D           ;    SCI1CR2 = 0x08;  //ENABLE TRANSMIT BIT
 000D C608              ldab #8
 000F 7B00D3            stab 0xd3
 0012           ;    
 0012           ;   
 0012           ; 
 0012           ; printf("To make the motors go full backwords press B, to make them go full foward press F.  To stop them press S.\r\n");
 0012 CC0166            ldd #L4
 0015 160000            jsr _printf
 0018           ; printf("To turn right type R.  To turn left type L.\r\n");
 0018 CC0138            ldd #L5
 001B 160000            jsr _printf
 001E           ; c = 'null';
 001E C66E              ldab #110
 0020 7B0000            stab _c
 0023           ; 
 0023           ; //while(!(SCI1SR1 & 0x80));   /*wait for TDRE*/
 0023           ; //SCI1DRL = 0x10;                     /*motor 1*/
 0023           ; delay_100us();
 0023 1600E9            jsr _delay_100us
 0026           ; delay_100us();
 0026 1600E9            jsr _delay_100us
 0029           ; delay_100us();
 0029 1600E9            jsr _delay_100us
 002C 182000B4          lbra L7
 0030           L6:
 0030           ; 
 0030           ; while(1){
 0030           ; 
 0030           ; c=getcSCI0();
 0030 160000            jsr _getcSCI0
 0033 7B0000            stab _c
 0036           ; 
 0036           ; if (c == '6'){                        //Right Turn
 0036 F60000            ldab _c
 0039 C136              cmpb #54
 003B 261D              bne L9
 003D           L11:
 003D           L12:
 003D           ; 
 003D           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 003D 1F00D480FB        brclr 0xd4,#128,L11
 0042           ; SCI1DRL = 80;                 /*motor 1*/
 0042 C650              ldab #80
 0044 7B00D7            stab 0xd7
 0047           ; delay_100us();
 0047 1600E9            jsr _delay_100us
 004A           L14:
 004A           L15:
 004A           ; 
 004A           ; 
 004A           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 004A 1F00D480FB        brclr 0xd4,#128,L14
 004F           ; SCI1DRL = 174;                /*motor 2*/
 004F C6AE              ldab #174
 0051 7B00D7            stab 0xd7
 0054           ; printf("\r\nCommand Sent\r\n");
 0054 CC0127            ldd #L17
 0057 160000            jsr _printf
 005A           ; }
 005A           L9:
 005A           ; if (c == '4'){				//Left Turn
 005A F60000            ldab _c
 005D C134              cmpb #52
 005F 261D              bne L18
 0061           L20:
 0061           L21:
 0061           ; 
 0061           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 0061 1F00D480FB        brclr 0xd4,#128,L20
 0066           ; SCI1DRL = 50;                 /*motor 1*/
 0066 C632              ldab #50
 0068 7B00D7            stab 0xd7
 006B           ; delay_100us();
 006B 1600E9            jsr _delay_100us
 006E           L23:
 006E           L24:
 006E           ; 
 006E           ; 
 006E           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 006E 1F00D480FB        brclr 0xd4,#128,L23
 0073           ; SCI1DRL = 208;                /*motor 2*/
 0073 C6D0              ldab #208
 0075 7B00D7            stab 0xd7
 0078           ; printf("\r\nCommand Sent\r\n");
 0078 CC0127            ldd #L17
 007B 160000            jsr _printf
 007E           ; }
 007E           L18:
 007E           ; if (c == '2'){ 		  	//Drive Backwords
 007E F60000            ldab _c
 0081 C132              cmpb #50
 0083 261F              bne L26
 0085           L28:
 0085           L29:
 0085           ; 
 0085           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 0085 1F00D480FB        brclr 0xd4,#128,L28
 008A           ; SCI1DRL = 50;                 /*motor 1*/
 008A C632              ldab #50
 008C 7B00D7            stab 0xd7
 008F           ; delay_100us();
 008F 1600E9            jsr _delay_100us
 0092           L31:
 0092           L32:
 0092           ; 
 0092           ; 
 0092           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 0092 1F00D480FB        brclr 0xd4,#128,L31
 0097           ; SCI1DRL = 178;                /*motor 2*/
 0097 C6B2              ldab #178
 0099 7B00D7            stab 0xd7
 009C           ; printf("\r\nCommand Sent\r\n");
 009C CC0127            ldd #L17
 009F 160000            jsr _printf
 00A2           ; }
 00A2 203B              bra L27
 00A4           L26:
 00A4           ; 
 00A4           ; 
 00A4           ; else if (c == '8'){      //Drive Forwords
 00A4 F60000            ldab _c
 00A7 C138              cmpb #56
 00A9 261F              bne L34
 00AB           L36:
 00AB           L37:
 00AB           ; 
 00AB           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 00AB 1F00D480FB        brclr 0xd4,#128,L36
 00B0           ; SCI1DRL = 80;         /*motor 1*/
 00B0 C650              ldab #80
 00B2 7B00D7            stab 0xd7
 00B5           ; delay_100us();
 00B5 1600E9            jsr _delay_100us
 00B8           L39:
 00B8           L40:
 00B8           ; 
 00B8           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 00B8 1F00D480FB        brclr 0xd4,#128,L39
 00BD           ; SCI1DRL = 208;                /*motor 2*/
 00BD C6D0              ldab #208
 00BF 7B00D7            stab 0xd7
 00C2           ; printf("\r\nCommand Sent\r\n");
 00C2 CC0127            ldd #L17
 00C5 160000            jsr _printf
 00C8           ; 
 00C8           ; }
 00C8 2015              bra L35
 00CA           L34:
 00CA           ; else if (c == 's'){       //Stop Both Motors
 00CA F60000            ldab _c
 00CD C173              cmpb #115
 00CF 260E              bne L42
 00D1           L44:
 00D1           L45:
 00D1           ; while(!(SCI1SR1 & 0x80));	/*wait for TDRE*/
 00D1 1F00D480FB        brclr 0xd4,#128,L44
 00D6           ; SCI1DRL = 0x00;                       /*motor 1*/
 00D6 7900D7            clr 0xd7
 00D9           ; printf("\r\nCommand Sent, Motors Stopped\r\n");
 00D9 CC0106            ldd #L47
 00DC 160000            jsr _printf
 00DF           ; }
 00DF           L42:
 00DF           ; 
 00DF           ; else;
 00DF           L43:
 00DF           L35:
 00DF           L27:
 00DF C66E              ldab #110
 00E1 7B0000            stab _c
 00E4           L7:
 00E4 1820FF48          lbra L6
 00E8           X0:
 00E8           ; c = 'null';
 00E8           ; }
 00E8           ; }
 00E8           L3:
 00E8                   .dbline 0 ; func end
 00E8 3D                rts
 00E9           ;              i -> -2,x
 00E9           _delay_100us::
 00E9 34                pshx
 00EA B775              tfr s,x
 00EC 1B9E              leas -2,sp
 00EE           ; 
 00EE           ; void delay_100us(void){ 
 00EE           ; int i;
 00EE           ; for (i=0; i<50;i++)
 00EE CC0000            ldd #0
 00F1 6C1E              std -2,x
 00F3           L49:
 00F3 A7                        nop
 00F4           
 00F4           L50:
 00F4 EC1E              ldd -2,x
 00F6 C30001            addd #1
 00F9 6C1E              std -2,x
 00FB EC1E              ldd -2,x
 00FD 8C0032            cpd #50
 0100 2DF1              blt L49
 0102           ; asm("nop");
 0102           ; }
 0102           L48:
 0102 B757              tfr x,s
 0104 30                pulx
 0105                   .dbline 0 ; func end
 0105 3D                rts
                        .area bss
 0000           _c::
 0000                   .blkb 1
                        .area text
 0106           L47:
 0106 0D0A436F6D6D616E642053656E742C20  .byte 13,10,'C,'o,'m,'m,'a,'n,'d,32,'S,'e,'n,'t,44,32
 0116 4D6F746F72732053746F707065640D0A  .byte 'M,'o,'t,'o,'r,'s,32,'S,'t,'o,'p,'p,'e,'d,13,10
 0126 00                .byte 0
 0127           L17:
 0127 0D0A436F6D6D616E642053656E740D0A  .byte 13,10,'C,'o,'m,'m,'a,'n,'d,32,'S,'e,'n,'t,13,10
 0137 00                .byte 0
 0138           L5:
 0138 546F207475726E207269676874207479  .byte 'T,'o,32,'t,'u,'r,'n,32,'r,'i,'g,'h,'t,32,'t,'y
 0148 706520522E2020546F207475726E206C  .byte 'p,'e,32,'R,46,32,32,'T,'o,32,'t,'u,'r,'n,32,'l
 0158 6566742074797065204C2E0D0A00      .byte 'e,'f,'t,32,'t,'y,'p,'e,32,'L,46,13,10,0
 0166           L4:
 0166 546F206D616B6520746865206D6F746F  .byte 'T,'o,32,'m,'a,'k,'e,32,'t,'h,'e,32,'m,'o,'t,'o
 0176 727320676F2066756C6C206261636B77  .byte 'r,'s,32,'g,'o,32,'f,'u,'l,'l,32,'b,'a,'c,'k,'w
 0186 6F72647320707265737320422C20746F  .byte 'o,'r,'d,'s,32,'p,'r,'e,'s,'s,32,'B,44,32,'t,'o
 0196 206D616B65207468656D20676F206675  .byte 32,'m,'a,'k,'e,32,'t,'h,'e,'m,32,'g,'o,32,'f,'u
 01A6 6C6C20666F7761726420707265737320  .byte 'l,'l,32,'f,'o,'w,'a,'r,'d,32,'p,'r,'e,'s,'s,32
 01B6 462E2020546F2073746F70207468656D  .byte 'F,46,32,32,'T,'o,32,'s,'t,'o,'p,32,'t,'h,'e,'m
 01C6 20707265737320532E0D0A00  .byte 32,'p,'r,'e,'s,'s,32,'S,46,13,10,0
