git @ Cat's Eye Technologies SixtyPical / 2803aa2
Add failing tests for `add` and `sub` on locations other than `a`. Chris Pressey 6 years ago
2 changed file(s) with 83 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
851851 | }
852852 ? ForbiddenWriteError: a
853853
854 You can `add` a byte constant to a byte memory location.
855
856 | byte lives
857 | define main routine
858 | inputs a, lives
859 | outputs lives
860 | trashes a, c, z, v, n
861 | {
862 | st off, c
863 | add lives, 3
864 | }
865 = ok
866
867 `add`ing a byte constant to a byte memory location trashes `a`.
868
869 | byte lives
870 | define main routine
871 | inputs a, lives
872 | outputs lives
873 | trashes c, z, v, n
874 | {
875 | st off, c
876 | add lives, 3
877 | }
878 ? UnmeaningfulOutputError: a
879
854880 You can `add` a word constant to a word memory location.
855881
856882 | word score
9941020 | sub a, 0
9951021 | }
9961022 ? ForbiddenWriteError: a
1023
1024 You can `sub` a byte constant from a byte memory location.
1025
1026 | byte lives
1027 | define main routine
1028 | inputs a, lives
1029 | outputs lives
1030 | trashes a, c, z, v, n
1031 | {
1032 | st on, c
1033 | sub lives, 3
1034 | }
1035 = ok
1036
1037 `sub`ing a byte constant from a byte memory location trashes `a`.
1038
1039 | byte lives
1040 | define main routine
1041 | inputs a, lives
1042 | outputs lives
1043 | trashes c, z, v, n
1044 | {
1045 | st on, c
1046 | sub lives, 3
1047 | }
1048 ? UnmeaningfulOutputError: a
9971049
9981050 You can `sub` a word constant from a word memory location.
9991051
10241024 = $0842 JMP ($0846)
10251025 = $0845 RTS
10261026
1027 ### add, sub
1028
1029 Various modes of `add`.
1030
1031 | byte lives
1032 | word score
1033 | define main routine
1034 | inputs lives, score
1035 | outputs lives, score
1036 | trashes a, x, y, c, z, v, n
1037 | {
1038 | ld a, 0
1039 | ld x, 0
1040 | ld y, 0
1041 | st off, c
1042 | add a, 7
1043 | add a, lives
1044 | // add x, 7
1045 | // add y, 7
1046 | add lives, 2
1047 | add score, 1999
1048 | }
1049 = $080D CLC
1050 = $080E LDA $081F
1051 = $0811 ADC #$CF
1052 = $0813 STA $081F
1053 = $0816 LDA $0820
1054 = $0819 ADC #$07
1055 = $081B STA $0820
1056 = $081E RTS
1057
10271058 ### word operations
10281059
10291060 Adding a constant word to a word memory location.