Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 1 PC Object I Line Source A 1 ; Zilog Z8 Encore! ANSI C Compiler Release 3.60 A 2 ; -nolocalcse -optsize -nofastcall -const=RAM -model=L A 3 ; -nooptlink -regvar -reduceopt -debug -norevaa -peephole A 4 ; -alias A 5 DEFINE zumobot_TEXT,SPACE=ROM A 6 FILE "..\ZUMOBOT.C" A 7 .debug "C" A 8 SEGMENT FAR_BSS 000000 A 9 _a: 000000 A 10 DS 2*1 A 11 .define "a" A 12 .alias "_a" A 13 .class 83 A 14 .value _a A 15 .type 3 A 16 .type 0 A 17 .endef 000002 A 18 _d: 000002 A 19 DS 2*1 A 20 .define "d" A 21 .alias "_d" A 22 .class 83 A 23 .value _d A 24 .type 3 A 25 .type 0 A 26 .endef 000004 A 27 _status: 000004 A 28 DS 2*1 A 29 .define "status" A 30 .alias "_status" A 31 .class 83 A 32 .value _status A 33 .type 3 A 34 .type 0 A 35 .endef A 36 SEGMENT FAR_DATA 000000 A 37 _index: 000000 01 A 38 DB 1 A 39 .define "index" A 40 .alias "_index" A 41 .class 69 A 42 .value _index A 43 .type 12 A 44 .type 0 A 45 .endef A 46 SEGMENT ROM_DATA A 47 A 48 A 49 ;**************************** _isrTimer1 *************************** A 50 ;Name Addr/Register Size Type A 51 ;_index STATIC 0 variable A 52 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 2 PC Object I Line Source zumobot.src A 53 A 54 ; Aggregate Stack Size: 0 (words) A 55 A 56 A 57 .FRAME _n_isrTimer1,?_n_isrTimer1,RDATA A 58 .FRAME _f_isrTimer1,?_f_isrTimer1,EDATA A 59 SEGMENT zumobot_TEXT 000000 A 60 _isrTimer1: A 61 .define "_isrTimer1" A 62 .value _isrTimer1 A 63 .class 2 A 64 .type 65 A 65 .type 0 A 66 .endef A 67 .begfunc "isrTimer1",14,"_isrTimer1" 000000 C8FFD0 A 68 PUSHX 4093 000003 D6 0000 A 69 CALL __b_iframeset00 A 70 ; 1 #include A 71 ; 2 A 72 ; 3 void forward(int ontime1, int offtime1); A 73 ; 4 void reverse(int ontime1, int offtime1); A 74 ; 5 void left(int ontime1, int offtime1); A 75 ; 6 void rotateL(int ontime1, int offtime1); A 76 ; 7 void right(int ontime1, int offtime1); A 77 ; 8 void rotateR(int ontime1, int offtime1); A 78 ; 9 A 79 ; 10 int a, d, status; A 80 ; 11 unsigned char index=1; A 81 ; 12 A 82 ; 13 #pragma interrupt A 83 ; 14 void isrTimer1(void) { A 84 ; 15 index = index << 1; A 85 .line 15 000006 840000 A 86 LDX R0,_index 000009 0200 A 87 ADD R0,R0 00000B 940000 A 88 LDX _index,R0 A 89 ; 16 if(index==0x40){ A 90 .line 16 00000E A9400000 A 91 CPX _index,#64 000012 EB 04 A 92 JR NE,_1_L_1 A 93 ; 17 index=1; A 94 .line 17 000014 E9010000 A 95 LDX _index,#1 A 96 ; 18 } A 97 ; 19 } 000018 A 98 _1_L_1: A 99 .line 19 000018 D6 0000 A 100 CALL __b_iframereset 00001B BF A 101 IRET A 102 .endfunc "isrTimer1",19,"_isrTimer1" A 103 SEGMENT ROM_DATA A 104 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 3 PC Object I Line Source zumobot.src A 105 A 106 ;**************************** _InitTimer1 *************************** A 107 ;Name Addr/Register Size Type A 108 ;_EI IMPORT ----- function A 109 ;_SET_VECTOR IMPORT ----- function A 110 ;_DI IMPORT ----- function A 111 A 112 A 113 ; Aggregate Stack Size: 0 (words) A 114 A 115 A 116 .FRAME _n_InitTimer1,?_n_InitTimer1,RDATA A 117 .FRAME _f_InitTimer1,?_f_InitTimer1,EDATA A 118 SEGMENT zumobot_TEXT 00001C A 119 _InitTimer1: A 120 .define "_InitTimer1" A 121 .value _InitTimer1 A 122 .class 2 A 123 .type 65 A 124 .type 0 A 125 .endef A 126 .begfunc "InitTimer1",22,"_InitTimer1" 00001C D6 0000 A 127 CALL __b_frameset00 A 128 ; 20 A 129 ; 21 #define RELOAD 8 A 130 ; 22 void InitTimer1(void) { A 131 ; 23 DI(); A 132 .line 23 00001F 8F A 133 DI A 134 ; 24 T1CTL = (0x07 << 3) | 0x01; // Cont mode, prescale 2^7=128 A 135 .line 24 000020 E9390F0F A 136 LDX 3855,#57 A 137 ; 25 T1H = 0x00; T1L = 0x01; // T1 start = 0x0001 A 138 .line 25 000024 E9000F08 A 139 LDX 3848,#-0 000028 E9010F09 A 140 LDX 3849,#1 A 141 ; 26 T1RH = (RELOAD >> 8); T1RL = (RELOAD & 0xFF); A 142 .line 26 00002C E9000F0A A 143 LDX 3850,#-0 000030 E9080F0B A 144 LDX 3851,#8 A 145 ; 27 SET_VECTOR(TIMER1,isrTimer1); A 146 ; 28 IRQ0ENH |= 0x40; // enable timer1 interrupt T1I A 147 .line 28 000034 49400FC1 A 148 ORX 4033,#64 A 149 ; 29 IRQ0ENL |= 0x40; A 150 .line 29 000038 49400FC2 A 151 ORX 4034,#64 A 152 ; 30 IRQ0 &= ~0x40; // clear timer1 interrupt flag A 153 .line 30 00003C 59BF0FC0 A 154 ANDX 4032,#-65 A 155 ; 31 EI(); A 156 .line 31 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 4 PC Object I Line Source zumobot.src 000040 9F A 157 EI A 158 ; 32 T1CTL |= 0x80; // Enable timer1 A 159 .line 32 000041 49800F0F A 160 ORX 3855,#128 A 161 ; 33 } A 162 .line 33 000045 D6 0000 A 163 CALL __b_framereset 000048 AF A 164 RET A 165 .endfunc "InitTimer1",33,"_InitTimer1" A 166 SEGMENT ROM_DATA A 167 A 168 A 169 ;**************************** _LINE *************************** A 170 ;Name Addr/Register Size Type A 171 ;_EI IMPORT ----- function A 172 ;_status STATIC 1 variable A 173 ;_reverse IMPORT ----- function A 174 ;_a STATIC 1 variable A 175 ;_d STATIC 1 variable A 176 ;_DI IMPORT ----- function A 177 A 178 A 179 ; Aggregate Stack Size: 0 (words) A 180 A 181 A 182 .FRAME _n_LINE,?_n_LINE,RDATA A 183 .FCALL _n_reverse A 184 .FRAME _f_LINE,?_f_LINE,EDATA A 185 .FCALL _f_reverse A 186 SEGMENT zumobot_TEXT 000049 A 187 _LINE: A 188 .define "_LINE" A 189 .value _LINE A 190 .class 2 A 191 .type 65 A 192 .type 0 A 193 .endef A 194 .begfunc "LINE",36,"_LINE" 000049 C8FFD0 A 195 PUSHX 4093 00004C D6 0000 A 196 CALL __b_iframeset00 A 197 ; 34 A 198 ; 35 #pragma interrupt A 199 ; 36 void LINE(void) { A 200 ; 37 DI(); // Disable Interrupt A 201 .line 37 00004F 8F A 202 DI 000050 8B 0D A 203 JR _3_L_4 A 204 ; 38 for(d=0;d<1000;d++){} 000052 A 205 _3_L_5: A 206 .line 38 000052 A9E80003 A 207 CPX _d+1,#232 000056 1FA90300 02 A 208 CPCX _d,#3 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 5 PC Object I Line Source zumobot.src 00005B 1B 0C A 209 JR LT,_3_L_7 00005D 8B 14 A 210 JR _3_L_14 00005F A 211 _3_L_4: 00005F E9000002 A 212 LDX _d,#-0 000063 E9000003 A 213 LDX _d+1,#-0 000067 8B E9 A 214 JR _3_L_5 000069 A 215 _3_L_7: 000069 09010003 A 216 ADDX _d+1,#1 00006D 19000002 A 217 ADCX _d,#-0 000071 8B DF A 218 JR _3_L_5 000073 A 219 _3_L_14: A 220 ; 39 if(PAIN & 0x20){ A 221 .line 39 000073 79200FD2 A 222 TMX 4050,#32 000077 EB 0F A 223 JR NE,_3_L_9 000079 8B 38 A 224 JR _3_L_15 A 225 ; 40 for(a=0;a<80;a++){ 00007B A 226 _3_L_10: A 227 .line 40 00007B A9500001 A 228 CPX _a+1,#80 00007F 1FA90000 00 A 229 CPCX _a,#0 000084 1B 0C A 230 JR LT,_3_L_12 000086 8B 2B A 231 JR _3_L_15 000088 A 232 _3_L_9: 000088 E9000000 A 233 LDX _a,#-0 00008C E9000001 A 234 LDX _a+1,#-0 000090 8B E9 A 235 JR _3_L_10 000092 A 236 _3_L_12: A 237 ; 41 reverse(1000,200); A 238 .line 41 000092 1F70C8 A 239 PUSH #200 000095 1F7000 A 240 PUSH #0 000098 1F70E8 A 241 PUSH #232 00009B 1F7003 A 242 PUSH #3 00009E D6 02EE A 243 CALL _reverse 0000A1 50E0 A 244 POP R0 0000A3 50E0 A 245 POP R0 0000A5 50E0 A 246 POP R0 0000A7 50E0 A 247 POP R0 A 248 .line 40 0000A9 09010001 A 249 ADDX _a+1,#1 0000AD 19000000 A 250 ADCX _a,#-0 A 251 ; 42 } A 252 .line 42 0000B1 8B C8 A 253 JR _3_L_10 A 254 ; 43 } 0000B3 A 255 _3_L_15: A 256 .line 43 A 257 ; 44 status |= 0x01; A 258 .line 44 0000B3 49010005 A 259 ORX _status+1,#1 A 260 ; 45 IRQ0 &= ~0x40; // clear timer1 interrupt flag Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 6 PC Object I Line Source zumobot.src A 261 .line 45 0000B7 59BF0FC0 A 262 ANDX 4032,#-65 A 263 ; 46 EI(); // Enable Interrupt A 264 .line 46 0000BB 9F A 265 EI A 266 ; 47 } A 267 .line 47 0000BC D6 0000 A 268 CALL __b_iframereset 0000BF BF A 269 IRET A 270 .endfunc "LINE",47,"_LINE" A 271 SEGMENT ROM_DATA A 272 A 273 A 274 ;**************************** _InitLINE *************************** A 275 ;Name Addr/Register Size Type A 276 ;_EI IMPORT ----- function A 277 ;_SET_VECTOR IMPORT ----- function A 278 ;_DI IMPORT ----- function A 279 A 280 A 281 ; Aggregate Stack Size: 0 (words) A 282 A 283 A 284 .FRAME _n_InitLINE,?_n_InitLINE,RDATA A 285 .FRAME _f_InitLINE,?_f_InitLINE,EDATA A 286 SEGMENT zumobot_TEXT 0000C0 A 287 _InitLINE: A 288 .define "_InitLINE" A 289 .value _InitLINE A 290 .class 2 A 291 .type 65 A 292 .type 0 A 293 .endef A 294 .begfunc "InitLINE",49,"_InitLINE" 0000C0 D6 0000 A 295 CALL __b_frameset00 A 296 ; 48 A 297 ; 49 void InitLINE(void) { A 298 ; 50 DI(); A 299 .line 50 0000C3 8F A 300 DI A 301 ; 51 PADD |= 0x20; // Initialize PA5 as Input A 302 .line 51 0000C4 E9010FD0 A 303 LDX 4048,#1 0000C8 49200FD1 A 304 ORX 4049,#32 A 305 ; 52 IRQES |= 0x20; // Set EDGE SELECT Reg to Rising Edge A 306 .line 52 0000CC 49200FCD A 307 ORX 4045,#32 A 308 ; 53 SET_VECTOR(P5AD, LINE); // Set ISR A 309 ; 54 IRQ1ENL |= 0x20; // Set Priority Reg to HIGH A 310 .line 54 0000D0 49200FC5 A 311 ORX 4037,#32 A 312 ; 55 IRQ1ENH |= 0x20; // Set Priority Reg to HIGH Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 7 PC Object I Line Source zumobot.src A 313 .line 55 0000D4 49200FC4 A 314 ORX 4036,#32 A 315 ; 56 IRQ1 &= ~0x20; // Clear any pending INT rqst from PD3 A 316 .line 56 0000D8 59DF0FC3 A 317 ANDX 4035,#-33 A 318 ; 57 EI(); // Enable Interrupt A 319 .line 57 0000DC 9F A 320 EI A 321 ; 58 } A 322 .line 58 0000DD D6 0000 A 323 CALL __b_framereset 0000E0 AF A 324 RET A 325 .endfunc "InitLINE",58,"_InitLINE" A 326 SEGMENT ROM_DATA A 327 A 328 A 329 ;**************************** _main *************************** A 330 ;Name Addr/Register Size Type A 331 ;_rotateR IMPORT ----- function A 332 ;_rotateL IMPORT ----- function A 333 ;_right IMPORT ----- function A 334 ;_left IMPORT ----- function A 335 ;_forward IMPORT ----- function A 336 ;_a STATIC 1 variable A 337 ;_index STATIC 0 variable A 338 ;_reverse IMPORT ----- function A 339 ;_status STATIC 1 variable A 340 A 341 A 342 ; Aggregate Stack Size: 0 (words) A 343 A 344 A 345 .FRAME _n_main,?_n_main,RDATA A 346 .FCALL _n_InitTimer1 A 347 .FCALL _n_InitLINE A 348 .FCALL _n_reverse A 349 .FCALL _n_forward A 350 .FCALL _n_left A 351 .FCALL _n_right A 352 .FCALL _n_rotateL A 353 .FCALL _n_rotateR A 354 .FRAME _f_main,?_f_main,EDATA A 355 .FCALL _f_InitTimer1 A 356 .FCALL _f_InitLINE A 357 .FCALL _f_reverse A 358 .FCALL _f_forward A 359 .FCALL _f_left A 360 .FCALL _f_right A 361 .FCALL _f_rotateL A 362 .FCALL _f_rotateR A 363 SEGMENT zumobot_TEXT 0000E1 A 364 _main: Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 8 PC Object I Line Source zumobot.src A 365 .define "_main" A 366 .value _main A 367 .class 2 A 368 .type 65 A 369 .type 0 A 370 .endef A 371 .begfunc "main",63,"_main" 0000E1 D6 0000 A 372 CALL __b_frameset00 A 373 ; 59 A 374 ; 60 #define babad 100 A 375 ; 61 A 376 ; 62 void main() A 377 ; 63 { A 378 ; 64 int input; A 379 ; 65 A 380 ; 66 PADD=0xff; //Port A all input A 381 .line 66 0000E4 E9010FD0 A 382 LDX 4048,#1 0000E8 E9FF0FD1 A 383 LDX 4049,#255 A 384 ; 67 PBDD=0x00; //Port B all output A 385 .line 67 0000EC E9010FD4 A 386 LDX 4052,#1 0000F0 E9000FD5 A 387 LDX 4053,#-0 A 388 ; 68 PCDD=0xff; //Port C all input A 389 .line 68 0000F4 E9010FD8 A 390 LDX 4056,#1 0000F8 E9FF0FD9 A 391 LDX 4057,#255 A 392 ; 69 A 393 ; 70 InitTimer1(); A 394 .line 70 0000FC D6 001C A 395 CALL _InitTimer1 A 396 ; 71 InitLINE(); A 397 .line 71 0000FF D6 00C0 A 398 CALL _InitLINE A 399 ; 72 /* PB truth table: hex value: A 400 ; 73 0000 = stop 0x00 A 401 ; 74 0010 = left 0x02 A 402 ; 75 1111 = reverse 0x0f A 403 ; 76 1110 = rotateL 0x0e A 404 ; 77 1000 = right 0x08 A 405 ; 78 1011 = rotateR 0x0b A 406 ; 79 1010 = forward 0x0a A 407 ; 80 A 408 ; 81 Sensor truth table: hex value: A 409 ; 82 000 = reverse 0x00 A 410 ; 83 001 = rotateR 0x01 A 411 ; 84 010 = forward 0x02 A 412 ; 85 011 = right 0x03 A 413 ; 86 100 = rotateL 0x04 A 414 ; 87 101 = 0x05 A 415 ; 88 110 = left 0x06 A 416 ; 89 111 = forward 0x07 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 9 PC Object I Line Source zumobot.src A 417 ; 90 */ A 418 ; 91 while(1) 000102 A 419 _5_L_74: A 420 .line 91 A 421 ; 92 { A 422 ; 93 if((PAIN & 0x20) || ((status & 0x01) && !(PAIN & 0x08))){ A 423 .line 93 000102 79200FD2 A 424 TMX 4050,#32 000106 EB 0C A 425 JR NE,_5_L_20 000108 79010005 A 426 TMX _status+1,#1 00010C 6B 1F A 427 JR Z,_5_L_21 00010E 79080FD2 A 428 TMX 4050,#8 000112 EB 19 A 429 JR NE,_5_L_21 000114 A 430 _5_L_20: A 431 ; 94 reverse(600,600); A 432 .line 94 000114 1F7058 A 433 PUSH #88 000117 1F7002 A 434 PUSH #2 00011A 1F7058 A 435 PUSH #88 00011D 1F7002 A 436 PUSH #2 000120 D6 02EE A 437 CALL _reverse 000123 50E0 A 438 POP R0 000125 50E0 A 439 POP R0 000127 50E0 A 440 POP R0 000129 50E0 A 441 POP R0 A 442 ; 95 } A 443 ; 96 else{status &= ~0x01;} A 444 .line 96 00012B 8B 04 A 445 JR _5_L_23 00012D A 446 _5_L_21: 00012D 59FE0005 A 447 ANDX _status+1,#254 A 448 ; 97 A 449 ; 98 while(!(PAIN & 0x08) && !(status & 0x01)) { 000131 A 450 _5_L_23: A 451 .line 98 000131 79080FD2 A 452 TMX 4050,#8 000135 EB 0C A 453 JR NE,_5_L_33 000137 79010005 A 454 TMX _status+1,#1 00013B EB 06 A 455 JR NE,_5_L_33 A 456 ; 99 PBOUT=0x0a; // attack A 457 .line 99 00013D E90A0FD7 A 458 LDX 4055,#10 A 459 ; 100 } A 460 .line 100 000141 8B EE A 461 JR _5_L_23 000143 A 462 _5_L_33: A 463 ; 101 A 464 ; 102 if(index==0x01){ A 465 .line 102 000143 A9010000 A 466 CPX _index,#1 000147 6B 15 A 467 JR Z,_5_L_28 000149 8B 3E A 468 JR _5_L_41 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 05-Aug-08 13:07:31 page: 10 PC Object I Line Source zumobot.src A 469 ; 103 for(a=0;a