mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Allow :: to join instructions *and* data declarations (#1785)
This commit is contained in:
@@ -43,7 +43,9 @@ Labels tie a name to a specific location within a section (see
|
|||||||
below).
|
below).
|
||||||
.Pp
|
.Pp
|
||||||
Instructions are assembled into Game Boy opcodes.
|
Instructions are assembled into Game Boy opcodes.
|
||||||
Multiple instructions on one line can be separated by double colons
|
Multiple instructions on one line, as well as data directives (see
|
||||||
|
.Sx Defining constant data in ROM
|
||||||
|
below), can be separated by double colons
|
||||||
.Ql :: .
|
.Ql :: .
|
||||||
.Pp
|
.Pp
|
||||||
The available instructions are documented in
|
The available instructions are documented in
|
||||||
|
|||||||
122
src/asm/parser.y
122
src/asm/parser.y
@@ -480,7 +480,7 @@ else:
|
|||||||
|
|
||||||
plain_directive:
|
plain_directive:
|
||||||
label
|
label
|
||||||
| label cpu_commands
|
| label data
|
||||||
| label macro
|
| label macro
|
||||||
| label directive
|
| label directive
|
||||||
;
|
;
|
||||||
@@ -562,10 +562,6 @@ directive:
|
|||||||
| println
|
| println
|
||||||
| export
|
| export
|
||||||
| export_def
|
| export_def
|
||||||
| db
|
|
||||||
| dw
|
|
||||||
| dl
|
|
||||||
| ds
|
|
||||||
| section
|
| section
|
||||||
| rsreset
|
| rsreset
|
||||||
| rsset
|
| rsset
|
||||||
@@ -889,56 +885,6 @@ endu:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
ds:
|
|
||||||
POP_DS uconst {
|
|
||||||
sect_Skip($2, true);
|
|
||||||
}
|
|
||||||
| POP_DS uconst COMMA ds_args trailing_comma {
|
|
||||||
sect_RelBytes($2, $4);
|
|
||||||
}
|
|
||||||
| POP_DS POP_ALIGN LBRACK align_spec RBRACK trailing_comma {
|
|
||||||
uint32_t n = sect_GetAlignBytes($4.alignment, $4.alignOfs);
|
|
||||||
sect_Skip(n, true);
|
|
||||||
sect_AlignPC($4.alignment, $4.alignOfs);
|
|
||||||
}
|
|
||||||
| POP_DS POP_ALIGN LBRACK align_spec RBRACK COMMA ds_args trailing_comma {
|
|
||||||
uint32_t n = sect_GetAlignBytes($4.alignment, $4.alignOfs);
|
|
||||||
sect_RelBytes(n, $7);
|
|
||||||
sect_AlignPC($4.alignment, $4.alignOfs);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
ds_args:
|
|
||||||
reloc_8bit {
|
|
||||||
$$.push_back(std::move($1));
|
|
||||||
}
|
|
||||||
| ds_args COMMA reloc_8bit {
|
|
||||||
$$ = std::move($1);
|
|
||||||
$$.push_back(std::move($3));
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
db:
|
|
||||||
POP_DB {
|
|
||||||
sect_Skip(1, false);
|
|
||||||
}
|
|
||||||
| POP_DB constlist_8bit trailing_comma
|
|
||||||
;
|
|
||||||
|
|
||||||
dw:
|
|
||||||
POP_DW {
|
|
||||||
sect_Skip(2, false);
|
|
||||||
}
|
|
||||||
| POP_DW constlist_16bit trailing_comma
|
|
||||||
;
|
|
||||||
|
|
||||||
dl:
|
|
||||||
POP_DL {
|
|
||||||
sect_Skip(4, false);
|
|
||||||
}
|
|
||||||
| POP_DL constlist_32bit trailing_comma
|
|
||||||
;
|
|
||||||
|
|
||||||
def_equ:
|
def_equ:
|
||||||
def_id POP_EQU iconst {
|
def_id POP_EQU iconst {
|
||||||
$$ = std::move($1);
|
$$ = std::move($1);
|
||||||
@@ -1775,15 +1721,19 @@ sect_attrs:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
// CPU commands.
|
// CPU instructions and data declarations
|
||||||
|
|
||||||
cpu_commands:
|
data:
|
||||||
cpu_command
|
datum
|
||||||
| cpu_command DOUBLE_COLON cpu_commands
|
| datum DOUBLE_COLON data
|
||||||
;
|
;
|
||||||
|
|
||||||
cpu_command:
|
datum:
|
||||||
sm83_adc
|
db
|
||||||
|
| dw
|
||||||
|
| dl
|
||||||
|
| ds
|
||||||
|
| sm83_adc
|
||||||
| sm83_add
|
| sm83_add
|
||||||
| sm83_and
|
| sm83_and
|
||||||
| sm83_bit
|
| sm83_bit
|
||||||
@@ -1831,6 +1781,56 @@ cpu_command:
|
|||||||
| sm83_xor
|
| sm83_xor
|
||||||
;
|
;
|
||||||
|
|
||||||
|
ds:
|
||||||
|
POP_DS uconst {
|
||||||
|
sect_Skip($2, true);
|
||||||
|
}
|
||||||
|
| POP_DS uconst COMMA ds_args trailing_comma {
|
||||||
|
sect_RelBytes($2, $4);
|
||||||
|
}
|
||||||
|
| POP_DS POP_ALIGN LBRACK align_spec RBRACK trailing_comma {
|
||||||
|
uint32_t n = sect_GetAlignBytes($4.alignment, $4.alignOfs);
|
||||||
|
sect_Skip(n, true);
|
||||||
|
sect_AlignPC($4.alignment, $4.alignOfs);
|
||||||
|
}
|
||||||
|
| POP_DS POP_ALIGN LBRACK align_spec RBRACK COMMA ds_args trailing_comma {
|
||||||
|
uint32_t n = sect_GetAlignBytes($4.alignment, $4.alignOfs);
|
||||||
|
sect_RelBytes(n, $7);
|
||||||
|
sect_AlignPC($4.alignment, $4.alignOfs);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
ds_args:
|
||||||
|
reloc_8bit {
|
||||||
|
$$.push_back(std::move($1));
|
||||||
|
}
|
||||||
|
| ds_args COMMA reloc_8bit {
|
||||||
|
$$ = std::move($1);
|
||||||
|
$$.push_back(std::move($3));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
db:
|
||||||
|
POP_DB {
|
||||||
|
sect_Skip(1, false);
|
||||||
|
}
|
||||||
|
| POP_DB constlist_8bit trailing_comma
|
||||||
|
;
|
||||||
|
|
||||||
|
dw:
|
||||||
|
POP_DW {
|
||||||
|
sect_Skip(2, false);
|
||||||
|
}
|
||||||
|
| POP_DW constlist_16bit trailing_comma
|
||||||
|
;
|
||||||
|
|
||||||
|
dl:
|
||||||
|
POP_DL {
|
||||||
|
sect_Skip(4, false);
|
||||||
|
}
|
||||||
|
| POP_DL constlist_32bit trailing_comma
|
||||||
|
;
|
||||||
|
|
||||||
sm83_adc:
|
sm83_adc:
|
||||||
SM83_ADC op_a_n {
|
SM83_ADC op_a_n {
|
||||||
sect_ConstByte(0xCE);
|
sect_ConstByte(0xCE);
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ Label: nop :: call z, .local :: ld b, a
|
|||||||
|
|
||||||
Label2::jr Label2::ret
|
Label2::jr Label2::ret
|
||||||
.local2::call nz, .local2::ret
|
.local2::call nz, .local2::ret
|
||||||
|
|
||||||
|
Label3:: db 1, 2 :: dw 3, 4 :: dl 5, 6 :: ds 7, 8 :: ret
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user