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