mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Add syntax to push and modify stacks in one line (#1421)
This commit is contained in:
24
man/rgbasm.5
24
man/rgbasm.5
@@ -500,6 +500,7 @@ There is also a character map stack that can be used to save and restore which c
|
||||
.It Ic NEWCHARMAP Ar name , basename Ta Creates a new character map called Ar name , No copied from character map Ar basename , No and switches to it .
|
||||
.It Ic SETCHARMAP Ar name Ta Switch to character map Ar name .
|
||||
.It Ic PUSHC Ta Push the current character map onto the stack.
|
||||
.It Ic PUSHC Ar name Ta Push the current character map onto the stack and switch to character map Ar name .
|
||||
.It Ic POPC Ta Pop a character map off the stack and switch to it.
|
||||
.El
|
||||
.Pp
|
||||
@@ -756,6 +757,20 @@ will push the current section context on the section stack.
|
||||
.Ic POPS
|
||||
can then later be used to restore it.
|
||||
Useful for defining sections in included files when you don't want to override the section context at the point the file was included.
|
||||
.Pp
|
||||
.Ic PUSHS
|
||||
can also take the same arguments as
|
||||
.Ic SECTION ,
|
||||
in order to push the current section context and define a new section at the same time:
|
||||
.Bd -literal -offset indent
|
||||
SECTION "Code", ROM0
|
||||
Function:
|
||||
ld a, 42
|
||||
PUSHS "Variables", WRAM0
|
||||
wAnswer: db
|
||||
POPS
|
||||
ld [wAnswer], a
|
||||
.Ed
|
||||
.Ss RAM code
|
||||
Sometimes you want to have some code in RAM.
|
||||
But then you can't simply put it in a RAM section, you have to store it in ROM and copy it to RAM at some point.
|
||||
@@ -2091,6 +2106,15 @@ will push the current set of options on the option stack.
|
||||
can then later be used to restore them.
|
||||
Useful if you want to change some options in an include file and you don't want to destroy the options set by the program that included your file.
|
||||
The stack's number of entries is limited only by the amount of memory in your machine.
|
||||
.Pp
|
||||
.Ic PUSHO
|
||||
can also take a comma-separated list of options, to push the current set and apply the argument set at the same time:
|
||||
.Bd -literal -offset indent
|
||||
PUSHO b.X, g.oOX
|
||||
DB %..XXXX..
|
||||
DW `..ooOOXX
|
||||
POPO
|
||||
.Ed
|
||||
.Ss Requesting alignment
|
||||
While
|
||||
.Ic ALIGN
|
||||
|
||||
@@ -545,6 +545,7 @@ directive:
|
||||
| setcharmap
|
||||
| pushc
|
||||
| popc
|
||||
| pushc_setcharmap
|
||||
| load
|
||||
| shift
|
||||
| fail
|
||||
@@ -561,6 +562,7 @@ directive:
|
||||
| purge
|
||||
| pops
|
||||
| pushs
|
||||
| pushs_section
|
||||
| endsection
|
||||
| popo
|
||||
| pusho
|
||||
@@ -664,7 +666,16 @@ popo:
|
||||
pusho:
|
||||
POP_PUSHO {
|
||||
opt_Push();
|
||||
// Parsing 'optional_opt_list' will restore the lexer's normal mode
|
||||
lexer_SetMode(LEXER_RAW);
|
||||
} optional_opt_list
|
||||
;
|
||||
|
||||
optional_opt_list:
|
||||
%empty {
|
||||
lexer_SetMode(LEXER_NORMAL);
|
||||
}
|
||||
| opt_list
|
||||
;
|
||||
|
||||
pops:
|
||||
@@ -1067,6 +1078,13 @@ pushc:
|
||||
}
|
||||
;
|
||||
|
||||
pushc_setcharmap:
|
||||
POP_PUSHC ID {
|
||||
charmap_Push();
|
||||
charmap_Set($2);
|
||||
}
|
||||
;
|
||||
|
||||
popc:
|
||||
POP_POPC {
|
||||
charmap_Pop();
|
||||
@@ -1536,6 +1554,13 @@ section:
|
||||
}
|
||||
;
|
||||
|
||||
pushs_section:
|
||||
POP_PUSHS sect_mod string COMMA sect_type sect_org sect_attrs {
|
||||
sect_PushSection();
|
||||
sect_NewSection($3, (SectionType)$5, $6, $7, $2);
|
||||
}
|
||||
;
|
||||
|
||||
sect_mod:
|
||||
%empty {
|
||||
$$ = SECTION_NORMAL;
|
||||
|
||||
@@ -4,3 +4,4 @@ opt p1234
|
||||
opt Q1234
|
||||
opt Q32
|
||||
opt W
|
||||
opt
|
||||
|
||||
@@ -10,4 +10,6 @@ error: invalid-opt.asm(5):
|
||||
Argument for option 'Q' must be between 1 and 31
|
||||
error: invalid-opt.asm(6):
|
||||
Must specify an argument for option 'W'
|
||||
error: Assembly aborted (6 errors)!
|
||||
error: invalid-opt.asm(7):
|
||||
syntax error, unexpected newline, expecting string
|
||||
error: Assembly aborted (7 errors)!
|
||||
|
||||
@@ -20,6 +20,11 @@ MACRO push_
|
||||
pushc
|
||||
ENDM
|
||||
|
||||
MACRO push_set_
|
||||
println "pushc \1"
|
||||
pushc \1
|
||||
ENDM
|
||||
|
||||
MACRO pop_
|
||||
println "popc"
|
||||
popc
|
||||
@@ -83,9 +88,8 @@ charmap "ef", $3
|
||||
|
||||
push_
|
||||
set_ map2
|
||||
push_
|
||||
|
||||
set_ map3
|
||||
push_set_ map3
|
||||
|
||||
print_mapped "ab"
|
||||
print_mapped "cd"
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
warning: multiple-charmaps.asm(41) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(46) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
warning: multiple-charmaps.asm(49) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(54) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
warning: multiple-charmaps.asm(68) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(73) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
warning: multiple-charmaps.asm(91) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(95) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
warning: multiple-charmaps.asm(92) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(96) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
warning: multiple-charmaps.asm(100) -> multiple-charmaps.asm::print_mapped(29): [-Wnumeric-string]
|
||||
warning: multiple-charmaps.asm(104) -> multiple-charmaps.asm::print_mapped(34): [-Wnumeric-string]
|
||||
Treating 2-character string as a number
|
||||
error: multiple-charmaps.asm(102) -> multiple-charmaps.asm::new_(9):
|
||||
error: multiple-charmaps.asm(106) -> multiple-charmaps.asm::new_(9):
|
||||
Charmap 'map1' already exists
|
||||
error: multiple-charmaps.asm(104) -> multiple-charmaps.asm::set_(15):
|
||||
error: multiple-charmaps.asm(108) -> multiple-charmaps.asm::set_(15):
|
||||
Charmap 'map5' doesn't exist
|
||||
error: multiple-charmaps.asm(106) -> multiple-charmaps.asm::pop_(25):
|
||||
error: multiple-charmaps.asm(110) -> multiple-charmaps.asm::pop_(30):
|
||||
No entries in the charmap stack
|
||||
error: Assembly aborted (3 errors)!
|
||||
|
||||
@@ -22,8 +22,7 @@ $3
|
||||
setcharmap map1
|
||||
pushc
|
||||
setcharmap map2
|
||||
pushc
|
||||
setcharmap map3
|
||||
pushc map3
|
||||
$1
|
||||
$6364
|
||||
$6566
|
||||
|
||||
@@ -12,3 +12,7 @@ popo
|
||||
println $8000_0000 / -1
|
||||
def n = 3.14
|
||||
println "{x:n} = {f:n}"
|
||||
|
||||
pusho p99
|
||||
ds 1
|
||||
popo
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user