Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 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) 11-Oct-08 15:03:06 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) 11-Oct-08 15:03:06 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) 11-Oct-08 15:03:06 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 ;_DI IMPORT ----- function A 176 A 177 A 178 ; Aggregate Stack Size: 0 (words) A 179 A 180 A 181 .FRAME _n_LINE,?_n_LINE,RDATA A 182 .FCALL _n_reverse A 183 .FRAME _f_LINE,?_f_LINE,EDATA A 184 .FCALL _f_reverse A 185 SEGMENT zumobot_TEXT 000049 A 186 _LINE: A 187 .define "_LINE" A 188 .value _LINE A 189 .class 2 A 190 .type 65 A 191 .type 0 A 192 .endef A 193 .begfunc "LINE",36,"_LINE" 000049 C8FFD0 A 194 PUSHX 4093 00004C D6 0000 A 195 CALL __b_iframeset00 A 196 ; 34 A 197 ; 35 #pragma interrupt A 198 ; 36 void LINE(void) { A 199 ; 37 DI(); // Disable Interrupt A 200 .line 37 00004F 8F A 201 DI 000050 8B 0D A 202 JR _3_L_4 A 203 ; 38 for(a=0;a<80;a++){ 000052 A 204 _3_L_5: A 205 .line 38 000052 A9500001 A 206 CPX _a+1,#80 000056 1FA90000 00 A 207 CPCX _a,#0 00005B 1B 0C A 208 JR LT,_3_L_7 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 page: 5 PC Object I Line Source zumobot.src 00005D 8B 2B A 209 JR _3_L_8 00005F A 210 _3_L_4: 00005F E9000000 A 211 LDX _a,#-0 000063 E9000001 A 212 LDX _a+1,#-0 000067 8B E9 A 213 JR _3_L_5 000069 A 214 _3_L_7: A 215 ; 39 reverse(1000,200); A 216 .line 39 000069 1F70C8 A 217 PUSH #200 00006C 1F7000 A 218 PUSH #0 00006F 1F70E8 A 219 PUSH #232 000072 1F7003 A 220 PUSH #3 000075 D6 02E4 A 221 CALL _reverse 000078 50E0 A 222 POP R0 00007A 50E0 A 223 POP R0 00007C 50E0 A 224 POP R0 00007E 50E0 A 225 POP R0 A 226 .line 38 000080 09010001 A 227 ADDX _a+1,#1 000084 19000000 A 228 ADCX _a,#-0 A 229 ; 40 } A 230 .line 40 000088 8B C8 A 231 JR _3_L_5 A 232 ; 41 while(PAIN & 0x20){ 00008A A 233 _3_L_8: A 234 .line 41 00008A 79200FD2 A 235 TMX 4050,#32 00008E 6B 19 A 236 JR Z,_3_L_11 A 237 ; 42 reverse(600,600); A 238 .line 42 000090 1F7058 A 239 PUSH #88 000093 1F7002 A 240 PUSH #2 000096 1F7058 A 241 PUSH #88 000099 1F7002 A 242 PUSH #2 00009C D6 02E4 A 243 CALL _reverse 00009F 50E0 A 244 POP R0 0000A1 50E0 A 245 POP R0 0000A3 50E0 A 246 POP R0 0000A5 50E0 A 247 POP R0 A 248 ; 43 } A 249 .line 43 0000A7 8B E1 A 250 JR _3_L_8 0000A9 A 251 _3_L_11: A 252 ; 44 status |= 0x01; A 253 .line 44 0000A9 49010005 A 254 ORX _status+1,#1 A 255 ; 45 IRQ0 &= ~0x40; // clear timer1 interrupt flag A 256 .line 45 0000AD 59BF0FC0 A 257 ANDX 4032,#-65 A 258 ; 46 EI(); // Enable Interrupt A 259 .line 46 0000B1 9F A 260 EI Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 page: 6 PC Object I Line Source zumobot.src A 261 ; 47 } A 262 .line 47 0000B2 D6 0000 A 263 CALL __b_iframereset 0000B5 BF A 264 IRET A 265 .endfunc "LINE",47,"_LINE" A 266 SEGMENT ROM_DATA A 267 A 268 A 269 ;**************************** _InitLINE *************************** A 270 ;Name Addr/Register Size Type A 271 ;_EI IMPORT ----- function A 272 ;_SET_VECTOR IMPORT ----- function A 273 ;_DI IMPORT ----- function A 274 A 275 A 276 ; Aggregate Stack Size: 0 (words) A 277 A 278 A 279 .FRAME _n_InitLINE,?_n_InitLINE,RDATA A 280 .FRAME _f_InitLINE,?_f_InitLINE,EDATA A 281 SEGMENT zumobot_TEXT 0000B6 A 282 _InitLINE: A 283 .define "_InitLINE" A 284 .value _InitLINE A 285 .class 2 A 286 .type 65 A 287 .type 0 A 288 .endef A 289 .begfunc "InitLINE",49,"_InitLINE" 0000B6 D6 0000 A 290 CALL __b_frameset00 A 291 ; 48 A 292 ; 49 void InitLINE(void) { A 293 ; 50 DI(); A 294 .line 50 0000B9 8F A 295 DI A 296 ; 51 PADD |= 0x20; // Initialize PA5 as Input A 297 .line 51 0000BA E9010FD0 A 298 LDX 4048,#1 0000BE 49200FD1 A 299 ORX 4049,#32 A 300 ; 52 IRQES |= 0x20; // Set EDGE SELECT Reg to Rising Edge A 301 .line 52 0000C2 49200FCD A 302 ORX 4045,#32 A 303 ; 53 SET_VECTOR(P5AD, LINE); // Set ISR A 304 ; 54 IRQ1ENL |= 0x20; // Set Priority Reg to HIGH A 305 .line 54 0000C6 49200FC5 A 306 ORX 4037,#32 A 307 ; 55 IRQ1ENH |= 0x20; // Set Priority Reg to HIGH A 308 .line 55 0000CA 49200FC4 A 309 ORX 4036,#32 A 310 ; 56 IRQ1 &= ~0x20; // Clear any pending INT rqst from PD3 A 311 .line 56 0000CE 59DF0FC3 A 312 ANDX 4035,#-33 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 page: 7 PC Object I Line Source zumobot.src A 313 ; 57 EI(); // Enable Interrupt A 314 .line 57 0000D2 9F A 315 EI A 316 ; 58 } A 317 .line 58 0000D3 D6 0000 A 318 CALL __b_framereset 0000D6 AF A 319 RET A 320 .endfunc "InitLINE",58,"_InitLINE" A 321 SEGMENT ROM_DATA A 322 A 323 A 324 ;**************************** _main *************************** A 325 ;Name Addr/Register Size Type A 326 ;_rotateR IMPORT ----- function A 327 ;_rotateL IMPORT ----- function A 328 ;_right IMPORT ----- function A 329 ;_left IMPORT ----- function A 330 ;_forward IMPORT ----- function A 331 ;_a STATIC 1 variable A 332 ;_index STATIC 0 variable A 333 ;_reverse IMPORT ----- function A 334 ;_status STATIC 1 variable A 335 A 336 A 337 ; Aggregate Stack Size: 0 (words) A 338 A 339 A 340 .FRAME _n_main,?_n_main,RDATA A 341 .FCALL _n_InitTimer1 A 342 .FCALL _n_InitLINE A 343 .FCALL _n_reverse A 344 .FCALL _n_forward A 345 .FCALL _n_left A 346 .FCALL _n_right A 347 .FCALL _n_rotateL A 348 .FCALL _n_rotateR A 349 .FRAME _f_main,?_f_main,EDATA A 350 .FCALL _f_InitTimer1 A 351 .FCALL _f_InitLINE A 352 .FCALL _f_reverse A 353 .FCALL _f_forward A 354 .FCALL _f_left A 355 .FCALL _f_right A 356 .FCALL _f_rotateL A 357 .FCALL _f_rotateR A 358 SEGMENT zumobot_TEXT 0000D7 A 359 _main: A 360 .define "_main" A 361 .value _main A 362 .class 2 A 363 .type 65 A 364 .type 0 Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 page: 8 PC Object I Line Source zumobot.src A 365 .endef A 366 .begfunc "main",63,"_main" 0000D7 D6 0000 A 367 CALL __b_frameset00 A 368 ; 59 A 369 ; 60 #define babad 100 A 370 ; 61 A 371 ; 62 void main() A 372 ; 63 { A 373 ; 64 int input; A 374 ; 65 A 375 ; 66 PADD=0xff; //Port A all input A 376 .line 66 0000DA E9010FD0 A 377 LDX 4048,#1 0000DE E9FF0FD1 A 378 LDX 4049,#255 A 379 ; 67 PBDD=0x00; //Port B all output A 380 .line 67 0000E2 E9010FD4 A 381 LDX 4052,#1 0000E6 E9000FD5 A 382 LDX 4053,#-0 A 383 ; 68 PCDD=0xff; //Port C all input A 384 .line 68 0000EA E9010FD8 A 385 LDX 4056,#1 0000EE E9FF0FD9 A 386 LDX 4057,#255 A 387 ; 69 A 388 ; 70 InitTimer1(); A 389 .line 70 0000F2 D6 001C A 390 CALL _InitTimer1 A 391 ; 71 InitLINE(); A 392 .line 71 0000F5 D6 00B6 A 393 CALL _InitLINE A 394 ; 72 /* PB truth table: hex value: A 395 ; 73 0000 = stop 0x00 A 396 ; 74 0010 = left 0x02 A 397 ; 75 1111 = reverse 0x0f A 398 ; 76 1110 = rotateL 0x0e A 399 ; 77 1000 = right 0x08 A 400 ; 78 1011 = rotateR 0x0b A 401 ; 79 1010 = forward 0x0a A 402 ; 80 A 403 ; 81 Sensor truth table: hex value: A 404 ; 82 000 = reverse 0x00 A 405 ; 83 001 = rotateR 0x01 A 406 ; 84 010 = forward 0x02 A 407 ; 85 011 = right 0x03 A 408 ; 86 100 = rotateL 0x04 A 409 ; 87 101 = 0x05 A 410 ; 88 110 = left 0x06 A 411 ; 89 111 = forward 0x07 A 412 ; 90 */ A 413 ; 91 while(1) 0000F8 A 414 _5_L_70: A 415 .line 91 A 416 ; 92 { Zilog Z8 Encore! Macro Assembler Version 2.50 (08031703) 11-Oct-08 15:03:06 page: 9 PC Object I Line Source zumobot.src A 417 ; 93 if((PAIN & 0x20) || ((status & 0x01) && !(PAIN & 0x08))){ A 418 .line 93 0000F8 79200FD2 A 419 TMX 4050,#32 0000FC EB 0C A 420 JR NE,_5_L_16 0000FE 79010005 A 421 TMX _status+1,#1 000102 6B 1F A 422 JR Z,_5_L_17 000104 79080FD2 A 423 TMX 4050,#8 000108 EB 19 A 424 JR NE,_5_L_17 00010A A 425 _5_L_16: A 426 ; 94 reverse(600,600); A 427 .line 94 00010A 1F7058 A 428 PUSH #88 00010D 1F7002 A 429 PUSH #2 000110 1F7058 A 430 PUSH #88 000113 1F7002 A 431 PUSH #2 000116 D6 02E4 A 432 CALL _reverse 000119 50E0 A 433 POP R0 00011B 50E0 A 434 POP R0 00011D 50E0 A 435 POP R0 00011F 50E0 A 436 POP R0 A 437 ; 95 } A 438 ; 96 else{status &= ~0x01;} A 439 .line 96 000121 8B 04 A 440 JR _5_L_19 000123 A 441 _5_L_17: 000123 59FE0005 A 442 ANDX _status+1,#254 A 443 ; 97 A 444 ; 98 while(!(PAIN & 0x08) && !(status & 0x01)) { 000127 A 445 _5_L_19: A 446 .line 98 000127 79080FD2 A 447 TMX 4050,#8 00012B EB 0C A 448 JR NE,_5_L_29 00012D 79010005 A 449 TMX _status+1,#1 000131 EB 06 A 450 JR NE,_5_L_29 A 451 ; 99 PBOUT=0x0a; // attack A 452 .line 99 000133 E90A0FD7 A 453 LDX 4055,#10 A 454 ; 100 } A 455 .line 100 000137 8B EE A 456 JR _5_L_19 000139 A 457 _5_L_29: A 458 ; 101 A 459 ; 102 if(index==0x01){ A 460 .line 102 000139 A9010000 A 461 CPX _index,#1 00013D 6B 15 A 462 JR Z,_5_L_24 00013F 8B 3E A 463 JR _5_L_37 A 464 ; 103 for(a=0;a