1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/macros.oph Sat Jun 27 17:51:51 2015 +0200
1.3 @@ -0,0 +1,98 @@
1.4 +; Common macros.
1.5 +
1.6 +; Copyright (C) 2014, 2015 Paul Boddie <paul@boddie.org.uk>
1.7 +
1.8 +; This program is free software; you can redistribute it and/or modify it under
1.9 +; the terms of the GNU General Public License as published by the Free Software
1.10 +; Foundation; either version 3 of the License, or (at your option) any later
1.11 +; version.
1.12 +
1.13 +; This program is distributed in the hope that it will be useful, but WITHOUT
1.14 +; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.15 +; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.16 +; details.
1.17 +
1.18 +; You should have received a copy of the GNU General Public License along with
1.19 +; this program. If not, see <http://www.gnu.org/licenses/>.
1.20 +
1.21 +.alias oswrch $ffee
1.22 +
1.23 +.macro mode
1.24 + lda #22
1.25 + jsr oswrch
1.26 + lda #_1
1.27 + jsr oswrch
1.28 +.macend
1.29 +
1.30 +; store values in locations
1.31 +;
1.32 +; _1: valueW
1.33 +; _2: {_, _} -> {valueL, valueH}
1.34 +;
1.35 +; affects: A
1.36 +
1.37 +.macro store16
1.38 + lda #<_1
1.39 + sta _2
1.40 + lda #>_1
1.41 + sta _2+1
1.42 +.macend
1.43 +
1.44 +; copy word between locations
1.45 +;
1.46 +; _1: source
1.47 +; _2: target
1.48 +;
1.49 +; affects: A
1.50 +
1.51 +.macro mov16
1.52 + lda _1
1.53 + sta _2
1.54 + lda _1+1
1.55 + sta _2+1
1.56 +.macend
1.57 +
1.58 +; copy word from location to stack
1.59 +;
1.60 +; _1: source
1.61 +;
1.62 +; affects: A
1.63 +
1.64 +.macro push16
1.65 + lda _1
1.66 + pha
1.67 + lda _1+1
1.68 + pha
1.69 +.macend
1.70 +
1.71 +; copy word to location from stack
1.72 +;
1.73 +; _1: source
1.74 +;
1.75 +; affects: A
1.76 +
1.77 +.macro pull16
1.78 + pla
1.79 + sta _1+1
1.80 + pla
1.81 + sta _1
1.82 +.macend
1.83 +
1.84 +; add word to locations
1.85 +;
1.86 +; _1: valueW
1.87 +; _2: {valueL, valueH} -> {valueL', valueH'}
1.88 +;
1.89 +; affects: A, C
1.90 +
1.91 +.macro add16
1.92 + clc
1.93 + lda _2
1.94 + adc #<_1
1.95 + sta _2
1.96 + lda _2+1
1.97 + adc #>_1
1.98 + sta _2+1
1.99 +.macend
1.100 +
1.101 +; vim: tabstop=4 expandtab shiftwidth=4