                        .module robot.c
                        .area text
                ;  lreg1 -> -4,x
                ;  lreg2 -> -8,x
                ;              t -> -14,x
                ;           time -> -12,x
 0000           _main::
 0000 34                pshx
 0001 B775              tfr s,x
 0003 1B92              leas -14,sp
 0005           ; #include<mc9S12dp256.h>
 0005           ; #include<stdio.h>
 0005           ; 
 0005           ; void main(void)
 0005           ; {
 0005           ; 
 0005           ;    int t;
 0005           ;    long int time;
 0005           ;    
 0005           ;    init_pwm();
 0005 1600D8            jsr _init_pwm
 0008 18200069          lbra L5
 000C           L4:
 000C           ;    
 000C           ;    while(1)
 000C           ;    {
 000C           ;       t++;
 000C EC12              ldd -14,x
 000E C30001            addd #1
 0011 6C12              std -14,x
 0013           ;         if (t>15)
 0013 EC12              ldd -14,x
 0015 8C000F            cpd #15
 0018 2F05              ble L7
 001A           ;            t=0;
 001A CC0000            ldd #0
 001D 6C12              std -14,x
 001F           L7:
 001F           ;       		 
 001F           ;       ob_led(t);
 001F EC12              ldd -14,x
 0021 16009D            jsr _ob_led
 0024 CD0119            ldy #L13
 0027 1802401C          movw 0,y,-4,x
 002B 1802421E          movw 2,y,-2,x
 002F 1914              leay -12,x
 0031 18021C40          movw -4,x,0,y
 0035 18021E42          movw -2,x,2,y
 0039           L9:
 0039           L10:
 0039 1914              leay -12,x
 003B 1802401C          movw 0,y,-4,x
 003F 1802421E          movw 2,y,-2,x
 0043 CD0115            ldy #L14
 0046 18024018          movw 0,y,-8,x
 004A 1802421A          movw 2,y,-6,x
 004E 160000            jsr __ladd
 0051 1914              leay -12,x
 0053 18021C40          movw -4,x,0,y
 0057 18021E42          movw -2,x,2,y
 005B 1914              leay -12,x
 005D 1802401C          movw 0,y,-4,x
 0061 1802421E          movw 2,y,-2,x
 0065 CD0111            ldy #L15
 0068 18024018          movw 0,y,-8,x
 006C 1802421A          movw 2,y,-6,x
 0070 160000            jsr __lcmp
 0073 2DC4              blt L9
 0075           L5:
 0075 1820FF93          lbra L4
 0079           X0:
 0079           ; 	  for (time=0; time<50000; time++);
 0079           ; 	  
 0079           ;    }
 0079           ; }
 0079           L3:
 0079 B757              tfr x,s
 007B 30                pulx
 007C                   .dbline 0 ; func end
 007C 3D                rts
 007D           L17:
 007D 003F              .word 63
 007F 0006              .word 6
 0081 005B              .word 91
 0083 004F              .word 79
 0085 0066              .word 102
 0087 006D              .word 109
 0089 007D              .word 125
 008B 0007              .word 7
 008D 007F              .word 127
 008F 006F              .word 111
 0091 0077              .word 119
 0093 007C              .word 124
 0095 0039              .word 57
 0097 005E              .word 94
 0099 0079              .word 121
 009B 0071              .word 113
 009D           ;            out -> -32,x
 009D           ;              t -> 2,x
 009D           _ob_led::
 009D 3B                pshd
 009E 34                pshx
 009F B775              tfr s,x
 00A1 1BF1DE            leas -34,sp
 00A4           ; 
 00A4           ; 
 00A4           ; // Display value passed to function on on board 7-seg LED of MiniDragon Board
 00A4           ; void ob_led(int t)               
 00A4           ; {
 00A4           ; 
 00A4           ;   int out[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,
 00A4 19E1E0            leay -32,x
 00A7 B7C6              xgdy
 00A9 CD007D            ldy #L17
 00AC 34                pshx
 00AD B745              tfr d,x
 00AF CC0010            ldd #16
 00B2           X1:
 00B2 18027131          movw 2,y+,2,x+
 00B6 0434F9            dbne d,X1
 00B9 30                pulx
 00BA           ;     0x39,0x5e,0x79,0x71};
 00BA           ;   
 00BA           ;   DDRH=0xff;
 00BA C6FF              ldab #255
 00BC 7B0262            stab 0x262
 00BF           ;   
 00BF           ;   PTH=out[t];
 00BF 19E1E0            leay -32,x
 00C2 6DE1DE            sty -34,x
 00C5 EC02              ldd 2,x
 00C7 59                lsld
 00C8 E3E1DE            addd -34,x
 00CB B7C6              xgdy
 00CD EC40              ldd 0,y
 00CF 7B0260            stab 0x260
 00D2           ; 
 00D2           ;   
 00D2           ; }
 00D2           L16:
 00D2 B757              tfr x,s
 00D4 30                pulx
 00D5 1B82              leas 2,sp
 00D7                   .dbline 0 ; func end
 00D7 3D                rts
 00D8           _init_pwm::
 00D8           ; 
 00D8           ; void init_pwm()
 00D8           ; {
 00D8           ;   PWMTST = 0x00; 		   			  // turn off all PWM special Modes
 00D8 7900A6            clr 0xa6
 00DB           ;   PWMCTL = 0x00;                                        // PWM left aligned output mode 
 00DB 7900A5            clr 0xa5
 00DE           ;   
 00DE           ;   PWMSCLA = 0x7;                                        // Clock SA = Clock A /(2 * 7)
 00DE C607              ldab #7
 00E0 7B00A8            stab 0xa8
 00E3           ;   
 00E3           ;   
 00E3           ;   PWMPRCLK = 0x77;                                      // E/128 for A and B     
 00E3 C677              ldab #119
 00E5 7B00A3            stab 0xa3
 00E8           ;   
 00E8           ;   PWMCLK = 0x03;                                        // PW Chan 0, 1, clock SA
 00E8 C603              ldab #3
 00EA 7B00A2            stab 0xa2
 00ED           ;                                                                         // PW chan 4, 5 clock A 
 00ED           ;                                                                         // PW chan 2, 3, 6, 7 clock B
 00ED           ;                                                                         
 00ED           ;   PWMPOL= 0xff;                                                 // High Polarity for all channels
 00ED C6FF              ldab #255
 00EF 7B00A1            stab 0xa1
 00F2           ;   DDRP= 0xff;                                           // Set Port P to output 
 00F2 C6FF              ldab #255
 00F4 7B025A            stab 0x25a
 00F7           ;   PWME= 0x0ff;                                                  // Enable ALL PWM Channels
 00F7 C6FF              ldab #255
 00F9 7B00A0            stab 0xa0
 00FC           ; 
 00FC           ;   PWMPER0 = 255;
 00FC C6FF              ldab #255
 00FE 7B00B4            stab 0xb4
 0101           ;   PWMDTY0 = 171;
 0101 C6AB              ldab #171
 0103 7B00BC            stab 0xbc
 0106           ;   
 0106           ;   PWMPER1 = 255;
 0106 C6FF              ldab #255
 0108 7B00B5            stab 0xb5
 010B           ;   PWMDTY1 = 171;
 010B C6AB              ldab #171
 010D 7B00BD            stab 0xbd
 0110           ; }
 0110           L18:
 0110                   .dbline 0 ; func end
 0110 3D                rts
 0111           L15:
 0111 0000C350          .word 0,50000
 0115           L14:
 0115 00000001          .word 0,1
 0119           L13:
 0119 00000000          .word 0,0
