paul@0 | 1 | ; Common macros. |
paul@0 | 2 | |
paul@0 | 3 | ; Copyright (C) 2014, 2015 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 4 | |
paul@0 | 5 | ; This program is free software; you can redistribute it and/or modify it under |
paul@0 | 6 | ; the terms of the GNU General Public License as published by the Free Software |
paul@0 | 7 | ; Foundation; either version 3 of the License, or (at your option) any later |
paul@0 | 8 | ; version. |
paul@0 | 9 | |
paul@0 | 10 | ; This program is distributed in the hope that it will be useful, but WITHOUT |
paul@0 | 11 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@0 | 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@0 | 13 | ; details. |
paul@0 | 14 | |
paul@0 | 15 | ; You should have received a copy of the GNU General Public License along with |
paul@0 | 16 | ; this program. If not, see <http://www.gnu.org/licenses/>. |
paul@0 | 17 | |
paul@0 | 18 | .alias oswrch $ffee |
paul@0 | 19 | |
paul@0 | 20 | .macro mode |
paul@0 | 21 | lda #22 |
paul@0 | 22 | jsr oswrch |
paul@0 | 23 | lda #_1 |
paul@0 | 24 | jsr oswrch |
paul@0 | 25 | .macend |
paul@0 | 26 | |
paul@0 | 27 | ; store values in locations |
paul@0 | 28 | ; |
paul@0 | 29 | ; _1: valueW |
paul@0 | 30 | ; _2: {_, _} -> {valueL, valueH} |
paul@0 | 31 | ; |
paul@0 | 32 | ; affects: A |
paul@0 | 33 | |
paul@0 | 34 | .macro store16 |
paul@0 | 35 | lda #<_1 |
paul@0 | 36 | sta _2 |
paul@0 | 37 | lda #>_1 |
paul@0 | 38 | sta _2+1 |
paul@0 | 39 | .macend |
paul@0 | 40 | |
paul@0 | 41 | ; copy word between locations |
paul@0 | 42 | ; |
paul@0 | 43 | ; _1: source |
paul@0 | 44 | ; _2: target |
paul@0 | 45 | ; |
paul@0 | 46 | ; affects: A |
paul@0 | 47 | |
paul@0 | 48 | .macro mov16 |
paul@0 | 49 | lda _1 |
paul@0 | 50 | sta _2 |
paul@0 | 51 | lda _1+1 |
paul@0 | 52 | sta _2+1 |
paul@0 | 53 | .macend |
paul@0 | 54 | |
paul@0 | 55 | ; copy word from location to stack |
paul@0 | 56 | ; |
paul@0 | 57 | ; _1: source |
paul@0 | 58 | ; |
paul@0 | 59 | ; affects: A |
paul@0 | 60 | |
paul@0 | 61 | .macro push16 |
paul@0 | 62 | lda _1 |
paul@0 | 63 | pha |
paul@0 | 64 | lda _1+1 |
paul@0 | 65 | pha |
paul@0 | 66 | .macend |
paul@0 | 67 | |
paul@0 | 68 | ; copy word to location from stack |
paul@0 | 69 | ; |
paul@0 | 70 | ; _1: source |
paul@0 | 71 | ; |
paul@0 | 72 | ; affects: A |
paul@0 | 73 | |
paul@0 | 74 | .macro pull16 |
paul@0 | 75 | pla |
paul@0 | 76 | sta _1+1 |
paul@0 | 77 | pla |
paul@0 | 78 | sta _1 |
paul@0 | 79 | .macend |
paul@0 | 80 | |
paul@0 | 81 | ; add word to locations |
paul@0 | 82 | ; |
paul@0 | 83 | ; _1: valueW |
paul@0 | 84 | ; _2: {valueL, valueH} -> {valueL', valueH'} |
paul@0 | 85 | ; |
paul@0 | 86 | ; affects: A, C |
paul@0 | 87 | |
paul@0 | 88 | .macro add16 |
paul@0 | 89 | clc |
paul@0 | 90 | lda _2 |
paul@0 | 91 | adc #<_1 |
paul@0 | 92 | sta _2 |
paul@0 | 93 | lda _2+1 |
paul@0 | 94 | adc #>_1 |
paul@0 | 95 | sta _2+1 |
paul@0 | 96 | .macend |
paul@0 | 97 | |
paul@0 | 98 | ; vim: tabstop=4 expandtab shiftwidth=4 |