git @ Cat's Eye Technologies SixtyPical / 97e6e61
`cmp` can compare against a literal word. Chris Pressey 4 years ago
4 changed file(s) with 45 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
99 * When the range of a location is known, `inc` and `dec`
1010 on it will usually shift the known instead of invalidating it.
1111 * `cmp` instruction can now perform a 16-bit unsigned comparison
12 of `word` memory locations (at the cost of trashing `a`.)
12 of `word` memory locations and `word` literals (at the cost of
13 trashing the `a` register.)
1314 * Fixed pathological memory use in the lexical scanner - should
1415 be much less inefficient now when parsing large source files.
1516 * Reorganized the examples in `eg/rudiments/` to make them
399399 self.emitter.emit(BNE(Relative(end_label)))
400400 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
401401 self.emitter.emit(CMP(Absolute(Offset(src_label, 1))))
402 self.emitter.resolve_label(end_label)
403 return
404 if isinstance(src, ConstantRef) and src.type == TYPE_WORD:
405 dest_label = self.get_label(dest.name)
406 self.emitter.emit(LDA(Absolute(dest_label)))
407 self.emitter.emit(CMP(Immediate(Byte(src.high_byte()))))
408 end_label = Label('end_label')
409 self.emitter.emit(BNE(Relative(end_label)))
410 self.emitter.emit(LDA(Absolute(Offset(dest_label, 1))))
411 self.emitter.emit(CMP(Immediate(Byte(src.low_byte()))))
402412 self.emitter.resolve_label(end_label)
403413 return
404414 cls = {
12051205 | cmp za, zb
12061206 | }
12071207 ? UnmeaningfulReadError: zb
1208
1209 `cmp` can compare against a literal word.
1210
1211 | word za
1212 |
1213 | define main routine
1214 | inputs za
1215 | trashes a, z, c, n
1216 | {
1217 | cmp za, 4000
1218 | }
1219 = ok
1220
1221 | word za
1222 |
1223 | define main routine
1224 | inputs za
1225 | trashes z, c, n
1226 | {
1227 | cmp za, 4000
1228 | }
1229 ? ForbiddenWriteError: a
12081230
12091231 ### and ###
12101232
394394 | trashes a, z, c, n
395395 | {
396396 | cmp za, zb
397 | cmp za, 4000
397398 | }
398399 = $080D LDA $EA61
399 = $0810 CMP $081C
400 = $0810 CMP $0828
400401 = $0813 BNE $081B
401402 = $0815 LDA $EA62
402 = $0818 CMP $081D
403 = $081B RTS
404 = $081C .byte $BB
405 = $081D .byte $0B
403 = $0818 CMP $0829
404 = $081B LDA $EA61
405 = $081E CMP #$0F
406 = $0820 BNE $0827
407 = $0822 LDA $EA62
408 = $0825 CMP #$A0
409 = $0827 RTS
410 = $0828 .byte $BB
411 = $0829 .byte $0B
406412
407413 Compiling `if`.
408414