OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

[/] [tv80/] [trunk/] [tests/] [alu_optest.ast] - Blame information for rev 114

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 113 ghutchis
; Test of load opcodes
2
;
3
; Goes through most varieties of load opcode and tests for
4
; correct behavior.
5
 
6
    .module load_optest
7
 
8
;--------------------------------------------------------
9
; special function registers
10
;--------------------------------------------------------
11
_sim_ctl_port   =       0x0080
12
_msg_port       =       0x0081
13
_timeout_port   =       0x0082
14
_max_timeout_low        =       0x0083
15
_max_timeout_high       =       0x0084
16
_intr_cntdwn    =       0x0090
17
_cksum_value    =       0x0091
18
_cksum_accum    =       0x0092
19
_inc_on_read    =       0x0093
20
stack_end       =       0xFFFF
21
 
22
    .area INIT (ABS)
23
    .org  0
24
 
25
    jp      init
26
 
27
 
28
init:
29
    ld      sp, #stack_end
30
    jp      start
31
 
32
 
33
passed:
34
                ld      a, #0x0
35
                out     (_sim_ctl_port), a
36
                halt
37
 
38
failed:
39
                ld      a, #0x0
40
                out     (_sim_ctl_port), a
41
                halt
42
 
43
 
44
 
45
 
46
        ;; subroutine to print a message
47
        ;; called from within the "print" macro
48
        ;; expects address to be printed in hl
49
        ;; preserves all other registers
50
print_sub:
51
        push    bc
52
        ld      b, a
53
 
54
print_sub_loop:
55
        ld      a, (hl)
56
        cp      #0x0
57
        jp      z, print_sub_exit
58
        out     (_msg_port), a
59
        inc     hl
60
        jp      print_sub_loop
61
 
62
print_sub_exit:
63
        ld      a, b
64
        pop     bc
65
        ret
66
 
67
        ;; print a hex number between 0-255, stored in the A register
68
print_number:
69
        push    bc
70
        ld      b, a            ; store number to be printed in b
71
 
72 114 ghutchis
        and     #0xF0
73 113 ghutchis
        sra     a
74
        sra     a
75
        sra     a
76
        sra     a
77 114 ghutchis
        cp      a, #10
78 113 ghutchis
        jp      p, alpha_0
79
        add     #48             ; ordinal value of '0'
80
        out     (_msg_port), a
81
        jp      second_digit
82
alpha_0:
83
        add     #55              ; 'A' - 10
84
        out     (_msg_port), a
85
 
86
second_digit:
87
        ld      a, b
88 114 ghutchis
        and     #0x0F
89 113 ghutchis
 
90 114 ghutchis
        cp      a, #10
91 113 ghutchis
        jp      p, alpha_1
92 114 ghutchis
        add     #48
93 113 ghutchis
        out     (_msg_port), a
94
        jp      print_number_exit
95
 
96
alpha_1:
97
        add     #55              ; 'A' - 10
98
        out     (_msg_port), a
99
 
100
print_number_exit:
101
        pop     bc
102
        ret
103
 
104
fail_text: .ascii   "Test failed at checkpoint #"
105
        .db     #0x0
106
 
107
; expects failing message number in B
108
fail_routine:
109
        ld      hl, #fail_text
110
        call    print_sub       ; print out boilerplate text
111
        ld      a, b
112
 
113
        call    print_number    ; print out error number
114
 
115
        ld      a, #0x0a                ; print carriage return
116
        out     (_msg_port), a
117
        jp      failed
118
 
119
 
120
 
121
starting_test:  .ascii "Starting test"
122 114 ghutchis
        .db 0x0A .db 0x00
123 113 ghutchis
 
124
push_message: .ascii "push_0"
125
        .db 0xa
126
        .db 0x0
127
 
128
msg_ex_0: .ascii "ex_0" .db 0xa .db 0x0
129
msg_add_0: .ascii "add_0" .db 0xa .db 0x0
130
msg_adc_0: .ascii "adc_0" .db 0xa .db 0x0
131
msg_sub_0: .ascii "sub_0" .db 0xa .db 0x0
132
msg_sbc_0: .ascii "sbc_0" .db 0xa .db 0x0
133
msg_and_0: .ascii "and_0" .db 0xa .db 0x0
134
msg_or_0: .ascii "or_0" .db 0xa .db 0x0
135
msg_xor_0: .ascii "xor_0" .db 0xa .db 0x0
136
msg_cp_0: .ascii "cp_0" .db 0xa .db 0x0
137
msg_inc: .ascii "inc" .db 0xa .db 0x0
138
msg_dec: .ascii "dec" .db 0xa .db 0x0
139
msg_neg: .ascii "neg" .db 0xa .db 0x0
140
 
141
error_cnt:
142
        .db     0
143
 
144
        ;; Ordering of segments for the linker.
145
        .area   _HOME
146
        .area   _CODE
147
        .area   _GSINIT
148
        .area   _GSFINAL
149
 
150
        .area   _DATA
151
        .area   _BSS
152
        .area   _HEAP
153
 
154
        .area   _CODE
155
 
156
;------------------------------------------------------------
157
;   Beginning of test
158
;------------------------------------------------------------
159
 
160
start:
161
 
162
                ld      hl, #starting_test
163
                call    print_sub
164
 
165
                ld      a, #0x1
166
                ld      hl,#error_cnt
167
                ld      (hl),a                  ;clear error count
168
 
169
 
170
push_0:         ld      sp,#stack_end
171
                ld      hl, #push_message
172
                call    print_sub
173
                ld      bc,#0x1234
174
                push    bc
175
                ld      bc,#0
176
                pop     bc
177 114 ghutchis
                ld      a,#0x12      ;bjp was >#0x1234
178 113 ghutchis
                cp      b
179
                jr      z,push_1
180
        ld      b, #0
181
        jp      fail_routine
182 114 ghutchis
push_1:         ld      a,#0x34      ;bjp was >#0x1234
183 113 ghutchis
                cp      c
184
                jr      z,push_2
185
        ld      b, #1
186
        jp      fail_routine
187
push_2:         ld      de,#0x55aa
188
                push    de
189
                ld      de,#0
190
                pop     de
191
                ld      a,#0x55
192
                cp      d
193
                jr      z,push_3
194
        ld      b, #2
195
        jp      fail_routine
196
push_3:         ld      a,#0xaa
197
                cp      e
198
                jr      z,push_4
199
        ld      b, #3
200
        jp      fail_routine
201
push_4:         ld      hl,#0x7fff
202
                push    hl
203
                ld      hl,#0
204
                pop     hl
205
                ld      a,#0x7f
206
                cp      h
207
                jr      z,push_5
208
        ld      b, #4
209
        jp      fail_routine
210
push_5:         ld      a,#0xff
211
                cp      l
212
                jr      z,push_6
213
        ld      b, #5
214
        jp      fail_routine
215
push_6:         ld      a,#0x80
216
                push    af                      ;f depends on previous compare
217
                ld      hl,#0
218
                pop     hl
219
                cp      h
220
                jr      z,push_7
221
        ld      b, #6
222
        jp      fail_routine
223
push_7:         ld      a,l
224
                cp      #0x42
225
                jr      z,push_8
226
push_8:         ld      h,#0x55
227
                ld      l,#0x80+#0x41
228
                ld      a,#0
229
                push    hl
230
                pop     af
231
                jp      m,push_9
232
        ld      b, #8
233
        jp      fail_routine
234
push_9:         jr      z,push_10
235
        ld      b, #9
236
        jp      fail_routine
237
push_10:        jr      c,push_11
238
        ld      b, #10
239
        jp      fail_routine
240
push_11:        cp      #0x55
241
                jr      z,push_12
242
        ld      b, #11
243
        jp      fail_routine
244
push_12:        ld      ix,#0xaa55
245
                ld      bc,#0
246
                push    ix
247
                pop     bc
248
                ld      a,#0xaa
249
                cp      b
250
                jr      z,push_13
251
        ld      b, #12
252
        jp      fail_routine
253
push_13:        ld      a,#0x55
254
                cp      c
255
                jr      z,push_14
256
        ld      b, #13
257
        jp      fail_routine
258
push_14:        ld      iy,#0x7fff
259
                ld      de,#0
260
                push    iy
261
                pop     de
262
                ld      a,#0x7f
263
                cp      d
264
                jr      z,push_15
265
        ld      b, #14
266
        jp      fail_routine
267
push_15:        ld      a,#0xff
268
                cp      e
269
                jr      z,push_16
270
        ld      b, #15
271
        jp      fail_routine
272
push_16:        ld      de,#0x1234
273
                ld      ix,#0
274
                ld      hl,#0
275
                push    de
276
                pop     ix
277
                ld      sp,ix
278
                add     hl,sp
279 114 ghutchis
                ld      a,#0x12      ;bjp was >#0x1234
280 113 ghutchis
                cp      h
281
                jr      z,push_17
282
        ld      b, #16
283
        jp      fail_routine
284 114 ghutchis
push_17:        ld      a,#0x34      ;bjp was >#0x1234
285 113 ghutchis
                cp      l
286
                jr      z,push_18
287
        ld      b, #17
288
        jp      fail_routine
289
push_18:        ld      sp,#stack_end
290
                ld      bc,#0x55aa
291
                ld      iy,#0
292
                ld      hl,#0
293
                push    bc
294
                pop     iy
295
                ld      sp,iy
296
                add     hl,sp
297
                ld      a,#0x55
298
                cp      h
299
                jr      z,push_19
300
        ld      b, #18
301
        jp      fail_routine
302
push_19:        ld      a,#0xaa
303
                cp      l
304
                jr      z,push_20
305
        ld      b, #19
306
        jp      fail_routine
307
push_20:        ld      sp,#stack_end
308 114 ghutchis
        ld hl, #msg_ex_0
309 113 ghutchis
        call print_sub
310
ex_0:           ld      de,#0x1234
311
                ld      hl,#0xffff
312
                ex      de,hl
313
                ld      a,#0xff
314
                cp      d
315
                jr      z,ex_1
316
        ld      b, #0
317
        jp      fail_routine
318
ex_1:           cp      e
319
                jr      z,ex_2
320
        ld      b, #1
321
        jp      fail_routine
322 114 ghutchis
ex_2:           ld      a,#0x12      ;bjp was >#0x1234
323 113 ghutchis
                cp      h
324
                jr      z,ex_3
325
        ld      b, #2
326
        jp      fail_routine
327 114 ghutchis
ex_3:           ld      a,#0x34      ;bjp was >#0x1234
328 113 ghutchis
                cp      l
329
                jr      z,ex_4
330
        ld      b, #3
331
        jp      fail_routine
332
ex_4:           ld      h,#0
333
                ld      l,#0
334
                push    hl
335
                pop     af
336
                ex      af,af'
337
                ld      h,#0x7f
338
                ld      l,#0x80+#0x41
339
                push    hl
340
                pop     af
341
                ex      af,af'
342
                cp      #0
343
                jr      z,ex_5
344
        ld      b, #4
345
        jp      fail_routine
346
ex_5:           ex      af,af'
347
                jp      m,ex_6
348
        ld      b, #5
349
        jp      fail_routine
350
ex_6:           jr      z,ex_7
351
        ld      b, #6
352
        jp      fail_routine
353
ex_7:           cp      #0x7f
354
                jr      z,ex_8
355
        ld      b, #7
356
        jp      fail_routine
357
ex_8:           ld      hl,#0
358
                ld      bc,#0
359
                ld      de,#0
360
                exx
361
                ld      hl,#0x1234
362
                ld      bc,#0x7fff
363
                ld      de,#0xaa55
364
                exx
365
                ld      a,#0
366
                cp      h
367
                jr      z,ex_9
368
        ld      b, #8
369
        jp      fail_routine
370
ex_9:           cp      l
371
                jr      z,ex_10
372
        ld      b, #9
373
        jp      fail_routine
374
ex_10:          cp      d
375
                jr      z,ex_11
376
        ld      b, #10
377
        jp      fail_routine
378
ex_11:          cp      e
379
                jr      z,ex_12
380
        ld      b, #11
381
        jp      fail_routine
382
ex_12:          cp      b
383
                jr      z,ex_13
384
        ld      b, #12
385
        jp      fail_routine
386
ex_13:          cp      c
387
                jr      z,ex_14
388
        ld      b, #13
389
        jp      fail_routine
390
ex_14:          exx
391 114 ghutchis
                ld      a,#0x12      ;bjp was >#0x1234
392 113 ghutchis
                cp      h
393
                jr      z,ex_15
394
        ld      b, #14
395
        jp      fail_routine
396 114 ghutchis
ex_15:          ld      a,#0x34      ;bjp was >#0x1234
397 113 ghutchis
                cp      l
398
                jr      z,ex_16
399
        ld      b, #15
400
        jp      fail_routine
401
ex_16:          ld      a,#0xaa
402
                cp      d
403
                jr      z,ex_17
404
        ld      b, #16
405
        jp      fail_routine
406
ex_17:          ld      a,#0x55
407
                cp      e
408
                jr      z,ex_18
409
        ld      b, #17
410
        jp      fail_routine
411
ex_18:          ld      a,#0x7f
412
                cp      b
413
                jr      z,ex_19
414
        ld      b, #18
415
        jp      fail_routine
416
ex_19:          ld      a,#0xff
417
                cp      c
418
                jr      z,ex_20
419
        ld      b, #19
420
        jp      fail_routine
421
ex_20:          ld      bc,#0x55aa
422
                ld      hl,#0x7fff
423
                push    bc
424
                ex      (sp),hl
425
                pop     bc
426
                ld      a,#0x7f
427
                cp      b
428
                jr      z,ex_21
429
        ld      b, #20
430
        jp      fail_routine
431
ex_21:          ld      a,#0xff
432
                cp      c
433
                jr      z,ex_22
434
        ld      b, #21
435
        jp      fail_routine
436
ex_22:          ld      a,#0x55
437
                cp      h
438
                jr      z,ex_23
439
        ld      b, #22
440
        jp      fail_routine
441
ex_23:          ld      a,#0xaa
442
                cp      l
443
                jr      z,ex_24
444
        ld      b, #23
445
        jp      fail_routine
446
ex_24:          ld      bc,#0xffff
447
                ld      ix,#0x8000
448
                ld      hl,#0
449
                push    bc
450
                ex      (sp),ix
451
                pop     bc
452
                ld      sp,ix
453
                add     hl,sp
454
                ld      a,#0x80
455
                cp      b
456
                jr      z,ex_25
457
        ld      b, #24
458
        jp      fail_routine
459
ex_25:          ld      a,#0
460
                cp      c
461
                jr      z,ex_26
462
        ld      b, #25
463
        jp      fail_routine
464
ex_26:          ld      a,#0xff
465
                cp      h
466
                jr      z,ex_27
467
        ld      b, #26
468
        jp      fail_routine
469
ex_27:          cp      l
470
                jr      z,ex_28
471
        ld      b, #27
472
        jp      fail_routine
473
ex_28:          ld      sp,#stack_end
474
                ld      bc,#0x1234
475
                ld      iy,#0x7fff
476
                ld      hl,#0
477
                push    bc
478
                ex      (sp),iy
479
                pop     bc
480
                ld      sp,iy
481
                add     hl,sp
482
                ld      a,#0x7f
483
                cp      b
484
                jr      z,ex_29
485
        ld      b, #28
486
        jp      fail_routine
487
ex_29:          ld      a,#0xff
488
                cp      c
489
                jr      z,ex_30
490
        ld      b, #29
491
        jp      fail_routine
492 114 ghutchis
ex_30:          ld      a,#0x12      ;bjp was >#0x1234
493 113 ghutchis
                cp      h
494
                jr      z,ex_31
495
        ld      b, #30
496
        jp      fail_routine
497 114 ghutchis
ex_31:          ld      a,#0x34      ;bjp was >#0x1234
498 113 ghutchis
                cp      l
499
                jr      z,add_0
500
        ld      b, #31
501
        jp      fail_routine
502
add_0:          ld      sp,#stack_end ; reset stack after EX operations
503
                ld      hl, #msg_add_0
504
                call    print_sub
505
                ld      a,#0
506
                ld      b,#0x7f
507
                add     a,b
508
                cp      #0x7f
509
                jr      z,add_1
510
        ld      b, #0
511
        jp      fail_routine
512
add_1:          ld      a,#0
513
                ld      b,#0
514
                add     a,b
515
                jr      z,add_2
516
        ld      b, #1
517
        jp      fail_routine
518
add_2:          ld      b,#0x55
519
                add     a,b
520
                jr      nz,add_3
521
        ld      b, #2
522
        jp      fail_routine
523
add_3:          cp      #0x55
524
                jr      z,add_4
525
        ld      b, #3
526
        jp      fail_routine
527
add_4:          ld      a,#0xff
528
                ld      b,#1
529
                add     a,b
530
                jr      c,add_5
531
        ld      b, #4
532
        jp      fail_routine
533
add_5:          add     a,b
534
                jr      nc,add_6
535
        ld      b, #5
536
        jp      fail_routine
537
add_6:          ld      a,#0xff
538
                ld      b,#0
539
                add     a,b
540
                jp      m,add_7
541
        ld      b, #6
542
        jp      fail_routine
543
add_7:          ld      b,#1
544
                add     a,b
545
                jp      p,add_8
546
        ld      b, #7
547
        jp      fail_routine
548
add_8:          ld      a,#0x7f
549
                ld      b,#1
550
                add     a,b
551
                jp      pe,add_9
552
        ld      b, #8
553
        jp      fail_routine
554
add_9:          add     a,b
555
                jp      po,add_10
556
        ld      b, #9
557
        jp      fail_routine
558
add_10:         ld      a,#0x55
559
                ld      c,#2
560
                add     a,c
561
                cp      #0x55+2
562
                jr      z,add_11
563
        ld      b, #10
564
        jp      fail_routine
565
add_11:         ld      a,#0x80
566
                add     a,c
567
                cp      #0x80+2
568
                jr      z,add_12
569
        ld      b, #11
570
        jp      fail_routine
571
add_12:         ld      a,#0xaa
572
                ld      d,#0x55
573
                add     a,d
574
                cp      #0xaa+0x55
575
                jr      z,add_13
576
        ld      b, #12
577
        jp      fail_routine
578
add_13:         ld      a,#0xaa
579
                ld      e,#2
580
                add     a,e
581
                cp      #0xaa+2
582
                jr      z,add_14
583
        ld      b, #13
584
        jp      fail_routine
585
add_14:         ld      a,#0x55
586
                ld      h,#24
587
                add     a,h
588
                cp      #0x55+24
589
                jr      z,add_15
590
        ld      b, #14
591
        jp      fail_routine
592
add_15:         ld      a,#0x7f-10
593
                ld      l,#10
594
                add     a,l
595
                cp      #0x7f
596
                jr      z,add_16
597
        ld      b, #15
598
        jp      fail_routine
599
add_16:         ld      a,#1
600
                add     a,#0x7f
601
                jp      pe,add_17
602
        ld      b, #16
603
        jp      fail_routine
604
add_17:         jp      m,add_18
605
        ld      b, #17
606
        jp      fail_routine
607
add_18:         jr      nz,add_19
608
        ld      b, #18
609
        jp      fail_routine
610
add_19:         cp      #0x80
611
                jr      z,add_20
612
        ld      b, #19
613
        jp      fail_routine
614
add_20:         ld      a,#0x55
615
                add     a,#1
616
                jp      po,add_21
617
        ld      b, #20
618
        jp      fail_routine
619
add_21:         jp      p,add_22
620
        ld      b, #21
621
        jp      fail_routine
622
add_22:         jr      nc,add_23
623
        ld      b, #22
624
        jp      fail_routine
625
add_23:         cp      #0x55+1
626
                jr      z,add_24
627
        ld      b, #23
628
        jp      fail_routine
629
add_24:         ld      a,#0xff
630
                add     a,#1
631
                jr      c,add_25
632
        ld      b, #24
633
        jp      fail_routine
634
add_25:         jr      z,add_26
635
        ld      b, #25
636
        jp      fail_routine
637
add_26:         add     a,#1
638
                jr      nc,add_27
639
        ld      b, #26
640
        jp      fail_routine
641
add_27:         jr      nz,add_28
642
        ld      b, #27
643
        jp      fail_routine
644
add_28:         cp      #1
645
                jr      z,add_29
646
        ld      b, #28
647
        jp      fail_routine
648
add_29:         ld      hl,#var2
649
                ld      a,#2
650
                add     a,(hl)
651
                jp      po,add_30
652
        ld      b, #29
653
        jp      fail_routine
654
add_30:         jp      p,add_31
655
        ld      b, #30
656
        jp      fail_routine
657
add_31:         jr      nz,add_32
658
        ld      b, #31
659
        jp      fail_routine
660
add_32:         jr      nc,add_33
661
        ld      b, #32
662
        jp      fail_routine
663
add_33:         cp      #0x55+2
664
                jr      z,add_34
665
        ld      b, #33
666
        jp      fail_routine
667
add_34:         ld      hl,#var1
668
                ld      a,#1
669
                add     a,(hl)
670
                jr      c,add_35
671
        ld      b, #34
672
        jp      fail_routine
673
add_35:         jr      z,add_36
674
        ld      b, #35
675
        jp      fail_routine
676
add_36:         ld      hl,#var5
677
                ld      a,#1
678
                add     a,(hl)
679
                jp      m,add_37
680
        ld      b, #36
681
        jp      fail_routine
682
add_37:         jp      pe,add_38
683
        ld      b, #37
684
        jp      fail_routine
685
add_38:         cp      #0x80
686
                jr      z,add_39
687
        ld      b, #38
688
        jp      fail_routine
689
add_39:         ld      ix,#var3
690
                ld      a,#1
691
                add     a,-1(ix)
692
                jp      po,add_40
693
        ld      b, #39
694
        jp      fail_routine
695
add_40:         jp      p,add_41
696
        ld      b, #40
697
        jp      fail_routine
698
add_41:         jr      nz,add_42
699
        ld      b, #41
700
        jp      fail_routine
701
add_42:         jr      nc,add_43
702
        ld      b, #42
703
        jp      fail_routine
704
add_43:         cp      #0x55+1
705
                jr      z,add_44
706
        ld      b, #43
707
        jp      fail_routine
708
add_44:         ld      a,#1
709
                add     a,2(ix)
710
                jp      pe,add_45
711
        ld      b, #44
712
        jp      fail_routine
713
add_45:         jp      m,add_46
714
        ld      b, #45
715
        jp      fail_routine
716
add_46:         cp      #0x80
717
                jr      z,add_47
718
        ld      b, #46
719
        jp      fail_routine
720
add_47:         ld      a,#1
721
                add     a,-2(ix)
722
                jr      c,add_48
723
        ld      b, #47
724
        jp      fail_routine
725
add_48:         jr      z,add_49
726
        ld      b, #48
727
        jp      fail_routine
728
add_49:         add     a,#1
729
                jr      nc,add_50
730
        ld      b, #49
731
        jp      fail_routine
732
add_50:         jr      nz,add_51
733
        ld      b, #50
734
        jp      fail_routine
735
add_51:         cp      #1
736
                jr      z,add_52
737
        ld      b, #51
738
        jp      fail_routine
739
add_52:         ld      iy,#var3
740
                ld      a,#10
741
                add     a,-1(iy)
742
                jp      po,add_53
743
        ld      b, #52
744
        jp      fail_routine
745
add_53:         jp      p,add_54
746
        ld      b, #53
747
        jp      fail_routine
748
add_54:         jr      nz,add_55
749
        ld      b, #54
750
        jp      fail_routine
751
add_55:         jr      nc,add_56
752
        ld      b, #55
753
        jp      fail_routine
754
add_56:         cp      #0x55+10
755
                jr      z,add_57
756
        ld      b, #56
757
        jp      fail_routine
758
add_57:         ld      a,#1
759
                add     a,2(iy)
760
                jp      pe,add_58
761
        ld      b, #57
762
        jp      fail_routine
763
add_58:         jp      m,add_59
764
        ld      b, #58
765
        jp      fail_routine
766
add_59:         add     a,#1
767
                jp      po,add_60
768
        ld      b, #59
769
        jp      fail_routine
770
add_60:         cp      #0x80+1
771
                jr      z,add_61
772
        ld      b, #60
773
        jp      fail_routine
774
add_61:         ld      a,#1
775
                add     a,-2(iy)
776
                jr      z,add_62
777
        ld      b, #61
778
        jp      fail_routine
779
add_62:         jr      c,add_63
780
        ld      b, #62
781
        jp      fail_routine
782
add_63:         add     a,#1
783
                jr      nc,add_64
784
        ld      b, #63
785
        jp      fail_routine
786
add_64:         jr      nz,add_65
787
        ld      b, #64
788
        jp      fail_routine
789
add_65:         cp      #1
790
                jr      z,add_66
791
        ld      b, #65
792
        jp      fail_routine
793
add_66:         ld      a,#0xff
794
                add     a,#0x80
795
                jp      p,add_67
796
        ld      b, #66
797
        jp      fail_routine
798
add_67:         jp      pe,add_68
799
        ld      b, #67
800
        jp      fail_routine
801
add_68:         jr      c,add_69
802
        ld      b, #68
803
        jp      fail_routine
804
add_69:         add     a,#1
805
                jp      pe,add_70
806
        ld      b, #69
807
        jp      fail_routine
808
add_70:         jp      m,add_71
809
        ld      b, #70
810
        jp      fail_routine
811
add_71:         jr      nc,add_72
812
        ld      b, #71
813
        jp      fail_routine
814
add_72:         add     a,#1
815
                jp      po,add_73
816
        ld      b, #72
817
        jp      fail_routine
818
add_73:         cp      #0x80+1
819
                jr      z,adc_0
820
        ld      b, #73
821
        jp      fail_routine
822
adc_0:          nop
823 114 ghutchis
        ld hl, #msg_adc_0
824 113 ghutchis
        call print_sub
825
                ld      a,#0                 ;clear cry
826
                add     a,#0
827
                ld      b,#0x7f
828
                adc     a,b                  ;a=7f cry=0
829
                jp      p,adc_1
830
        ld      b, #0
831
        jp      fail_routine
832
adc_1:          jp      po,adc_2
833
        ld      b, #1
834
        jp      fail_routine
835
adc_2:          jr      nc,adc_3
836
        ld      b, #2
837
        jp      fail_routine
838
adc_3:          jr      nz,adc_4
839
        ld      b, #3
840
        jp      fail_routine
841
adc_4:          ld      b,#1
842
                adc     a,b                     ;a=80 cry=0
843
                jp      pe,adc_5                ;jp  ofl
844
        ld      b, #4
845
        jp      fail_routine
846
adc_5:          jp      m,adc_6
847
        ld      b, #5
848
        jp      fail_routine
849
adc_6:          cp      #0x80
850
                jr      z,adc_7                 ;z=0  ofl=0 cry=0 (borrow)
851
        ld      b, #6
852
        jp      fail_routine
853
adc_7:          ld      a,#0xff
854
                ld      b,#1
855
                adc     a,b                      ;ff+1+0
856
                jr      c,adc_8
857
        ld      b, #7
858
        jp      fail_routine
859
adc_8:          jr      z,adc_9
860
        ld      b, #8
861
        jp      fail_routine
862
adc_9:          adc     a,b
863
                jr      nc,adc_10
864
        ld      b, #9
865
        jp      fail_routine
866
adc_10:         jr      nz,adc_11
867
        ld      b, #10
868
        jp      fail_routine
869
adc_11:         cp      #2
870
                jr      z,adc_12
871
        ld      b, #11
872
        jp      fail_routine
873
adc_12:         ld      a,#0xff
874
                ld      c,#0
875
                adc     a,c
876
                jp      m,adc_13
877
        ld      b, #12
878
        jp      fail_routine
879
adc_13:         jr      nc,adc_14
880
        ld      b, #13
881
        jp      fail_routine
882
adc_14:         ld      c,#2
883
                adc     a,c
884
                jp      p,adc_15
885
        ld      b, #14
886
        jp      fail_routine
887
adc_15:         jr      c,adc_16
888
        ld      b, #15
889
        jp      fail_routine
890
adc_16:         ld      c,#0
891
                adc     a,c
892
                cp      #2
893
                jr      z,adc_17
894
        ld      b, #16
895
        jp      fail_routine
896
adc_17:         ld      a,#0xff
897
                ld      d,#1
898
                adc     a,d
899
                jr      c,adc_18
900
        ld      b, #17
901
        jp      fail_routine
902
adc_18:         ld      d,#0
903
                adc     a,d
904
                jr      nc,adc_19
905
        ld      b, #18
906
        jp      fail_routine
907
adc_19:         cp      #1
908
                jr      z,adc_20
909
        ld      b, #19
910
        jp      fail_routine
911
adc_20:         ld      a,#0xaa
912
                ld      e,#0x7f
913
                adc     a,e
914
                jr      c,adc_21
915
        ld      b, #20
916
        jp      fail_routine
917
adc_21:         ld      e,#0x2
918
                adc     a,e
919
                cp      #0x55
920
                jr      z,adc_22
921
        ld      b, #21
922
        jp      fail_routine
923
adc_22:         ld      a,#0xff
924
                ld      h,#1
925
                adc     a,h
926
                jr      c,adc_23
927
        ld      b, #22
928
        jp      fail_routine
929
adc_23:         adc     a,h
930
                cp      #2
931
                jr      z,adc_24
932
        ld      b, #23
933
        jp      fail_routine
934
adc_24:         ld      a,#0xff
935
                ld      l,#1
936
                adc     a,l
937
                jr      c,adc_25
938
        ld      b, #24
939
        jp      fail_routine
940
adc_25:         adc     a,l
941
                cp      #2
942
                jr      z,adc_26
943
        ld      b, #25
944
        jp      fail_routine
945
adc_26:         ld      a,#0
946
                adc     a,#0x7f
947
                jp      po,adc_27
948
        ld      b, #26
949
        jp      fail_routine
950
adc_27:         jp      p,adc_28
951
        ld      b, #27
952
        jp      fail_routine
953
adc_28:         jr      nc,adc_29
954
        ld      b, #28
955
        jp      fail_routine
956
adc_29:         jr      nz,adc_30
957
        ld      b, #29
958
        jp      fail_routine
959
adc_30:         adc     a,#1
960
                jp      pe,adc_31
961
        ld      b, #30
962
        jp      fail_routine
963
adc_31:         jp      m,adc_32
964
        ld      b, #31
965
        jp      fail_routine
966
adc_32:         cp      #0x80
967
                jr      z,adc_33
968
        ld      b, #32
969
        jp      fail_routine
970
adc_33:         ld      a,#0xff
971
                adc     a,#1
972
                jr      c,adc_34
973
        ld      b, #33
974
        jp      fail_routine
975
adc_34:         jr      z,adc_35
976
        ld      b, #34
977
        jp      fail_routine
978
adc_35:         adc     a,#1
979
                jr      nc,adc_36
980
        ld      b, #35
981
        jp      fail_routine
982
adc_36:         jr      nz,adc_37
983
        ld      b, #36
984
        jp      fail_routine
985
adc_37:         cp      #2
986
                jr      z,adc_38
987
        ld      b, #37
988
        jp      fail_routine
989
adc_38:         ld      hl,#var5
990
                ld      a,#0
991
                adc     a,(hl)
992
                jp      p,adc_39
993
        ld      b, #38
994
        jp      fail_routine
995
adc_39:         jp      po,adc_40
996
        ld      b, #39
997
        jp      fail_routine
998
adc_40:         jr      nz,adc_41
999
        ld      b, #40
1000
        jp      fail_routine
1001
adc_41:         jr      nc,adc_42
1002
        ld      b, #41
1003
        jp      fail_routine
1004
adc_42:         ld      a,#1
1005
                adc     a,(hl)
1006
                jp      m,adc_43
1007
        ld      b, #42
1008
        jp      fail_routine
1009
adc_43:         jp      pe,adc_44
1010
        ld      b, #43
1011
        jp      fail_routine
1012
adc_44:         cp      #0x80
1013
                jr      z,adc_45
1014
        ld      b, #44
1015
        jp      fail_routine
1016
adc_45:         ld      hl,#var1
1017
                ld      a,#1
1018
                adc     a,(hl)
1019
                jr      z,adc_46
1020
        ld      b, #45
1021
        jp      fail_routine
1022
adc_46:         jr      c,adc_47
1023
        ld      b, #46
1024
        jp      fail_routine
1025
adc_47:         ld      hl,#var2
1026
                adc     a,(hl)
1027
                jr      nc,adc_48
1028
        ld      b, #47
1029
        jp      fail_routine
1030
adc_48:         jr      nz,adc_49
1031
        ld      b, #48
1032
        jp      fail_routine
1033
adc_49:         cp      #0x55+1
1034
                jr      z,adc_50
1035
        ld      b, #49
1036
        jp      fail_routine
1037
adc_50:         ld      ix,#var3
1038
                ld      a,#0
1039
                adc     a,2(ix)
1040
                jp      p,adc_51
1041
        ld      b, #50
1042
        jp      fail_routine
1043
adc_51:         jp      po,adc_52
1044
        ld      b, #51
1045
        jp      fail_routine
1046
adc_52:         jr      nc,adc_53
1047
        ld      b, #52
1048
        jp      fail_routine
1049
adc_53:         jr      nz,adc_54
1050
        ld      b, #53
1051
        jp      fail_routine
1052
adc_54:         ld      a,#1
1053
                adc     a,2(ix)
1054
                jp      m,adc_55
1055
        ld      b, #54
1056
        jp      fail_routine
1057
adc_55:         jp      pe,adc_56
1058
        ld      b, #55
1059
        jp      fail_routine
1060
adc_56:         cp      #0x80
1061
                jr      z,adc_57
1062
        ld      b, #56
1063
        jp      fail_routine
1064
adc_57:         ld      a,#1
1065
                adc     a,-2(ix)
1066
                jr      c,adc_58
1067
        ld      b, #57
1068
        jp      fail_routine
1069
adc_58:         jr      z,adc_59
1070
        ld      b, #58
1071
        jp      fail_routine
1072
adc_59:         adc     a,-1(ix)
1073
                jr      nc,adc_60
1074
        ld      b, #59
1075
        jp      fail_routine
1076
adc_60:         jr      nz,adc_61
1077
        ld      b, #60
1078
        jp      fail_routine
1079
adc_61:         cp      #0x55+1
1080
                jr      z,adc_62
1081
        ld      b, #61
1082
        jp      fail_routine
1083
adc_62:         ld      iy,#var3
1084
                ld      a,#0
1085
                adc     a,2(ix)
1086
                jp      p,adc_63
1087
        ld      b, #62
1088
        jp      fail_routine
1089
adc_63:         jp      po,adc_64
1090
        ld      b, #63
1091
        jp      fail_routine
1092
adc_64:         jr      nc,adc_65
1093
        ld      b, #64
1094
        jp      fail_routine
1095
adc_65:         jr      nz,adc_66
1096
        ld      b, #65
1097
        jp      fail_routine
1098
adc_66:         ld      a,#1
1099
                adc     a,2(iy)
1100
                jp      m,adc_67
1101
        ld      b, #66
1102
        jp      fail_routine
1103
adc_67:         jp      pe,adc_68
1104
        ld      b, #67
1105
        jp      fail_routine
1106
adc_68:         cp      #0x80
1107
                jr      z,adc_69
1108
        ld      b, #68
1109
        jp      fail_routine
1110
adc_69:         ld      a,#1
1111
                adc     a,-2(iy)
1112
                jr      c,adc_70
1113
        ld      b, #69
1114
        jp      fail_routine
1115
adc_70:         jr      z,adc_71
1116
        ld      b, #70
1117
        jp      fail_routine
1118
adc_71:         adc     a,-1(iy)
1119
                jr      nc,adc_72
1120
        ld      b, #71
1121
        jp      fail_routine
1122
adc_72:         jr      nz,adc_73
1123
        ld      b, #72
1124
        jp      fail_routine
1125
adc_73:         cp      #0x55+1
1126
                jr      z,adc_74
1127
        ld      b, #73
1128
        jp      fail_routine
1129
adc_74:         ld      a,#0xff
1130
                add     a,#0
1131
                adc     a,#0x80
1132
                jp      p,adc_75
1133
        ld      b, #74
1134
        jp      fail_routine
1135
adc_75:         jp      pe,adc_76
1136
        ld      b, #75
1137
        jp      fail_routine
1138
adc_76:         jr      nz,adc_77
1139
        ld      b, #76
1140
        jp      fail_routine
1141
adc_77:         adc     a,#0
1142
                jp      m,adc_78
1143
        ld      b, #77
1144
        jp      fail_routine
1145
adc_78:         jp      pe,adc_79
1146
        ld      b, #78
1147
        jp      fail_routine
1148
adc_79:         adc     a,#1
1149
                jp      po,adc_80
1150
        ld      b, #79
1151
        jp      fail_routine
1152
adc_80:         cp      #0x80+1
1153
                jr      z,sub_0
1154
        ld      b, #80
1155
        jp      fail_routine
1156
sub_0:          nop
1157 114 ghutchis
        ld hl, #msg_sub_0
1158 113 ghutchis
        call print_sub
1159
                ld      a,#0
1160
                ld      b,#1
1161
                sub     a,b
1162
                jp      m,sub_1
1163
        ld      b, #0
1164
        jp      fail_routine
1165
sub_1:          jp      po,sub_2
1166
        ld      b, #1
1167
        jp      fail_routine
1168
sub_2:          jr      c,sub_3
1169
        ld      b, #2
1170
        jp      fail_routine
1171
sub_3:          jr      nz,sub_4
1172
        ld      b, #3
1173
        jp      fail_routine
1174
sub_4:          sub     a,b
1175
                jr      nc,sub_5
1176
        ld      b, #4
1177
        jp      fail_routine
1178
sub_5:          cp      #0xff-1
1179
                jr      z,sub_6
1180
        ld      b, #5
1181
        jp      fail_routine
1182
sub_6:          ld      a,#1
1183
                ld      b,#0
1184
                sub     a,b
1185
                jr      nz,sub_7
1186
        ld      b, #6
1187
        jp      fail_routine
1188
sub_7:          jp      p,sub_8
1189
        ld      b, #7
1190
        jp      fail_routine
1191
sub_8:          ld      b,#1
1192
                sub     a,b
1193
                jr      z,sub_9
1194
        ld      b, #8
1195
        jp      fail_routine
1196
sub_9:          sub     a,b
1197
                jp      m,sub_10
1198
        ld      b, #9
1199
        jp      fail_routine
1200
sub_10:         cp      #0xff
1201
                jr      z,sub_11
1202
        ld      b, #10
1203
        jp      fail_routine
1204
sub_11:         ld      a,#0x80
1205
                ld      b,#0x7f
1206
                sub     a,b
1207
                jp      pe,sub_12
1208
        ld      b, #11
1209
        jp      fail_routine
1210
sub_12:         sub     a,b
1211
                jp      po,sub_13
1212
        ld      b, #12
1213
        jp      fail_routine
1214
sub_13:         cp      #0x80+2
1215
                jr      z,sub_14
1216
        ld      b, #13
1217
        jp      fail_routine
1218
sub_14:         ld      a,#0x55
1219
                ld      c,#0x55
1220
                sub     a,c
1221
                jr      z,sub_15
1222
        ld      b, #14
1223
        jp      fail_routine
1224
sub_15:         ld      c,#1
1225
                sub     a,c
1226
                jp      m,sub_16
1227
        ld      b, #15
1228
        jp      fail_routine
1229
sub_16:         jr      c,sub_17
1230
        ld      b, #16
1231
        jp      fail_routine
1232
sub_17:         cp      #0xff
1233
                jr      z,sub_18
1234
        ld      b, #17
1235
        jp      fail_routine
1236
sub_18:         ld      a,#0x55
1237
                ld      d,#0x7f
1238
                sub     a,d
1239
                jr      c,sub_19
1240
        ld      b, #18
1241
        jp      fail_routine
1242
sub_19:         cp      #0x55-0x7f
1243
                jr      z,sub_20
1244
        ld      b, #19
1245
        jp      fail_routine
1246
sub_20:         ld      a,#0
1247
                ld      e,#0xff
1248
                sub     a,e
1249
                jr      c,sub_21
1250
        ld      b, #20
1251
        jp      fail_routine
1252
sub_21:         cp      #1
1253
                jr      z,sub_22
1254
        ld      b, #21
1255
        jp      fail_routine
1256
sub_22:         ld      a,#0xff
1257
                ld      h,#0x80
1258
                sub     a,h
1259
                jp      p,sub_23
1260
        ld      b, #22
1261
        jp      fail_routine
1262
sub_23:         cp      #0x7f
1263
                jr      z,sub_24
1264
        ld      b, #23
1265
        jp      fail_routine
1266
sub_24:         ld      a,#0xaa
1267
                ld      l,#0xff
1268
                sub     a,l
1269
                jr      c,sub_25
1270
        ld      b, #24
1271
        jp      fail_routine
1272
sub_25:         cp      #0xaa+1
1273
                jr      z,sub_26
1274
        ld      b, #25
1275
        jp      fail_routine
1276
sub_26:         ld      a,#0x7f
1277
                sub     a,#0xff
1278
                jp      pe,sub_27
1279
        ld      b, #26
1280
        jp      fail_routine
1281
sub_27:         jp      m,sub_28
1282
        ld      b, #27
1283
        jp      fail_routine
1284
sub_28:         sub     a,#1
1285
                jp      p,sub_29
1286
        ld      b, #28
1287
        jp      fail_routine
1288
sub_29:         sub     a,#1
1289
                jp      po,sub_30
1290
        ld      b, #29
1291
        jp      fail_routine
1292
sub_30:         jr      nz,sub_31
1293
        ld      b, #30
1294
        jp      fail_routine
1295
sub_31:         sub     a,#0x7f-1
1296
                jr      z,sub_32
1297
        ld      b, #31
1298
        jp      fail_routine
1299
sub_32:         ld      a,#0
1300
                sub     a,#0xff
1301
                jr      c,sub_33
1302
        ld      b, #32
1303
        jp      fail_routine
1304
sub_33:         sub     a,#1
1305
                jr      z,sub_34
1306
        ld      b, #33
1307
        jp      fail_routine
1308
sub_34:         jr      nc,sub_35
1309
        ld      b, #34
1310
        jp      fail_routine
1311
sub_35:         ld      hl,#var1
1312
                ld      a,#0x7f
1313
                sub     a,(hl)
1314
                jp      m,sub_36
1315
        ld      b, #35
1316
        jp      fail_routine
1317
sub_36:         jp      pe,sub_37
1318
        ld      b, #36
1319
        jp      fail_routine
1320
sub_37:         jr      c,sub_38
1321
        ld      b, #37
1322
        jp      fail_routine
1323
sub_38:         ld      hl,#var3
1324
                sub     a,(hl)
1325
                jp      p,sub_39
1326
        ld      b, #38
1327
        jp      fail_routine
1328
sub_39:         jp      po,sub_40
1329
        ld      b, #39
1330
        jp      fail_routine
1331
sub_40:
1332
        jr      nc,sub_41
1333
        ld      b, #40
1334
        jp      fail_routine
1335
sub_41:
1336
        jr      z,sub_42
1337
        ld      b, #40
1338
        jp      fail_routine
1339
sub_42:         ld      hl,#var2
1340
                sub     a,(hl)
1341
                jr      nz,sub_43
1342
        ld      b, #42
1343
        jp      fail_routine
1344
sub_43:         cp      #0xaa+1
1345
                jr      z,sub_44
1346
        ld      b, #43
1347
        jp      fail_routine
1348
sub_44:         ld      ix,#var3
1349
                ld      a,#0x7f
1350
                sub     a,-2(ix)
1351
                jp      m,sub_45
1352
        ld      b, #44
1353
        jp      fail_routine
1354
sub_45:         jp      pe,sub_46
1355
        ld      b, #45
1356
        jp      fail_routine
1357
sub_46:         jr      c,sub_47
1358
        ld      b, #46
1359
        jp      fail_routine
1360
sub_47:         sub     a,(ix)
1361
                jp      p,sub_48
1362
        ld      b, #47
1363
        jp      fail_routine
1364
sub_48:         jp      po,sub_49
1365
        ld      b, #48
1366
        jp      fail_routine
1367
sub_49:         jr      nc,sub_50
1368
        ld      b, #49
1369
        jp      fail_routine
1370
sub_50:         jr      z,sub_51
1371
        ld      b, #50
1372
        jp      fail_routine
1373
sub_51:         sub     a,2(ix)
1374
                jr      nz,sub_52
1375
        ld      b, #51
1376
        jp      fail_routine
1377
sub_52:         cp      #0x80+1
1378
                jr      z,sub_53
1379
        ld      b, #52
1380
        jp      fail_routine
1381
sub_53:         ld      iy,#var3
1382
                ld      a,#0x7f
1383
                sub     a,-2(iy)
1384
                jp      m,sub_54
1385
        ld      b, #53
1386
        jp      fail_routine
1387
sub_54:         jp      pe,sub_55
1388
        ld      b, #54
1389
        jp      fail_routine
1390
sub_55:         jr      c,sub_56
1391
        ld      b, #55
1392
        jp      fail_routine
1393
sub_56:         jr      nz,sub_57
1394
        ld      b, #56
1395
        jp      fail_routine
1396
sub_57:         sub     a,(iy)
1397
                jp      p,sub_58
1398
        ld      b, #57
1399
        jp      fail_routine
1400
sub_58:         jp      po,sub_59
1401
        ld      b, #58
1402
        jp      fail_routine
1403
sub_59:         jr      nc,sub_60
1404
        ld      b, #59
1405
        jp      fail_routine
1406
sub_60:         jr      z,sub_61
1407
        ld      b, #60
1408
        jp      fail_routine
1409
sub_61:         sub     a,2(iy)
1410
                jr      nz,sub_62
1411
        ld      b, #61
1412
        jp      fail_routine
1413
sub_62:         cp      #0x80+1
1414
                jr      z,sbc_0
1415
        ld      b, #62
1416
        jp      fail_routine
1417
sbc_0:          nop
1418 114 ghutchis
        ld hl, #msg_sbc_0
1419 113 ghutchis
        call print_sub
1420
                ld      a,#0x7f
1421
                ld      b,#0
1422
                sub     a,b                     ;clear carry flag
1423
                ld      b,#0xff
1424
                sbc     a,b
1425
                jp      m,sbc_1
1426
        ld      b, #0
1427
        jp      fail_routine
1428
sbc_1:          jp      pe,sbc_2
1429
        ld      b, #1
1430
        jp      fail_routine
1431
sbc_2:          jr      c,sbc_3
1432
        ld      b, #2
1433
        jp      fail_routine
1434
sbc_3:          jr      nz,sbc_4
1435
        ld      b, #3
1436
        jp      fail_routine
1437
sbc_4:          ld      b,#0x7f
1438
                sbc     a,b
1439
                jp      p,sbc_5
1440
        ld      b, #4
1441
        jp      fail_routine
1442
sbc_5:          jp      pe,sbc_6
1443
        ld      b, #5
1444
        jp      fail_routine
1445
sbc_6:          jr      nc,sbc_7
1446
        ld      b, #6
1447
        jp      fail_routine
1448
sbc_7:          jr      z,sbc_8
1449
        ld      b, #7
1450
        jp      fail_routine
1451
sbc_8:          ld      b,#0xff
1452
                sbc     a,b
1453
                jp      po,sbc_9
1454
        ld      b, #8
1455
        jp      fail_routine
1456
sbc_9:          jr      nz,sbc_10
1457
        ld      b, #9
1458
        jp      fail_routine
1459
sbc_10:         ld      b,#0
1460
                sbc     a,b
1461
                jr      z,sbc_11
1462
        ld      b, #10
1463
        jp      fail_routine
1464
sbc_11:         ld      a,#0xaa
1465
                ld      c,#0xff
1466
                sbc     a,c
1467
                jr      c,sbc_12
1468
        ld      b, #11
1469
        jp      fail_routine
1470
sbc_12:         ld      c,#0
1471
                sbc     a,c
1472
                jr      nc,sbc_13
1473
        ld      b, #12
1474
        jp      fail_routine
1475
sbc_13:         cp      #0xaa
1476
                jr      z,sbc_14
1477
        ld      b, #13
1478
        jp      fail_routine
1479
sbc_14:         ld      a,#0x55
1480
                ld      d,#0xff
1481
                sbc     a,d
1482
                jr      c,sbc_15
1483
        ld      b, #14
1484
        jp      fail_routine
1485
sbc_15:         ld      d,#0
1486
                sbc     a,d
1487
                jr      nc,sbc_16
1488
        ld      b, #15
1489
        jp      fail_routine
1490
sbc_16:         cp      #0x55
1491
                jr      z,sbc_17
1492
        ld      b, #16
1493
        jp      fail_routine
1494
sbc_17:         ld      a,#0xaa
1495
                ld      e,#0xff
1496
                sbc     a,e
1497
                jr      c,sbc_18
1498
        ld      b, #17
1499
        jp      fail_routine
1500
sbc_18:         ld      e,#0
1501
                sbc     a,e
1502
                jr      nc,sbc_19
1503
        ld      b, #18
1504
        jp      fail_routine
1505
sbc_19:         cp      #0xaa
1506
                jr      z,sbc_20
1507
        ld      b, #19
1508
        jp      fail_routine
1509
sbc_20:         ld      a,#0x55
1510
                ld      h,#0xff
1511
                sbc     a,h
1512
                jr      c,sbc_21
1513
        ld      b, #20
1514
        jp      fail_routine
1515
sbc_21:         ld      h,#0
1516
                sbc     a,h
1517
                jr      nc,sbc_22
1518
        ld      b, #21
1519
        jp      fail_routine
1520
sbc_22:         cp      #0x55
1521
                jr      z,sbc_23
1522
        ld      b, #22
1523
        jp      fail_routine
1524
sbc_23:         ld      a,#0xaa
1525
                ld      l,#0xff
1526
                sbc     a,l
1527
                jr      c,sbc_24
1528
        ld      b, #23
1529
        jp      fail_routine
1530
sbc_24:         ld      l,#0
1531
                sbc     a,l
1532
                jr      nc,sbc_25
1533
        ld      b, #24
1534
        jp      fail_routine
1535
sbc_25:         cp      #0xaa
1536
                jr      z,sbc_26
1537
        ld      b, #25
1538
        jp      fail_routine
1539
sbc_26:         ld      a,#0x7f
1540
                sbc     a,#0xff
1541
                jp      m,sbc_27
1542
        ld      b, #26
1543
        jp      fail_routine
1544
sbc_27:         jp      pe,sbc_28
1545
        ld      b, #27
1546
        jp      fail_routine
1547
sbc_28:         jr      c,sbc_29
1548
        ld      b, #28
1549
        jp      fail_routine
1550
sbc_29:         jr      nz,sbc_30
1551
        ld      b, #29
1552
        jp      fail_routine
1553
sbc_30:         sbc     a,#0x7f
1554
                jp      p,sbc_31
1555
        ld      b, #30
1556
        jp      fail_routine
1557
sbc_31:         jp      pe,sbc_32
1558
        ld      b, #31
1559
        jp      fail_routine
1560
sbc_32:         jr      nc,sbc_33
1561
        ld      b, #32
1562
        jp      fail_routine
1563
sbc_33:         jr      z,sbc_34
1564
        ld      b, #33
1565
        jp      fail_routine
1566
sbc_34:         sbc     a,#0xff
1567
                jr      nz,sbc_35
1568
        ld      b, #34
1569
        jp      fail_routine
1570
sbc_35:         cp      #1
1571
                jr      z,sbc_36
1572
        ld      b, #35
1573
        jp      fail_routine
1574
sbc_36:         ld      hl,#var1
1575
                ld      a,#0x7f
1576
                sbc     a,(hl)
1577
                jp      m,sbc_37
1578
        ld      b, #36
1579
        jp      fail_routine
1580
sbc_37:         jp      pe,sbc_38
1581
        ld      b, #37
1582
        jp      fail_routine
1583
sbc_38:         jr      c,sbc_39
1584
        ld      b, #38
1585
        jp      fail_routine
1586
sbc_39:         jr      nz,sbc_40
1587
        ld      b, #39
1588
        jp      fail_routine
1589
sbc_40:         ld      hl,#var5
1590
                sbc     a,(hl)
1591
                jp      p,sbc_41
1592
        ld      b, #40
1593
        jp      fail_routine
1594
sbc_41:         jp      pe,sbc_42
1595
        ld      b, #41
1596
        jp      fail_routine
1597
sbc_42:         jr      nc,sbc_43
1598
        ld      b, #42
1599
        jp      fail_routine
1600
sbc_43:         jr      z,sbc_44
1601
        ld      b, #43
1602
        jp      fail_routine
1603
sbc_44:         ld      hl,#var2
1604
                sbc     a,(hl)
1605
                jr      nz,sbc_45
1606
        ld      b, #44
1607
        jp      fail_routine
1608
sbc_45:         cp      #0xaa+1
1609
                jr      z,sbc_46
1610
        ld      b, #45
1611
        jp      fail_routine
1612
sbc_46:         ld      ix,#var3
1613
                ld      a,#0x7f
1614
                sbc     a,-2(ix)
1615
                jp      m,sbc_47
1616
        ld      b, #46
1617
        jp      fail_routine
1618
sbc_47:         jp      pe,sbc_48
1619
        ld      b, #47
1620
        jp      fail_routine
1621
sbc_48:         jr      c,sbc_49
1622
        ld      b, #48
1623
        jp      fail_routine
1624
sbc_49:         jr      nz,sbc_50
1625
        ld      b, #49
1626
        jp      fail_routine
1627
sbc_50:         sbc     a,2(ix)
1628
                jp      p,sbc_51
1629
        ld      b, #50
1630
        jp      fail_routine
1631
sbc_51:         jp      pe,sbc_52
1632
        ld      b, #51
1633
        jp      fail_routine
1634
sbc_52:         jr      nc,sbc_53
1635
        ld      b, #52
1636
        jp      fail_routine
1637
sbc_53:         jr      z,sbc_54
1638
        ld      b, #53
1639
        jp      fail_routine
1640
sbc_54:         sbc     a,-1(ix)
1641
                jr      nz,sbc_55
1642
        ld      b, #54
1643
        jp      fail_routine
1644
sbc_55:         cp      #0xaa+1
1645
                jr      z,sbc_56
1646
        ld      b, #55
1647
        jp      fail_routine
1648
sbc_56:         ld      iy,#var3
1649
                ld      a,#0x7f
1650
                sbc     a,-2(ix)
1651
                jp      m,sbc_57
1652
        ld      b, #56
1653
        jp      fail_routine
1654
sbc_57:         jp      pe,sbc_58
1655
        ld      b, #57
1656
        jp      fail_routine
1657
sbc_58:         jr      c,sbc_59
1658
        ld      b, #58
1659
        jp      fail_routine
1660
sbc_59:         jr      nz,sbc_60
1661
        ld      b, #59
1662
        jp      fail_routine
1663
sbc_60:         sbc     a,2(ix)
1664
                jp      p,sbc_61
1665
        ld      b, #60
1666
        jp      fail_routine
1667
sbc_61:         jp      pe,sbc_62
1668
        ld      b, #61
1669
        jp      fail_routine
1670
sbc_62:         jr      nc,sbc_63
1671
        ld      b, #62
1672
        jp      fail_routine
1673
sbc_63:         jr      z,sbc_64
1674
        ld      b, #63
1675
        jp      fail_routine
1676
sbc_64:         sbc     a,1(ix)
1677
                jr      nz,sbc_65
1678
        ld      b, #64
1679
        jp      fail_routine
1680
sbc_65:         cp      #0x55+1
1681
                jr      z,and_0
1682
        ld      b, #65
1683
        jp      fail_routine
1684
and_0:          nop
1685 114 ghutchis
        ld hl, #msg_and_0
1686 113 ghutchis
        call print_sub
1687
                ld      a,#0xff
1688
                add     a,#1                    ;set carry
1689
                ld      a,#0xff
1690
                ld      b,#0xaa
1691
                and     a,b
1692
                jr      nc,and_1
1693
        ld      b, #0
1694
        jp      fail_routine
1695
and_1:          jp      m,and_2
1696
        ld      b, #1
1697
        jp      fail_routine
1698
and_2:          jp      pe,and_3
1699
        ld      b, #2
1700
        jp      fail_routine
1701
and_3:          jr      nz,and_4
1702
        ld      b, #3
1703
        jp      fail_routine
1704
and_4:          ld      b,#0x55
1705
                and     a,b
1706
                jp      p,and_5
1707
        ld      b, #4
1708
        jp      fail_routine
1709
and_5:          jr      z,and_6
1710
        ld      b, #5
1711
        jp      fail_routine
1712
and_6:          ld      a,#0xff
1713
                ld      b,#0x7f
1714
                and     a,b
1715
                jp      po,and_7
1716
        ld      b, #6
1717
        jp      fail_routine
1718
and_7:          ld      b,#0x55
1719
                and     a,b
1720
                jp      pe,and_8
1721
        ld      b, #7
1722
        jp      fail_routine
1723
and_8:          ld      a,#0xff
1724
                ld      c,#0x80
1725
                and     a,c
1726
                jp      m,and_9
1727
        ld      b, #8
1728
        jp      fail_routine
1729
and_9:          cp      #0x80
1730
                jr      z,and_10
1731
        ld      b, #9
1732
        jp      fail_routine
1733
and_10:         ld      a,#0xff
1734
                ld      d,#0x7f
1735
                and     a,d
1736
                jp      p,and_11
1737
        ld      b, #10
1738
        jp      fail_routine
1739
and_11:         cp      #0x7f
1740
                jr      z,and_12
1741
        ld      b, #11
1742
        jp      fail_routine
1743
and_12:         ld      a,#0xff
1744
                ld      e,#0xaa
1745
                and     a,e
1746
                jp      m,and_13
1747
        ld      b, #12
1748
        jp      fail_routine
1749
and_13:         cp      #0xaa
1750
                jr      z,and_14
1751
        ld      b, #13
1752
        jp      fail_routine
1753
and_14:         ld      a,#0xff
1754
                ld      h,#0x55
1755
                and     a,h
1756
                jp      p,and_15
1757
        ld      b, #14
1758
        jp      fail_routine
1759
and_15:         cp      #0x55
1760
                jr      z,and_16
1761
        ld      b, #15
1762
        jp      fail_routine
1763
and_16:         ld      a,#0xff
1764
                ld      l,#0xaa
1765
                and     a,l
1766
                jp      m,and_17
1767
        ld      b, #16
1768
        jp      fail_routine
1769
and_17:         cp      #0xaa
1770
                jr      z,and_18
1771
        ld      b, #17
1772
        jp      fail_routine
1773
and_18:         ld      a,#0xff
1774
                and     a,#0xaa
1775
                jp      m,and_19
1776
        ld      b, #18
1777
        jp      fail_routine
1778
and_19:         jr      nz,and_20
1779
        ld      b, #19
1780
        jp      fail_routine
1781
and_20:         and     a,#0x55
1782
                jp      p,and_21
1783
        ld      b, #20
1784
        jp      fail_routine
1785
and_21:         jr      z,and_22
1786
        ld      b, #21
1787
        jp      fail_routine
1788
and_22:         ld      a,#0xff
1789
                and     a,#0x7f
1790
                jp      po,and_23
1791
        ld      b, #22
1792
        jp      fail_routine
1793
and_23:         and     a,#0x55
1794
                jp      pe,and_24
1795
        ld      b, #23
1796
        jp      fail_routine
1797
and_24:         jr      nz,and_25
1798
        ld      b, #24
1799
        jp      fail_routine
1800
and_25:         and     a,#0xaa
1801
                jr      z,and_26
1802
        ld      b, #25
1803
        jp      fail_routine
1804
and_26:         ld      a,#0xff
1805
                and     a,#0xaa
1806
                cp      #0xaa
1807
                jr      z,and_27
1808
        ld      b, #26
1809
        jp      fail_routine
1810
and_27:         ld      hl,#var4
1811
                ld      a,#0xff
1812
                and     a,(hl)
1813
                jp      m,and_28
1814
        ld      b, #27
1815
        jp      fail_routine
1816
and_28:         jr      nz,and_29
1817
        ld      b, #28
1818
        jp      fail_routine
1819
and_29:         ld      hl,#var2
1820
                and     a,(hl)
1821
                jp      p,and_30
1822
        ld      b, #29
1823
        jp      fail_routine
1824
and_30:         jr      z,and_31
1825
        ld      b, #30
1826
        jp      fail_routine
1827
and_31:         ld      a,#0xff
1828
                ld      hl,#var5
1829
                and     a,(hl)
1830
                jp      po,and_32
1831
        ld      b, #31
1832
        jp      fail_routine
1833
and_32:         ld      hl,#var2
1834
                and     a,(hl)
1835
                jp      pe,and_33
1836
        ld      b, #32
1837
        jp      fail_routine
1838
and_33:         cp      #0x55
1839
                jr      z,and_34
1840
        ld      b, #33
1841
        jp      fail_routine
1842
and_34:         ld      ix,#var3
1843
                ld      a,#0xff
1844
                and     a,1(ix)
1845
                jp      m,and_35
1846
        ld      b, #34
1847
        jp      fail_routine
1848
and_35:         jr      nz,and_36
1849
        ld      b, #35
1850
        jp      fail_routine
1851
and_36:         and     a,-1(ix)
1852
                jp      p,and_37
1853
        ld      b, #36
1854
        jp      fail_routine
1855
and_37:         jr      z,and_38
1856
        ld      b, #37
1857
        jp      fail_routine
1858
and_38:         ld      a,#0xff
1859
                and     a,2(ix)
1860
                jp      po,and_39
1861
        ld      b, #38
1862
        jp      fail_routine
1863
and_39:         and     a,-1(ix)
1864
                jp      pe,and_40
1865
        ld      b, #39
1866
        jp      fail_routine
1867
and_40:         cp      #0x55
1868
                jr      z,and_41
1869
        ld      b, #40
1870
        jp      fail_routine
1871
and_41:         ld      iy,#var3
1872
                ld      a,#0xff
1873
                and     a,1(iy)
1874
                jp      m,and_42
1875
        ld      b, #41
1876
        jp      fail_routine
1877
and_42:         jr      nz,and_43
1878
        ld      b, #42
1879
        jp      fail_routine
1880
and_43:         and     a,-1(iy)
1881
                jp      p,and_44
1882
        ld      b, #43
1883
        jp      fail_routine
1884
and_44:         jr      z,and_45
1885
        ld      b, #44
1886
        jp      fail_routine
1887
and_45:         ld      a,#0xff
1888
                and     a,2(iy)
1889
                jp      po,and_46
1890
        ld      b, #45
1891
        jp      fail_routine
1892
and_46:         and     a,-1(iy)
1893
                jp      pe,and_47
1894
        ld      b, #46
1895
        jp      fail_routine
1896
and_47:         cp      #0x55
1897
                jr      z,or_0
1898
        ld      b, #47
1899
        jp      fail_routine
1900
or_0:           nop
1901 114 ghutchis
        ld hl, #msg_or_0
1902 113 ghutchis
        call print_sub
1903
                ld      a,#0
1904
                ld      b,#0x7f
1905
                or      a,b
1906
                jp      p,or_1
1907
        ld      b, #0
1908
        jp      fail_routine
1909
or_1:           jp      po,or_2
1910
        ld      b, #1
1911
        jp      fail_routine
1912
or_2:           ld      b,#0x80
1913
                or      a,b
1914
                jp      m,or_3
1915
        ld      b, #2
1916
        jp      fail_routine
1917
or_3:           jp      pe,or_4
1918
        ld      b, #3
1919
        jp      fail_routine
1920
or_4:           cp      #0xff
1921
                jr      z,or_5
1922
        ld      b, #4
1923
        jp      fail_routine
1924
or_5:           ld      a,#0
1925
                ld      b,#0
1926
                or      a,b
1927
                jr      z,or_6
1928
        ld      b, #5
1929
        jp      fail_routine
1930
or_6:           ld      b,#0x55
1931
                or      a,b
1932
                jr      nz,or_7
1933
        ld      b, #6
1934
        jp      fail_routine
1935
or_7:           cp      #0x55
1936
                jr      z,or_8
1937
        ld      b, #7
1938
        jp      fail_routine
1939
or_8:           ld      a,#0xff
1940
                add     a,#1
1941
                jr      c,or_9
1942
        ld      b, #8
1943
        jp      fail_routine
1944
or_9:           ld      b,#0x7f
1945
                or      a,b
1946
                jr      nc,or_10
1947
        ld      b, #9
1948
        jp      fail_routine
1949
or_10:          cp      #0x7f
1950
                jr      z,or_11
1951
        ld      b, #10
1952
        jp      fail_routine
1953
or_11:          ld      a,#0
1954
                ld      c,#0x55
1955
                or      a,c
1956
                cp      #0x55
1957
                jr      z,or_12
1958
        ld      b, #11
1959
        jp      fail_routine
1960
or_12:          ld      c,#0xaa
1961
                or      a,c
1962
                cp      #0xff
1963
                jr      z,or_13
1964
        ld      b, #12
1965
        jp      fail_routine
1966
or_13:          ld      a,#0
1967
                ld      d,#0xaa
1968
                or      a,d
1969
                cp      #0xaa
1970
                jr      z,or_14
1971
        ld      b, #13
1972
        jp      fail_routine
1973
or_14:          ld      e,#0x55
1974
                or      a,e
1975
                cp      #0xff
1976
                jr      z,or_15
1977
        ld      b, #14
1978
        jp      fail_routine
1979
or_15:          ld      a,#0
1980
                ld      h,#0x80
1981
                or      a,h
1982
                cp      #0x80
1983
                jr      z,or_16
1984
        ld      b, #15
1985
        jp      fail_routine
1986
or_16:          ld      l,#0x7f
1987
                or      a,l
1988
                cp      #0xff
1989
                jr      z,or_17
1990
        ld      b, #16
1991
        jp      fail_routine
1992
or_17:          ld      a,#0
1993
                or      a,#0x7f
1994
                jp      p,or_18
1995
        ld      b, #17
1996
        jp      fail_routine
1997
or_18:          jp      po,or_19
1998
        ld      b, #18
1999
        jp      fail_routine
2000
or_19:          or      a,#0x80
2001
                jp      m,or_20
2002
        ld      b, #19
2003
        jp      fail_routine
2004
or_20:          jp      pe,or_21
2005
        ld      b, #20
2006
        jp      fail_routine
2007
or_21:          cp      #0xff
2008
                jr      z,or_22
2009
        ld      b, #21
2010
        jp      fail_routine
2011
or_22:          ld      a,#0
2012
                or      a,#0
2013
                jr      z,or_23
2014
        ld      b, #22
2015
        jp      fail_routine
2016
or_23:          or      a,#0x7f
2017
                jr      nz,or_24
2018
        ld      b, #23
2019
        jp      fail_routine
2020
or_24:          ld      a,#0xff
2021
                add     a,#1
2022
                jr      c,or_25
2023
        ld      b, #24
2024
        jp      fail_routine
2025
or_25:          or      a,#0x55
2026
                jr      nc,or_26
2027
        ld      b, #25
2028
        jp      fail_routine
2029
or_26:          cp      #0x55
2030
                jr      z,or_27
2031
        ld      b, #26
2032
        jp      fail_routine
2033
or_27:          ld      hl,#var5
2034
                ld      a,#0
2035
                or      a,(hl)
2036
                jp      p,or_28
2037
        ld      b, #27
2038
        jp      fail_routine
2039
or_28:          jp      po,or_29
2040
        ld      b, #28
2041
        jp      fail_routine
2042
or_29:          ld      hl,#var3
2043
                or      a,(hl)
2044
                jp      m,or_30
2045
        ld      b, #29
2046
        jp      fail_routine
2047
or_30:          jp      pe,or_31
2048
        ld      b, #30
2049
        jp      fail_routine
2050
or_31:          cp      #0xff
2051
                jr      z,or_32
2052
        ld      b, #31
2053
        jp      fail_routine
2054
or_32:          ld      hl,#t_var1
2055
                ld      a,#0
2056
                ld      (hl),a
2057
                or      a,(hl)
2058
                jr      z,or_33
2059
        ld      b, #32
2060
        jp      fail_routine
2061
or_33:          ld      hl,#var2
2062
                or      a,(hl)
2063
                jr      nz,or_34
2064
        ld      b, #33
2065
        jp      fail_routine
2066
or_34:          cp      #0x55
2067
                jr      z,or_35
2068
        ld      b, #34
2069
        jp      fail_routine
2070
or_35:          ld      ix,#var3
2071
                ld      a,#0
2072
                or      a,2(ix)
2073
                jp      p,or_36
2074
        ld      b, #35
2075
        jp      fail_routine
2076
or_36:          jp      po,or_37
2077
        ld      b, #36
2078
        jp      fail_routine
2079
or_37:          or      a,(ix)
2080
                jp      m,or_38
2081
        ld      b, #37
2082
        jp      fail_routine
2083
or_38:          jp      pe,or_39
2084
        ld      b, #38
2085
        jp      fail_routine
2086
or_39:          cp      #0xff
2087
                jr      z,or_40
2088
        ld      b, #39
2089
        jp      fail_routine
2090
or_40:          ld      ix,#t_var3
2091
                ld      a,#0
2092
                ld      -2(ix),a
2093
                or      a,-2(ix)
2094
                jr      z,or_41
2095
        ld      b, #40
2096
        jp      fail_routine
2097
or_41:          ld      2(ix),#0xaa
2098
                or      a,2(ix)
2099
                jr      nz,or_42
2100
        ld      b, #41
2101
        jp      fail_routine
2102
or_42:          cp      #0xaa
2103
                jr      z,or_43
2104
        ld      b, #42
2105
        jp      fail_routine
2106
or_43:          ld      iy,#var3
2107
                ld      a,#0
2108
                or      a,2(iy)
2109
                jp      p,or_44
2110
        ld      b, #43
2111
        jp      fail_routine
2112
or_44:          jp      po,or_45
2113
        ld      b, #44
2114
        jp      fail_routine
2115
or_45:          or      a,(iy)
2116
                jp      m,or_46
2117
        ld      b, #45
2118
        jp      fail_routine
2119
or_46:          jp      pe,or_47
2120
        ld      b, #46
2121
        jp      fail_routine
2122
or_47:          cp      #0xff
2123
                jr      z,or_48
2124
        ld      b, #47
2125
        jp      fail_routine
2126
or_48:          ld      iy,#t_var3
2127
                ld      a,#0
2128
                ld      -2(iy),a
2129
                or      a,-2(iy)
2130
                jr      z,or_49
2131
        ld      b, #48
2132
        jp      fail_routine
2133
or_49:          ld      2(iy),#0x55
2134
                or      a,2(iy)
2135
                jr      nz,or_50
2136
        ld      b, #49
2137
        jp      fail_routine
2138
or_50:          cp      #0x55
2139
                jr      z,xor_0
2140
        ld      b, #50
2141
        jp      fail_routine
2142
xor_0:          nop
2143 114 ghutchis
        ld hl, #msg_xor_0
2144 113 ghutchis
        call print_sub
2145
                ld      a,#0xff
2146
                ld      b,#0x55
2147
                xor     a,b
2148
                jp      m,xor_1
2149
        ld      b, #0
2150
        jp      fail_routine
2151
xor_1:          jp      pe,xor_2
2152
        ld      b, #1
2153
        jp      fail_routine
2154
xor_2:          ld      b,#0x80
2155
                xor     a,b
2156
                jp      p,xor_3
2157
        ld      b, #2
2158
        jp      fail_routine
2159
xor_3:          jp      po,xor_4
2160
        ld      b, #3
2161
        jp      fail_routine
2162
xor_4:          cp      #0x2
2163
                jr      z,xor_5
2164
        ld      b, #4
2165
        jp      fail_routine
2166
xor_5:          ld      a,#0xff
2167
                ld      b,#0xff
2168
                xor     a,b
2169
                jr      z,xor_6
2170
        ld      b, #5
2171
        jp      fail_routine
2172
xor_6:          ld      b,#0x55
2173
                xor     a,b
2174
                jr      nz,xor_7
2175
        ld      b, #6
2176
        jp      fail_routine
2177
xor_7:          cp      #0x55
2178
                jr      z,xor_8
2179
        ld      b, #7
2180
        jp      fail_routine
2181
xor_8:          ld      a,#0xff
2182
                add     a,#1
2183
                jr      c,xor_9
2184
        ld      b, #8
2185
        jp      fail_routine
2186
xor_9:          ld      b,#0xaa
2187
                xor     a,b
2188
                jr      nc,xor_10
2189
        ld      b, #9
2190
        jp      fail_routine
2191
xor_10:         cp      #0xaa
2192
                jr      z,xor_11
2193
        ld      b, #10
2194
        jp      fail_routine
2195
xor_11:         ld      a,#0xff
2196
                ld      c,#0x7f
2197
                xor     a,c
2198
                jp      m,xor_12
2199
        ld      b, #11
2200
        jp      fail_routine
2201
xor_12:         cp      #0x80
2202
                jr      z,xor_13
2203
        ld      b, #12
2204
        jp      fail_routine
2205
xor_13:         ld      a,#0xff
2206
                ld      d,#0x55
2207
                xor     a,d
2208
                jp      m,xor_14
2209
        ld      b, #13
2210
        jp      fail_routine
2211
xor_14:         cp      #0xaa
2212
                jr      z,xor_15
2213
        ld      b, #14
2214
        jp      fail_routine
2215
xor_15:         ld      e,#0x55
2216
                xor     a,e
2217
                jp      m,xor_16
2218
        ld      b, #15
2219
        jp      fail_routine
2220
xor_16:         cp      #0xff
2221
                jr      z,xor_17
2222
        ld      b, #16
2223
        jp      fail_routine
2224
xor_17:         ld      a,#0xff
2225
                ld      h,#0x7f
2226
                xor     a,h
2227
                jp      po,xor_18
2228
        ld      b, #17
2229
        jp      fail_routine
2230
xor_18:         ld      l,#0x7f
2231
                xor     a,l
2232
                jp      pe,xor_19
2233
        ld      b, #18
2234
        jp      fail_routine
2235
xor_19:         cp      #0xff
2236
                jr      z,xor_20
2237
        ld      b, #19
2238
        jp      fail_routine
2239
xor_20:         ld      a,#0xff
2240
                add     a,#1
2241
                jr      c,xor_21
2242
        ld      b, #20
2243
        jp      fail_routine
2244
xor_21:         ld      b,#0x7f
2245
                xor     a,b
2246
                jr      nc,xor_22
2247
        ld      b, #21
2248
        jp      fail_routine
2249
xor_22:         cp      #0x7f
2250
                jr      z,xor_23
2251
        ld      b, #22
2252
        jp      fail_routine
2253
xor_23:         ld      a,#0xff
2254
                xor     a,#0x7f
2255
                jp      po,xor_24
2256
        ld      b, #23
2257
        jp      fail_routine
2258
xor_24:         jp      m,xor_25
2259
        ld      b, #24
2260
        jp      fail_routine
2261
xor_25:         xor     a,#0x7f
2262
                jp      pe,xor_26
2263
        ld      b, #25
2264
        jp      fail_routine
2265
xor_26:         jp      m,xor_27
2266
        ld      b, #26
2267
        jp      fail_routine
2268
xor_27:         xor     a,#0xaa
2269
                jp      p,xor_28
2270
        ld      b, #27
2271
        jp      fail_routine
2272
xor_28:         cp      #0x55
2273
                jr      z,xor_29
2274
        ld      b, #28
2275
        jp      fail_routine
2276
xor_29:         ld      a,#0xff
2277
                xor     a,#0xff
2278
                jr      z,xor_30
2279
        ld      b, #29
2280
        jp      fail_routine
2281
xor_30:         xor     a,#0x80
2282
                jr      nz,xor_31
2283
        ld      b, #30
2284
        jp      fail_routine
2285
xor_31:         cp      #0x80
2286
                jr      z,xor_32
2287
        ld      b, #31
2288
        jp      fail_routine
2289
xor_32:         ld      hl,#var5
2290
                ld      a,#0xff
2291
                xor     a,(hl)
2292
                jp      m,xor_33
2293
        ld      b, #32
2294
        jp      fail_routine
2295
xor_33:         jp      po,xor_34
2296
        ld      b, #33
2297
        jp      fail_routine
2298
xor_34:         xor     a,(hl)
2299
                jp      m,xor_35
2300
        ld      b, #34
2301
        jp      fail_routine
2302
xor_35:         jp      pe,xor_36
2303
        ld      b, #35
2304
        jp      fail_routine
2305
xor_36:         ld      hl,#var3
2306
                xor     a,(hl)
2307
                jp      p,xor_37
2308
        ld      b, #36
2309
        jp      fail_routine
2310
xor_37:         cp      #0x7f
2311
                jr      z,xor_38
2312
        ld      b, #37
2313
        jp      fail_routine
2314
xor_38:         ld      hl,#var1
2315
                ld      a,#0xff
2316
                xor     a,(hl)
2317
                jr      z,xor_39
2318
        ld      b, #38
2319
        jp      fail_routine
2320
xor_39:         ld      hl,#var2
2321
                xor     a,(hl)
2322
                jr      nz,xor_40
2323
        ld      b, #39
2324
        jp      fail_routine
2325
xor_40:         cp      #0x55
2326
                jr      z,xor_41
2327
        ld      b, #40
2328
        jp      fail_routine
2329
xor_41:         ld      ix,#var3
2330
                ld      a,#0xff
2331
                xor     a,2(ix)
2332
                jp      m,xor_42
2333
        ld      b, #41
2334
        jp      fail_routine
2335
xor_42:         jp      po,xor_43
2336
        ld      b, #42
2337
        jp      fail_routine
2338
xor_43:         xor     a,2(ix)
2339
                jp      m,xor_44
2340
        ld      b, #43
2341
        jp      fail_routine
2342
xor_44:         jp      pe,xor_45
2343
        ld      b, #44
2344
        jp      fail_routine
2345
xor_45:         xor     a,1(ix)
2346
                jp      p,xor_46
2347
        ld      b, #45
2348
        jp      fail_routine
2349
xor_46:         cp      #0x55
2350
                jr      z,xor_47
2351
        ld      b, #46
2352
        jp      fail_routine
2353
xor_47:         ld      a,#0xff
2354
                xor     a,-2(ix)
2355
                jr      z,xor_48
2356
        ld      b, #47
2357
        jp      fail_routine
2358
xor_48:         xor     a,1(ix)
2359
                jr      nz,xor_49
2360
        ld      b, #48
2361
        jp      fail_routine
2362
xor_49:         cp      #0xaa
2363
                jr      z,xor_50
2364
        ld      b, #49
2365
        jp      fail_routine
2366
xor_50:         ld      iy,#var3
2367
                ld      a,#0xff
2368
                xor     a,2(iy)
2369
                jp      m,xor_51
2370
        ld      b, #50
2371
        jp      fail_routine
2372
xor_51:         jp      po,xor_52
2373
        ld      b, #51
2374
        jp      fail_routine
2375
xor_52:         xor     a,2(iy)
2376
                jp      m,xor_53
2377
        ld      b, #52
2378
        jp      fail_routine
2379
xor_53:         jp      pe,xor_54
2380
        ld      b, #53
2381
        jp      fail_routine
2382
xor_54:         xor     a,1(iy)
2383
                jp      p,xor_55
2384
        ld      b, #54
2385
        jp      fail_routine
2386
xor_55:         cp      #0x55
2387
                jr      z,xor_56
2388
        ld      b, #55
2389
        jp      fail_routine
2390
xor_56:         ld      a,#0xff
2391
                xor     a,-2(iy)
2392
                jr      z,xor_57
2393
        ld      b, #56
2394
        jp      fail_routine
2395
xor_57:         xor     a,-1(iy)
2396
                jr      nz,xor_58
2397
        ld      b, #57
2398
        jp      fail_routine
2399
xor_58:         cp      #0x55
2400
                jr      z,cp_0
2401
        ld      b, #58
2402
        jp      fail_routine
2403
cp_0:           nop
2404 114 ghutchis
        ld hl, #msg_cp_0
2405 113 ghutchis
        call print_sub
2406
                ld      a,#0
2407
                ld      b,#0
2408
                cp      a,b
2409
                jr      z,cp_1
2410
        ld      b, #0
2411
        jp      fail_routine
2412
cp_1:           jp      p,cp_2
2413
        ld      b, #1
2414
        jp      fail_routine
2415
cp_2:           jr      nc,cp_3
2416
        ld      b, #2
2417
        jp      fail_routine
2418
cp_3:           ld      b,#0x55
2419
                cp      a,b
2420
                jr      nz,cp_4
2421
        ld      b, #3
2422
        jp      fail_routine
2423
cp_4:           jp      m,cp_5
2424
        ld      b, #4
2425
        jp      fail_routine
2426
cp_5:           jr      c,cp_6
2427
        ld      b, #5
2428
        jp      fail_routine
2429
cp_6:           ld      a,#0x80
2430
                ld      b,#0x7f
2431
                cp      a,b
2432
                jp      pe,cp_7
2433
        ld      b, #6
2434
        jp      fail_routine
2435
cp_7:           jr      nc,cp_8
2436
        ld      b, #7
2437
        jp      fail_routine
2438
cp_8:           ld      a,#0x7f
2439
                ld      b,#0x80
2440
                cp      a,b
2441
                jp      pe,cp_9
2442
        ld      b, #8
2443
        jp      fail_routine
2444
cp_9:           jr      c,cp_10
2445
        ld      b, #9
2446
        jp      fail_routine
2447
cp_10:          ld      b,#0
2448
                cp      a,b
2449
                jp      po,cp_11
2450
        ld      b, #10
2451
        jp      fail_routine
2452
cp_11:          jr      nc,cp_12
2453
        ld      b, #11
2454
        jp      fail_routine
2455
cp_12:          ld      a,#0x80
2456
                ld      c,#0
2457
                cp      a,c
2458
                jp      m,cp_13
2459
        ld      b, #12
2460
        jp      fail_routine
2461
cp_13:          ld      c,#0x80
2462
                cp      a,c
2463
                jr      z,cp_14
2464
        ld      b, #13
2465
        jp      fail_routine
2466
cp_14:          ld      a,#0x7f
2467
                ld      d,#0x55
2468
                cp      a,d
2469
                jp      p,cp_15
2470
        ld      b, #14
2471
        jp      fail_routine
2472
cp_15:          jr      nz,cp_16
2473
        ld      b, #15
2474
        jp      fail_routine
2475
cp_16:          ld      e,#0x7f
2476
                cp      a,e
2477
                jr      z,cp_17
2478
        ld      b, #16
2479
        jp      fail_routine
2480
cp_17:          ld      a,#0x80
2481
                ld      h,#0xff
2482
                cp      a,h
2483
                jp      m,cp_18
2484
        ld      b, #17
2485
        jp      fail_routine
2486
cp_18:          jr      c,cp_19
2487
        ld      b, #18
2488
        jp      fail_routine
2489
cp_19:          ld      l,#0x80
2490
                cp      a,l
2491
                jr      z,cp_20
2492
        ld      b, #19
2493
        jp      fail_routine
2494
cp_20:          ld      a,#0x80
2495
                cp      a,#0x7f
2496
                jp      p,cp_21
2497
        ld      b, #20
2498
        jp      fail_routine
2499
cp_21:          jp      pe,cp_22
2500
        ld      b, #21
2501
        jp      fail_routine
2502
cp_22:          jr      nz,cp_23
2503
        ld      b, #22
2504
        jp      fail_routine
2505
cp_23:          cp      a,#0x80
2506
                jp      p,cp_24
2507
        ld      b, #23
2508
        jp      fail_routine
2509
cp_24:          jp      po,cp_25
2510
        ld      b, #24
2511
        jp      fail_routine
2512
cp_25:          jr      z,cp_26
2513
        ld      b, #25
2514
        jp      fail_routine
2515
cp_26:          ld      a,#0x55
2516
                cp      a,#0x7f
2517
                jr      c,cp_27
2518
        ld      b, #26
2519
        jp      fail_routine
2520
cp_27:          jp      m,cp_28
2521
        ld      b, #27
2522
        jp      fail_routine
2523
cp_28:          cp      a,#0x55
2524
                jr      nc,cp_29
2525
        ld      b, #28
2526
        jp      fail_routine
2527
cp_29:          jr      z,cp_30
2528
        ld      b, #29
2529
        jp      fail_routine
2530
cp_30:          ld      a,#0x80
2531
                ld      hl,#var5
2532
                cp      a,(hl)
2533
                jp      p,cp_31
2534
        ld      b, #30
2535
        jp      fail_routine
2536
cp_31:          jp      pe,cp_32
2537
        ld      b, #31
2538
        jp      fail_routine
2539
cp_32:          jr      nz,cp_33
2540
        ld      b, #32
2541
        jp      fail_routine
2542
cp_33:          ld      hl,#var3
2543
                cp      a,(hl)
2544
                jp      p,cp_34
2545
        ld      b, #33
2546
        jp      fail_routine
2547
cp_34:          jp      po,cp_35
2548
        ld      b, #34
2549
        jp      fail_routine
2550
cp_35:          jr      z,cp_36
2551
        ld      b, #35
2552
        jp      fail_routine
2553
cp_36:          ld      a,#0x55
2554
                ld      hl,#var5
2555
                cp      a,(hl)
2556
                jr      c,cp_37
2557
        ld      b, #36
2558
        jp      fail_routine
2559
cp_37:          jp      m,cp_38
2560
        ld      b, #37
2561
        jp      fail_routine
2562
cp_38:          ld      hl,#var2
2563
                cp      a,(hl)
2564
                jr      nc,cp_39
2565
        ld      b, #38
2566
        jp      fail_routine
2567
cp_39:          jp      p,cp_40
2568
        ld      b, #39
2569
        jp      fail_routine
2570
cp_40:          jr      z,cp_41
2571
        ld      b, #40
2572
        jp      fail_routine
2573
cp_41:          ld      a,#0x80
2574
                ld      ix,#var3
2575
                cp      a,2(ix)
2576
                jp      p,cp_42
2577
        ld      b, #41
2578
        jp      fail_routine
2579
cp_42:          jp      pe,cp_43
2580
        ld      b, #42
2581
        jp      fail_routine
2582
cp_43:          jr      nz,cp_44
2583
        ld      b, #43
2584
        jp      fail_routine
2585
cp_44:          cp      a,(ix)
2586
                jp      p,cp_45
2587
        ld      b, #44
2588
        jp      fail_routine
2589
cp_45:          jp      po,cp_46
2590
        ld      b, #45
2591
        jp      fail_routine
2592
cp_46:          jr      z,cp_47
2593
        ld      b, #46
2594
        jp      fail_routine
2595
cp_47:          ld      a,#0x55
2596
                cp      a,-2(ix)
2597
                jr      nz,cp_48
2598
        ld      b, #47
2599
        jp      fail_routine
2600
cp_48:          jr      c,cp_49
2601
        ld      b, #48
2602
        jp      fail_routine
2603
cp_49:          cp      a,-1(ix)
2604
                jr      z,cp_50
2605
        ld      b, #49
2606
        jp      fail_routine
2607
cp_50:          jr      nc,cp_51
2608
        ld      b, #50
2609
        jp      fail_routine
2610
cp_51:          ld      iy,#var3
2611
                ld      a,#0x80
2612
                cp      a,2(iy)
2613
                jp      p,cp_52
2614
        ld      b, #51
2615
        jp      fail_routine
2616
cp_52:          jp      pe,cp_53
2617
        ld      b, #52
2618
        jp      fail_routine
2619
cp_53:          jr      nz,cp_54
2620
        ld      b, #53
2621
        jp      fail_routine
2622
cp_54:          cp      a,(iy)
2623
                jp      p,cp_55
2624
        ld      b, #54
2625
        jp      fail_routine
2626
cp_55:          jp      po,cp_56
2627
        ld      b, #55
2628
        jp      fail_routine
2629
cp_56:          jr      z,cp_57
2630
        ld      b, #56
2631
        jp      fail_routine
2632
cp_57:          ld      a,#0x55
2633
                cp      a,-2(iy)
2634
                jr      nz,cp_58
2635
        ld      b, #57
2636
        jp      fail_routine
2637
cp_58:          jr      c,cp_59
2638
        ld      b, #58
2639
        jp      fail_routine
2640
cp_59:          cp      a,-1(iy)
2641
                jr      z,cp_60
2642
        ld      b, #59
2643
        jp      fail_routine
2644
cp_60:          jr      nc,inc_0
2645
        ld      b, #60
2646
        jp      fail_routine
2647
inc_0:          nop
2648
        ld hl, #msg_inc
2649
        call print_sub
2650
                ld      a,#0x7f
2651
                cp      a,#0x7f
2652
                jr      z,inc_1
2653
        ld      b, #0
2654
        jp      fail_routine
2655
inc_1:          inc     a
2656
                jp      pe,inc_2
2657
        ld      b, #1
2658
        jp      fail_routine
2659
inc_2:          jp      m,inc_3
2660
        ld      b, #2
2661
        jp      fail_routine
2662
inc_3:          jr      nz,inc_4
2663
        ld      b, #3
2664
        jp      fail_routine
2665
inc_4:          ld      a,#0x55
2666
                inc     a
2667
                jp      po,inc_5
2668
        ld      b, #4
2669
        jp      fail_routine
2670
inc_5:          jp      p,inc_6
2671
        ld      b, #5
2672
        jp      fail_routine
2673
inc_6:          cp      a,#0x55+1
2674
                jr      z,inc_7
2675
        ld      b, #6
2676
        jp      fail_routine
2677
inc_7:          ld      a,#0xff-1
2678
                inc     a
2679
                jr      nz,inc_8
2680
        ld      b, #7
2681
        jp      fail_routine
2682
inc_8:          jp      m,inc_9
2683
        ld      b, #8
2684
        jp      fail_routine
2685
inc_9:          inc     a
2686
                jr      z,inc_10
2687
        ld      b, #9
2688
        jp      fail_routine
2689
inc_10:         ld      b,#0xaa
2690
                inc     b
2691
                jp      m,inc_11
2692
        ld      b, #10
2693
        jp      fail_routine
2694
inc_11:         ld      a,b
2695
                cp      a,#0xaa+1
2696
                jr      z,inc_12
2697
        ld      b, #11
2698
        jp      fail_routine
2699
inc_12:         ld      c,#0x80
2700
                inc     c
2701
                jp      m,inc_13
2702
        ld      b, #12
2703
        jp      fail_routine
2704
inc_13:         ld      a,c
2705
                cp      a,#0x80+1
2706
                jr      z,inc_14
2707
        ld      b, #13
2708
        jp      fail_routine
2709
inc_14:         ld      d,#0xff
2710
                inc     d
2711
                jr      z,inc_15
2712
        ld      b, #14
2713
        jp      fail_routine
2714
inc_15:         ld      e,#0x55
2715
                inc     e
2716
                jp      p,inc_16
2717
        ld      b, #15
2718
        jp      fail_routine
2719
inc_16:         ld      a,e
2720
                cp      a,#0x55+1
2721
                jr      z,inc_17
2722
        ld      b, #16
2723
        jp      fail_routine
2724
inc_17:         ld      h,#0x7f
2725
                inc     h
2726
                jp      pe,inc_18
2727
        ld      b, #17
2728
        jp      fail_routine
2729
inc_18:         ld      a,h
2730
                cp      a,#0x80
2731
                jr      z,inc_19
2732
        ld      b, #18
2733
        jp      fail_routine
2734
inc_19:         ld      l,#0xaa
2735
                inc     l
2736
                jp      m,inc_20
2737
        ld      b, #19
2738
        jp      fail_routine
2739
inc_20:         ld      a,l
2740
                cp      a,#0xaa+1
2741
                jr      z,inc_21
2742
        ld      b, #20
2743
        jp      fail_routine
2744
inc_21:         ld      hl,#t_var1
2745
                ld      a,#0x7f
2746
                ld      (hl),a
2747
                cp      a,(hl)
2748
                jr      z,inc_22
2749
        ld      b, #21
2750
        jp      fail_routine
2751
inc_22:         inc     (hl)
2752
                jp      m,inc_23
2753
        ld      b, #22
2754
        jp      fail_routine
2755
inc_23:         jp      pe,inc_24
2756
        ld      b, #23
2757
        jp      fail_routine
2758
inc_24:         ld      a,#0x55
2759
                ld      (hl),a
2760
                inc     (hl)
2761
                jp      p,inc_25
2762
        ld      b, #24
2763
        jp      fail_routine
2764
inc_25:         jp      po,inc_26
2765
        ld      b, #25
2766
        jp      fail_routine
2767
inc_26:         ld      a,(hl)
2768
                cp      a,#0x55+1
2769
                jr      z,inc_27
2770
        ld      b, #26
2771
        jp      fail_routine
2772
inc_27:         ld      a,#0xff
2773
                ld      (hl),a
2774
                inc     (hl)
2775
                jr      z,inc_28
2776
        ld      b, #27
2777
        jp      fail_routine
2778
inc_28:         inc     (hl)
2779
                jr      nz,inc_29
2780
        ld      b, #28
2781
        jp      fail_routine
2782
inc_29:         ld      a,(hl)
2783
                cp      a,#1
2784
                jr      z,inc_30
2785
        ld      b, #29
2786
        jp      fail_routine
2787
inc_30:         ld      a,#0xaa
2788
                ld      (hl),a
2789
                inc     (hl)
2790
                jp      m,inc_31
2791
        ld      b, #30
2792
        jp      fail_routine
2793
inc_31:         ld      a,(hl)
2794
                cp      a,#0xaa+1
2795
                jr      z,inc_32
2796
        ld      b, #31
2797
        jp      fail_routine
2798
inc_32:         ld      ix,#t_var3
2799
                ld      a,#0x7f
2800
                ld      -2(ix),a
2801
                cp      a,#0x7f
2802
                jr      z,inc_33
2803
        ld      b, #32
2804
        jp      fail_routine
2805
inc_33:         inc     -2(ix)
2806
                jp      m,inc_34
2807
        ld      b, #33
2808
        jp      fail_routine
2809
inc_34:         jp      pe,inc_35
2810
        ld      b, #34
2811
        jp      fail_routine
2812
inc_35:         ld      a,#0x55
2813
                ld      2(ix),a
2814
                inc     2(ix)
2815
                jp      p,inc_36
2816
        ld      b, #35
2817
        jp      fail_routine
2818
inc_36:         jp      po,inc_37
2819
        ld      b, #36
2820
        jp      fail_routine
2821
inc_37:         ld      a,2(ix)
2822
                cp      a,#0x55+1
2823
                jr      z,inc_38
2824
        ld      b, #37
2825
        jp      fail_routine
2826
inc_38:         ld      a,#0xff
2827
                ld      -1(ix),a
2828
                inc     -1(ix)
2829
                jr      z,inc_39
2830
        ld      b, #38
2831
        jp      fail_routine
2832
inc_39:         inc     -1(ix)
2833
                jr      nz,inc_40
2834
        ld      b, #39
2835
        jp      fail_routine
2836
inc_40:         ld      a,-1(ix)
2837
                cp      a,#1
2838
                jr      z,inc_41
2839
        ld      b, #40
2840
        jp      fail_routine
2841
inc_41:         ld      a,#0xaa
2842
                ld      1(ix),a
2843
                inc     1(ix)
2844
                jp      m,inc_42
2845
        ld      b, #41
2846
        jp      fail_routine
2847
inc_42:         ld      a,1(ix)
2848
                cp      a,#0xaa+1
2849
                jr      z,inc_43
2850
        ld      b, #42
2851
        jp      fail_routine
2852
inc_43:         ld      iy,#t_var3
2853
                ld      a,#0x7f
2854
                ld      2(iy),a
2855
                cp      a,#0x7f
2856
                jr      z,inc_44
2857
        ld      b, #43
2858
        jp      fail_routine
2859
inc_44:         inc     2(iy)
2860
                jp      m,inc_45
2861
        ld      b, #44
2862
        jp      fail_routine
2863
inc_45:         jp      pe,inc_46
2864
        ld      b, #45
2865
        jp      fail_routine
2866
inc_46:         ld      a,#0x55
2867
                ld      -2(iy),a
2868
                inc     -2(iy)
2869
                jp      p,inc_47
2870
        ld      b, #46
2871
        jp      fail_routine
2872
inc_47:         jp      po,inc_48
2873
        ld      b, #47
2874
        jp      fail_routine
2875
inc_48:         ld      a,-2(iy)
2876
                cp      a,#0x55+1
2877
                jr      z,inc_49
2878
        ld      b, #48
2879
        jp      fail_routine
2880
inc_49:         ld      a,#0xff
2881
                ld      1(iy),a
2882
                inc     1(iy)
2883
                jr      z,inc_50
2884
        ld      b, #49
2885
        jp      fail_routine
2886
inc_50:         inc     1(iy)
2887
                jr      nz,inc_51
2888
        ld      b, #50
2889
        jp      fail_routine
2890
inc_51:         ld      a,1(iy)
2891
                cp      a,#1
2892
                jr      z,inc_52
2893
        ld      b, #51
2894
        jp      fail_routine
2895
inc_52:         ld      a,#0x80
2896
                ld      -1(iy),a
2897
                inc     -1(iy)
2898
                jp      m,inc_53
2899
        ld      b, #52
2900
        jp      fail_routine
2901
inc_53:         ld      a,-1(iy)
2902
                cp      a,#0x80+1
2903
                jr      z,dec_0
2904
        ld      b, #53
2905
        jp      fail_routine
2906
dec_0:          nop
2907
        ld hl, #msg_dec
2908
        call print_sub
2909
                ld      a,#0x80
2910
                cp      a,#0x80
2911
                jr      z,dec_1
2912
        ld      b, #0
2913
        jp      fail_routine
2914
dec_1:          dec     a
2915
                jp      p,dec_2
2916
        ld      b, #1
2917
        jp      fail_routine
2918
dec_2:          jp      pe,dec_3
2919
        ld      b, #2
2920
        jp      fail_routine
2921
dec_3:          ld      a,#0
2922
                dec     a
2923
                jp      m,dec_4
2924
        ld      b, #3
2925
        jp      fail_routine
2926
dec_4:          jp      po,dec_5
2927
        ld      b, #4
2928
        jp      fail_routine
2929
dec_5:          cp      a,#0xff
2930
                jr      z,dec_6
2931
        ld      b, #5
2932
        jp      fail_routine
2933
dec_6:          ld      a,#1
2934
                dec     a
2935
                jr      z,dec_7
2936
        ld      b, #6
2937
        jp      fail_routine
2938
dec_7:          dec     a
2939
                jr      nz,dec_8
2940
        ld      b, #7
2941
        jp      fail_routine
2942
dec_8:          cp      a,#0xff
2943
                jr      z,dec_9
2944
        ld      b, #8
2945
        jp      fail_routine
2946
dec_9:          ld      a,#0xaa
2947
                dec     a
2948
                cp      a,#0xaa-1
2949
                jr      z,dec_10
2950
        ld      b, #9
2951
        jp      fail_routine
2952
dec_10:         ld      b,#0x7f
2953
                dec     b
2954
                ld      a,b
2955
                cp      a,#0x7f-1
2956
                jr      z,dec_11
2957
        ld      b, #10
2958
        jp      fail_routine
2959
dec_11:         ld      c,#0x55
2960
                dec     c
2961
                ld      a,c
2962
                cp      a,#0x55-1
2963
                jr      z,dec_12
2964
        ld      b, #11
2965
        jp      fail_routine
2966
dec_12:         ld      d,#0xaa
2967
                dec     d
2968
                ld      a,d
2969
                cp      a,#0xaa-1
2970
                jr      z,dec_13
2971
        ld      b, #12
2972
        jp      fail_routine
2973
dec_13:         ld      e,#0x80
2974
                dec     e
2975
                ld      a,e
2976
                cp      a,#0x80-1
2977
                jr      z,dec_14
2978
        ld      b, #13
2979
        jp      fail_routine
2980
dec_14:         ld      h,#0xff
2981
                dec     h
2982
                ld      a,h
2983
                cp      a,#0xff-1
2984
                jr      z,dec_15
2985
        ld      b, #14
2986
        jp      fail_routine
2987
dec_15:         ld      l,#0x55
2988
                dec     l
2989
                ld      a,l
2990
                cp      a,#0x55-1
2991
                jr      z,dec_16
2992
        ld      b, #15
2993
        jp      fail_routine
2994
dec_16:         ld      hl,#t_var5
2995
                ld      a,#0x80
2996
                ld      (hl),a
2997
                cp      a,(hl)
2998
                jr      z,dec_17
2999
        ld      b, #16
3000
        jp      fail_routine
3001
dec_17:         dec     (hl)
3002
                jp      p,dec_18
3003
        ld      b, #17
3004
        jp      fail_routine
3005
dec_18:         jp      pe,dec_19
3006
        ld      b, #18
3007
        jp      fail_routine
3008
dec_19:         ld      a,#0
3009
                ld      (hl),a
3010
                dec     (hl)
3011
                jp      m,dec_20
3012
        ld      b, #19
3013
        jp      fail_routine
3014
dec_20:         jp      po,dec_21
3015
        ld      b, #20
3016
        jp      fail_routine
3017
dec_21:         ld      a,(hl)
3018
                cp      a,#0xff
3019
                jr      z,dec_22
3020
        ld      b, #21
3021
        jp      fail_routine
3022
dec_22:         ld      a,#1
3023
                ld      (hl),a
3024
                dec     (hl)
3025
                jr      z,dec_23
3026
        ld      b, #22
3027
        jp      fail_routine
3028
dec_23:         dec     (hl)
3029
                jr      nz,dec_24
3030
        ld      b, #23
3031
        jp      fail_routine
3032
dec_24:         ld      a,(hl)
3033
                cp      a,#0xff
3034
                jr      z,dec_25
3035
        ld      b, #24
3036
        jp      fail_routine
3037
dec_25:         ld      a,#0xaa
3038
                ld      (hl),a
3039
                dec     (hl)
3040
                ld      a,(hl)
3041
                cp      a,#0xaa-1
3042
                jr      z,dec_26
3043
        ld      b, #25
3044
        jp      fail_routine
3045
dec_26:         ld      ix,#t_var3
3046
                ld      a,#0x80
3047
                ld      -2(ix),a
3048
                cp      a,-2(ix)
3049
                jr      z,dec_27
3050
        ld      b, #26
3051
        jp      fail_routine
3052
dec_27:         dec     -2(ix)
3053
                jp      p,dec_28
3054
        ld      b, #27
3055
        jp      fail_routine
3056
dec_28:         jp      pe,dec_29
3057
        ld      b, #28
3058
        jp      fail_routine
3059
dec_29:         ld      a,#0
3060
                ld      2(ix),a
3061
                dec     2(ix)
3062
                jp      m,dec_30
3063
        ld      b, #29
3064
        jp      fail_routine
3065
dec_30:         jp      po,dec_31
3066
        ld      b, #30
3067
        jp      fail_routine
3068
dec_31:         ld      a,2(ix)
3069
                cp      a,#0xff
3070
                jr      z,dec_32
3071
        ld      b, #31
3072
        jp      fail_routine
3073
dec_32:         ld      a,#1
3074
                ld      -1(ix),a
3075
                dec     -1(ix)
3076
                jr      z,dec_33
3077
        ld      b, #32
3078
        jp      fail_routine
3079
dec_33:         dec     -1(ix)
3080
                jr      nz,dec_34
3081
        ld      b, #33
3082
        jp      fail_routine
3083
dec_34:         ld      a,-1(ix)
3084
                cp      a,#0xff
3085
                jr      z,dec_35
3086
        ld      b, #34
3087
        jp      fail_routine
3088
dec_35:         ld      a,#0x7f
3089
                ld      1(ix),a
3090
                dec     1(ix)
3091
                ld      a,1(ix)
3092
                cp      a,#0x7f-1
3093
                jr      z,dec_36
3094
        ld      b, #35
3095
        jp      fail_routine
3096
dec_36:         ld      iy,#t_var3
3097
                ld      a,#0x80
3098
                ld      -2(iy),a
3099
                cp      a,-2(iy)
3100
                jr      z,dec_37
3101
        ld      b, #36
3102
        jp      fail_routine
3103
dec_37:         dec     -2(iy)
3104
                jp      p,dec_38
3105
        ld      b, #37
3106
        jp      fail_routine
3107
dec_38:         jp      pe,dec_39
3108
        ld      b, #38
3109
        jp      fail_routine
3110
dec_39:         ld      a,#0
3111
                ld      2(iy),a
3112
                dec     2(iy)
3113
                jp      m,dec_40
3114
        ld      b, #39
3115
        jp      fail_routine
3116
dec_40:         jp      po,dec_41
3117
        ld      b, #40
3118
        jp      fail_routine
3119
dec_41:         ld      a,2(iy)
3120
                cp      a,#0xff
3121
                jr      z,dec_42
3122
        ld      b, #41
3123
        jp      fail_routine
3124
dec_42:         ld      a,#1
3125
                ld      1(iy),a
3126
                dec     1(iy)
3127
                jr      z,dec_43
3128
        ld      b, #42
3129
        jp      fail_routine
3130
dec_43:         dec     1(iy)
3131
                jr      nz,dec_44
3132
        ld      b, #43
3133
        jp      fail_routine
3134
dec_44:         ld      a,1(iy)
3135
                cp      a,#0xff
3136
                jr      z,dec_45
3137
        ld      b, #44
3138
        jp      fail_routine
3139
dec_45:         ld      a,#0xaa
3140
                ld      -1(iy),a
3141
                dec     -1(iy)
3142
                ld      a,-1(iy)
3143
                cp      a,#0xaa-1
3144
                jr      z,cpl_0
3145
        ld      b, #45
3146
        jp      fail_routine
3147
cpl_0:          ld      a,#0xff
3148
                cpl
3149
                cp      a,#0
3150
                jr      z,cpl_1
3151
        ld      b, #0
3152
        jp      fail_routine
3153
cpl_1:          ld      a,#0xaa
3154
                cpl
3155
                cp      a,#0x55
3156
                jr      z,cpl_2
3157
        ld      b, #1
3158
        jp      fail_routine
3159
cpl_2:          cpl
3160
                cp      a,#0xaa
3161
                jr      z,neg_0
3162
        ld      b, #2
3163
        jp      fail_routine
3164
neg_0:          nop
3165
        ld hl, #msg_neg
3166
        call print_sub
3167
                ld      a,#0x80
3168
                cp      a,#0x80
3169
                jp      po,neg_1
3170
        ld      b, #0
3171
        jp      fail_routine
3172
neg_1:          neg
3173
                jp      pe,neg_2
3174
        ld      b, #1
3175
        jp      fail_routine
3176
neg_2:          jr      nz,neg_3
3177
        ld      b, #2
3178
        jp      fail_routine
3179
neg_3:          jr      c,neg_4
3180
        ld      b, #3
3181
        jp      fail_routine
3182
neg_4:          ld      a,#0
3183
                neg
3184
                jp      po,neg_5
3185
        ld      b, #4
3186
        jp      fail_routine
3187
neg_5:          jr      z,neg_6
3188
        ld      b, #5
3189
        jp      fail_routine
3190
neg_6:          jr      nc,neg_7
3191
        ld      b, #6
3192
        jp      fail_routine
3193
neg_7:          ld      a,#0x55
3194
                cp      a,#0x55
3195
                jp      p,neg_8
3196
        ld      b, #7
3197
        jp      fail_routine
3198
neg_8:          neg
3199
                jp      m,neg_9
3200
        ld      b, #8
3201
        jp      fail_routine
3202
neg_9:          neg
3203
                jp      p,neg_10
3204
        ld      b, #9
3205
        jp      fail_routine
3206
neg_10:         cp      a,#0x55
3207
                jr      z,end_of_test
3208
        ld      b, #10
3209
        jp      fail_routine
3210
 
3211
end_of_test:
3212
        jp      passed
3213
 
3214
 
3215
var1:           .db     #0x0
3216
var2:           .db     #0x0
3217
var3:           .db     #0x0
3218
var4:           .db     #0x0
3219
var5:           .db     #0x0
3220
 
3221
w_var1:         .dw     #0x0
3222
w_var2:         .dw     #0x0
3223
w_var3:         .dw     #0x0
3224
w_var4:         .dw     #0x0
3225
w_var5:         .dw     #0x0
3226
w_var6:         .dw     #0x0
3227
 
3228
.area    _DATA
3229
 
3230
 
3231
t_var1:         .db     0
3232
t_var2:         .db     0
3233
t_var3:         .db     0
3234
t_var4:         .db     0
3235
t_var5:         .db     0
3236
 
3237
 
3238
tw_var1:        .dw     0
3239
tw_var2:        .dw     0
3240
tw_var3:        .dw     0
3241
tw_var4:        .dw     0
3242
tw_var5:        .dw     0
3243
tw_var6:        .dw     0
3244
tw_var7:        .dw     0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.