mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-09 01:30:50 +00:00
Add example test program for cmp-against-literal-word. Fix it.
This commit is contained in:
parent
97e6e619ff
commit
d1a29709f2
64
eg/rudiments/cmp-litword.60p
Normal file
64
eg/rudiments/cmp-litword.60p
Normal file
@ -0,0 +1,64 @@
|
||||
// Include `support/${PLATFORM}.60p` before this source
|
||||
// Should print ENGGL
|
||||
|
||||
word w1
|
||||
|
||||
define main routine
|
||||
outputs w1
|
||||
trashes a, x, y, z, n, c, v
|
||||
{
|
||||
copy 4000, w1
|
||||
|
||||
cmp w1, 4000
|
||||
if z {
|
||||
ld a, 69 // E
|
||||
call chrout
|
||||
} else {
|
||||
ld a, 78 // N
|
||||
call chrout
|
||||
}
|
||||
|
||||
copy 4000, w1
|
||||
|
||||
cmp w1, 4001
|
||||
if z {
|
||||
ld a, 69 // E
|
||||
call chrout
|
||||
} else {
|
||||
ld a, 78 // N
|
||||
call chrout
|
||||
}
|
||||
|
||||
copy 20002, w1
|
||||
|
||||
cmp w1, 20001 // 20002 >= 20001
|
||||
if c {
|
||||
ld a, 71 // G
|
||||
call chrout
|
||||
} else {
|
||||
ld a, 76 // L
|
||||
call chrout
|
||||
}
|
||||
|
||||
copy 20001, w1
|
||||
|
||||
cmp w1, 20001 // 20001 >= 20001
|
||||
if c {
|
||||
ld a, 71 // G
|
||||
call chrout
|
||||
} else {
|
||||
ld a, 76 // L
|
||||
call chrout
|
||||
}
|
||||
|
||||
copy 20000, w1
|
||||
|
||||
cmp w1, 20001 // 20000 < 20001
|
||||
if c {
|
||||
ld a, 71 // G
|
||||
call chrout
|
||||
} else {
|
||||
ld a, 76 // L
|
||||
call chrout
|
||||
}
|
||||
}
|
@ -405,11 +405,11 @@ class Compiler(object):
|
||||
if isinstance(src, ConstantRef) and src.type == TYPE_WORD:
|
||||
dest_label = self.get_label(dest.name)
|
||||
self.emitter.emit(LDA(Absolute(dest_label)))
|
||||
self.emitter.emit(CMP(Immediate(Byte(src.high_byte()))))
|
||||
self.emitter.emit(CMP(Immediate(Byte(src.low_byte()))))
|
||||
end_label = Label('end_label')
|
||||
self.emitter.emit(BNE(Relative(end_label)))
|
||||
self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(CMP(Immediate(Byte(src.low_byte()))))
|
||||
self.emitter.emit(CMP(Immediate(Byte(src.high_byte()))))
|
||||
self.emitter.resolve_label(end_label)
|
||||
return
|
||||
cls = {
|
||||
|
@ -403,10 +403,10 @@ Compiling 16-bit `cmp`.
|
||||
= $0815 LDA $EA62
|
||||
= $0818 CMP $0829
|
||||
= $081B LDA $EA61
|
||||
= $081E CMP #$0F
|
||||
= $081E CMP #$A0
|
||||
= $0820 BNE $0827
|
||||
= $0822 LDA $EA62
|
||||
= $0825 CMP #$A0
|
||||
= $0825 CMP #$0F
|
||||
= $0827 RTS
|
||||
= $0828 .byte $BB
|
||||
= $0829 .byte $0B
|
||||
|
Loading…
x
Reference in New Issue
Block a user