Add support for multiple charmaps

This adds two new directives: newcharmap and setcharmap.
newcharmap creates a new charmap and switches to it.
setcharmap switches to an existing charmap.
This commit is contained in:
dbrotz
2019-08-29 21:54:06 -07:00
parent 12d82eb768
commit e05199ca1e
17 changed files with 395 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
SECTION "sec", ROM0
charmap "A", 1
SECTION "sec", ROM0
_A_ EQU "A"
db _A_

View File

@@ -0,0 +1,88 @@
printt "main charmap\n"
charmap "ab", $0
x = "ab"
printt "{x}\n"
printt "newcharmap map1\n"
newcharmap map1
x = "ab"
printt "{x}\n"
printt "newcharmap map2, main\n"
newcharmap map2, main
x = "ab"
printt "{x}\n"
printt "setcharmap map1\n"
setcharmap map1
x = "ab"
printt "{x}\n"
printt "newcharmap map3\n"
newcharmap map3
charmap "ab", $1
x = "ab"
printt "{x}\n"
printt "newcharmap map4, map3\n"
newcharmap map4, map3
charmap "ab", $1
charmap "cd", $2
x = "ab"
printt "{x}\n"
x = "cd"
printt "{x}\n"
printt "setcharmap map3\n"
setcharmap map3
x = "ab"
printt "{x}\n"
x = "cd"
printt "{x}\n"
printt "setcharmap main\n"
setcharmap main
SECTION "sec0", ROM0
x = "ab"
printt "{x}\n"
printt "override main charmap\n"
charmap "ef", $3
x = "ab"
printt "{x}\n"
x = "ef"
printt "{x}\n"
printt "setcharmap map3\n"
setcharmap map3
x = "ab"
printt "{x}\n"
x = "cd"
printt "{x}\n"
x = "ef"
printt "{x}\n"
printt "newcharmap map1\n"
newcharmap map1
printt "setcharmap map5\n"
setcharmap map5

View File

@@ -0,0 +1,34 @@
warning: multiple-charmaps.asm(64):
Using 'charmap' within a section when the current charmap is 'main' is deprecated
ERROR: multiple-charmaps.asm(85):
Charmap 'map1' already exists
ERROR: multiple-charmaps.asm(88):
Charmap 'map5' doesn't exist
error: Assembly aborted (2 errors)!
main charmap
$0
newcharmap map1
$6162
newcharmap map2, main
$0
setcharmap map1
$6162
newcharmap map3
$1
newcharmap map4, map3
$1
$2
setcharmap map3
$1
$6364
setcharmap main
$0
override main charmap
$6162
$3
setcharmap map3
$1
$6364
$6566
newcharmap map1
setcharmap map5

View File

@@ -0,0 +1,34 @@
warning: -(64):
Using 'charmap' within a section when the current charmap is 'main' is deprecated
ERROR: -(85):
Charmap 'map1' already exists
ERROR: -(88):
Charmap 'map5' doesn't exist
error: Assembly aborted (2 errors)!
main charmap
$0
newcharmap map1
$6162
newcharmap map2, main
$0
setcharmap map1
$6162
newcharmap map3
$1
newcharmap map4, map3
$1
$2
setcharmap map3
$1
$6364
setcharmap main
$0
override main charmap
$6162
$3
setcharmap map3
$1
$6364
$6566
newcharmap map1
setcharmap map5