uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit ef9405372397e5023a0a0dd6ef553b34279715d9
parent b43f973adb0eae2880143242be77557d21fd6008
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed, 21 Apr 2021 13:45:17 +0100

Allow device memory offsets in assembler

Diffstat:
Mprojects/examples/dev.console.usm | 11++++++++---
Mprojects/examples/dev.controller.buttons.usm | 15+++++++++------
Mprojects/examples/dev.file.usm | 21+++++++++++++--------
Msrc/assembler.c | 4++--
4 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/projects/examples/dev.console.usm b/projects/examples/dev.console.usm @@ -2,6 +2,14 @@ %RTN { JMP2r } +( devices ) + +|10 @Console [ &pad $8 &char $1 ] + +( variables ) + +|0000 + ( program ) |0100 @@ -22,6 +30,3 @@ RTN @hello-word [ 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 ] -( devices ) - -|ff10 @Console [ &pad $8 &char $1 ] diff --git a/projects/examples/dev.controller.buttons.usm b/projects/examples/dev.controller.buttons.usm @@ -6,8 +6,17 @@ %=>SC/ADDR { .Screen/addr IOW2 } %->SC/COLR { .Screen/color IOW } +( devices ) + +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] + ( variables ) +|0000 + @slime $1 |0100 @@ -78,9 +87,3 @@ BRK @right_icn [ 3c7e f7f8 f8f7 7e3c ] @slime_icn [ 0000 183c 3c18 0000 ] -( devices ) - -|ff00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|ff10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] -|ff20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] -|ff40 @Controller [ &vector $2 &button $1 &key $1 ] diff --git a/projects/examples/dev.file.usm b/projects/examples/dev.file.usm @@ -16,6 +16,19 @@ %MEMORY { #1000 } +( devices ) + +|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] +|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|40 @Controller [ &vector $2 &button $1 &key $1 ] +|60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] + +( variables ) + +|0000 + @loadbtn [ &x $2 &y $2 ] @output [ &x $2 &y $2 ] @pointer [ &x $2 &y $2 ] @@ -192,11 +205,3 @@ RTN 0000 0032 4c00 0000 3c42 99a1 a199 423c ] -( devices ) - -|ff00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|ff10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] -|ff20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] -|ff40 @Controller [ &vector $2 &button $1 &key $1 ] -|ff60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] -|ff70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] diff --git a/src/assembler.c b/src/assembler.c @@ -286,8 +286,6 @@ pass1(FILE *f) while(fscanf(f, "%s", w) == 1) { if(skipblock(w, &ccmnt, '(', ')')) continue; if(w[0] == '|') { - if(shex(w + 1) < addr) - return error("Memory Overwrite", w); addr = shex(w + 1); } else if(w[0] == '%') { if(!makemacro(w + 1, f)) @@ -322,6 +320,8 @@ pass2(FILE *f) if(skipblock(w, &ccmnt, '(', ')')) continue; if(skipblock(w, &ctemplate, '{', '}')) continue; if(w[0] == '|') { + if(p.length && shex(w + 1) < p.ptr) + return error("Memory Overwrite", w); p.ptr = shex(w + 1); continue; } else if(w[0] == '$') {