git @ Cat's Eye Technologies SixtyPical / b9fb263
Add some failing tests for looping on the `n` flag. Chris Pressey 3 years ago
3 changed file(s) with 49 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
55 dcc6502 -o 0xf000 -m 200 smiley.bin > smiley.bin.disasm.txt
66 dcc6502 -o 0xf000 -m 200 smiley-60p.bin > smiley-60p.bin.disasm.txt
77 paste smiley.bin.disasm.txt smiley-60p.bin.disasm.txt | pr -t -e24
8 #diff -ru smiley.bin.disasm.txt smiley-60p.bin.disasm.txt
89 fi
16681668 | }
16691669 = ok
16701670
1671 While `repeat` is most often used with `z`, it can also be used with `n`.
1672
1673 | routine main
1674 | outputs y, n, z
1675 | {
1676 | ld y, 15
1677 | repeat {
1678 | dec y
1679 | } until n
1680 | }
1681 = ok
1682
16711683 ### for ###
16721684
16731685 Basic "open-faced for" loop. We'll start with the "upto" variant.
356356 = $0813 LDY #$01
357357 = $0815 RTS
358358
359 Compiling `repeat`.
359 Compiling `repeat ... until z`.
360360
361361 | routine main
362362 | trashes a, y, z, n, c
375375 = $0813 BNE $080F
376376 = $0815 RTS
377377
378 Compiling `repeat until not`.
378 Compiling `repeat ... until not z`.
379379
380380 | routine main
381381 | trashes a, y, z, n, c
393393 = $0811 CPY #$5B
394394 = $0813 BEQ $080F
395395 = $0815 RTS
396
397 Compiling `repeat ... until n`.
398
399 | routine main
400 | trashes a, y, z, n, c
401 | {
402 | ld y, 65
403 | repeat {
404 | ld a, y
405 | dec y
406 | } until n
407 | }
408 = $080D LDY #$41
409 = $080F TYA
410 = $0810 DEY
411 = $0811 BPL $080F
412 = $0813 RTS
413
414 Compiling `repeat ... until not n`.
415
416 | routine main
417 | trashes a, y, z, n, c
418 | {
419 | ld y, 65
420 | repeat {
421 | ld a, y
422 | inc y
423 | } until not n
424 | }
425 = $080D LDY #$41
426 = $080F TYA
427 = $0810 INY
428 = $0811 BMI $080F
429 = $0813 RTS
396430
397431 Compiling `repeat forever`.
398432