git @ Cat's Eye Technologies SixtyPical / d1a2970
Add example test program for cmp-against-literal-word. Fix it. Chris Pressey 2 years ago
3 changed file(s) with 68 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
0 // Include `support/${PLATFORM}.60p` before this source
1 // Should print ENGGL
2
3 word w1
4
5 define main routine
6 outputs w1
7 trashes a, x, y, z, n, c, v
8 {
9 copy 4000, w1
10
11 cmp w1, 4000
12 if z {
13 ld a, 69 // E
14 call chrout
15 } else {
16 ld a, 78 // N
17 call chrout
18 }
19
20 copy 4000, w1
21
22 cmp w1, 4001
23 if z {
24 ld a, 69 // E
25 call chrout
26 } else {
27 ld a, 78 // N
28 call chrout
29 }
30
31 copy 20002, w1
32
33 cmp w1, 20001 // 20002 >= 20001
34 if c {
35 ld a, 71 // G
36 call chrout
37 } else {
38 ld a, 76 // L
39 call chrout
40 }
41
42 copy 20001, w1
43
44 cmp w1, 20001 // 20001 >= 20001
45 if c {
46 ld a, 71 // G
47 call chrout
48 } else {
49 ld a, 76 // L
50 call chrout
51 }
52
53 copy 20000, w1
54
55 cmp w1, 20001 // 20000 < 20001
56 if c {
57 ld a, 71 // G
58 call chrout
59 } else {
60 ld a, 76 // L
61 call chrout
62 }
63 }
404404 if isinstance(src, ConstantRef) and src.type == TYPE_WORD:
405405 dest_label = self.get_label(dest.name)
406406 self.emitter.emit(LDA(Absolute(dest_label)))
407 self.emitter.emit(CMP(Immediate(Byte(src.high_byte()))))
407 self.emitter.emit(CMP(Immediate(Byte(src.low_byte()))))
408408 end_label = Label('end_label')
409409 self.emitter.emit(BNE(Relative(end_label)))
410410 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
411 self.emitter.emit(CMP(Immediate(Byte(src.low_byte()))))
411 self.emitter.emit(CMP(Immediate(Byte(src.high_byte()))))
412412 self.emitter.resolve_label(end_label)
413413 return
414414 cls = {
402402 = $0815 LDA $EA62
403403 = $0818 CMP $0829
404404 = $081B LDA $EA61
405 = $081E CMP #$0F
405 = $081E CMP #$A0
406406 = $0820 BNE $0827
407407 = $0822 LDA $EA62
408 = $0825 CMP #$A0
408 = $0825 CMP #$0F
409409 = $0827 RTS
410410 = $0828 .byte $BB
411411 = $0829 .byte $0B