mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-07 04:30:35 +00:00
Fix order of operands in word-sized cmp
.
This commit is contained in:
parent
046e43cd66
commit
94ee042a1e
@ -398,6 +398,9 @@ and initializing them afterwards.
|
||||
|
||||
Subtracts the contents of src from dest (without considering carry) but
|
||||
does not store the result anywhere, only sets the resulting flags.
|
||||
This means that `z` is set if src and dest are equal,
|
||||
and `c` is set if dest is greater than or equal to src
|
||||
(`c` is unset if dest is less than src.)
|
||||
|
||||
* It is illegal if src OR dest is uninitialized.
|
||||
|
||||
@ -407,7 +410,7 @@ and initializing them afterwards.
|
||||
In addition, if dest is of `word` type, then src must also be of `word`
|
||||
type, and in this case this instruction trashes the `a` register.
|
||||
|
||||
Note that, like `cmp` is not suitable for making a
|
||||
Note that `cmp` is not suitable for making a
|
||||
signed comparison; this article, which mentions
|
||||
techniques that a SixtyPical compiler could use to
|
||||
implement `cmp`, also explains why that is:
|
||||
|
@ -52,7 +52,7 @@ define main routine
|
||||
|
||||
ld a, 20
|
||||
|
||||
cmp a, b // 20 >= 21
|
||||
cmp a, b // 20 >= 20
|
||||
if c {
|
||||
ld a, 71 // G
|
||||
call chrout
|
||||
@ -63,7 +63,7 @@ define main routine
|
||||
|
||||
ld a, 19
|
||||
|
||||
cmp a, b // 19 < 21
|
||||
cmp a, b // 19 < 20
|
||||
if c {
|
||||
ld a, 71 // G
|
||||
call chrout
|
||||
|
@ -394,12 +394,12 @@ class Compiler(object):
|
||||
if isinstance(src, LocationRef) and src.type == TYPE_WORD:
|
||||
src_label = self.get_label(src.name)
|
||||
dest_label = self.get_label(dest.name)
|
||||
self.emitter.emit(LDA(Absolute(src_label)))
|
||||
self.emitter.emit(CMP(Absolute(dest_label)))
|
||||
self.emitter.emit(LDA(Absolute(dest_label)))
|
||||
self.emitter.emit(CMP(Absolute(src_label)))
|
||||
end_label = Label('end_label')
|
||||
self.emitter.emit(BNE(Relative(end_label)))
|
||||
self.emitter.emit(LDA(Absolute(Offset(src_label, 1))))
|
||||
self.emitter.emit(CMP(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
|
||||
self.emitter.emit(CMP(Absolute(Offset(src_label, 1))))
|
||||
self.emitter.resolve_label(end_label)
|
||||
return
|
||||
cls = {
|
||||
|
@ -396,11 +396,11 @@ Compiling 16-bit `cmp`.
|
||||
| {
|
||||
| cmp za, zb
|
||||
| }
|
||||
= $080D LDA $081C
|
||||
= $0810 CMP $EA61
|
||||
= $080D LDA $EA61
|
||||
= $0810 CMP $081C
|
||||
= $0813 BNE $081B
|
||||
= $0815 LDA $081D
|
||||
= $0818 CMP $EA62
|
||||
= $0815 LDA $EA62
|
||||
= $0818 CMP $081D
|
||||
= $081B RTS
|
||||
= $081C .byte $BB
|
||||
= $081D .byte $0B
|
||||
|
Loading…
x
Reference in New Issue
Block a user