Rename Z80 prefix to SM83

This commit is contained in:
Rangi42
2025-01-24 12:11:46 -05:00
parent 91d7ce5e09
commit 84f59e14ed
2 changed files with 296 additions and 296 deletions

View File

@@ -139,53 +139,53 @@ struct CaseInsensitive {
// Tokens / keywords not handled here are handled in `yylex_NORMAL`'s switch. // Tokens / keywords not handled here are handled in `yylex_NORMAL`'s switch.
// This assumes that no two keywords have the same name. // This assumes that no two keywords have the same name.
static std::unordered_map<std::string, int, CaseInsensitive, CaseInsensitive> keywordDict = { static std::unordered_map<std::string, int, CaseInsensitive, CaseInsensitive> keywordDict = {
{"ADC", T_(Z80_ADC) }, {"ADC", T_(SM83_ADC) },
{"ADD", T_(Z80_ADD) }, {"ADD", T_(SM83_ADD) },
{"AND", T_(Z80_AND) }, {"AND", T_(SM83_AND) },
{"BIT", T_(Z80_BIT) }, {"BIT", T_(SM83_BIT) },
{"CALL", T_(Z80_CALL) }, {"CALL", T_(SM83_CALL) },
{"CCF", T_(Z80_CCF) }, {"CCF", T_(SM83_CCF) },
{"CPL", T_(Z80_CPL) }, {"CPL", T_(SM83_CPL) },
{"CP", T_(Z80_CP) }, {"CP", T_(SM83_CP) },
{"DAA", T_(Z80_DAA) }, {"DAA", T_(SM83_DAA) },
{"DEC", T_(Z80_DEC) }, {"DEC", T_(SM83_DEC) },
{"DI", T_(Z80_DI) }, {"DI", T_(SM83_DI) },
{"EI", T_(Z80_EI) }, {"EI", T_(SM83_EI) },
{"HALT", T_(Z80_HALT) }, {"HALT", T_(SM83_HALT) },
{"INC", T_(Z80_INC) }, {"INC", T_(SM83_INC) },
{"JP", T_(Z80_JP) }, {"JP", T_(SM83_JP) },
{"JR", T_(Z80_JR) }, {"JR", T_(SM83_JR) },
{"LD", T_(Z80_LD) }, {"LD", T_(SM83_LD) },
{"LDI", T_(Z80_LDI) }, {"LDI", T_(SM83_LDI) },
{"LDD", T_(Z80_LDD) }, {"LDD", T_(SM83_LDD) },
{"LDIO", T_(Z80_LDH) }, {"LDIO", T_(SM83_LDH) },
{"LDH", T_(Z80_LDH) }, {"LDH", T_(SM83_LDH) },
{"NOP", T_(Z80_NOP) }, {"NOP", T_(SM83_NOP) },
{"OR", T_(Z80_OR) }, {"OR", T_(SM83_OR) },
{"POP", T_(Z80_POP) }, {"POP", T_(SM83_POP) },
{"PUSH", T_(Z80_PUSH) }, {"PUSH", T_(SM83_PUSH) },
{"RES", T_(Z80_RES) }, {"RES", T_(SM83_RES) },
{"RETI", T_(Z80_RETI) }, {"RETI", T_(SM83_RETI) },
{"RET", T_(Z80_RET) }, {"RET", T_(SM83_RET) },
{"RLCA", T_(Z80_RLCA) }, {"RLCA", T_(SM83_RLCA) },
{"RLC", T_(Z80_RLC) }, {"RLC", T_(SM83_RLC) },
{"RLA", T_(Z80_RLA) }, {"RLA", T_(SM83_RLA) },
{"RL", T_(Z80_RL) }, {"RL", T_(SM83_RL) },
{"RRC", T_(Z80_RRC) }, {"RRC", T_(SM83_RRC) },
{"RRCA", T_(Z80_RRCA) }, {"RRCA", T_(SM83_RRCA) },
{"RRA", T_(Z80_RRA) }, {"RRA", T_(SM83_RRA) },
{"RR", T_(Z80_RR) }, {"RR", T_(SM83_RR) },
{"RST", T_(Z80_RST) }, {"RST", T_(SM83_RST) },
{"SBC", T_(Z80_SBC) }, {"SBC", T_(SM83_SBC) },
{"SCF", T_(Z80_SCF) }, {"SCF", T_(SM83_SCF) },
{"SET", T_(Z80_SET) }, {"SET", T_(SM83_SET) },
{"SLA", T_(Z80_SLA) }, {"SLA", T_(SM83_SLA) },
{"SRA", T_(Z80_SRA) }, {"SRA", T_(SM83_SRA) },
{"SRL", T_(Z80_SRL) }, {"SRL", T_(SM83_SRL) },
{"STOP", T_(Z80_STOP) }, {"STOP", T_(SM83_STOP) },
{"SUB", T_(Z80_SUB) }, {"SUB", T_(SM83_SUB) },
{"SWAP", T_(Z80_SWAP) }, {"SWAP", T_(SM83_SWAP) },
{"XOR", T_(Z80_XOR) }, {"XOR", T_(SM83_XOR) },
{"NZ", T_(CC_NZ) }, {"NZ", T_(CC_NZ) },
{"Z", T_(CC_Z) }, {"Z", T_(CC_Z) },
@@ -315,7 +315,7 @@ static std::unordered_map<std::string, int, CaseInsensitive, CaseInsensitive> ke
{"RB", T_(POP_RB) }, {"RB", T_(POP_RB) },
{"RW", T_(POP_RW) }, {"RW", T_(POP_RW) },
// There is no `T_(POP_RL)`; it's handled before as `T_(Z80_RL)` // There is no `T_(POP_RL)`; it's handled before as `T_(SM83_RL)`
{"EQU", T_(POP_EQU) }, {"EQU", T_(POP_EQU) },
{"EQUS", T_(POP_EQUS) }, {"EQUS", T_(POP_EQUS) },

View File

@@ -161,52 +161,52 @@
%token CC_Z "z" CC_NZ "nz" CC_NC "nc" // There is no CC_C, only TOKEN_C %token CC_Z "z" CC_NZ "nz" CC_NC "nc" // There is no CC_C, only TOKEN_C
// SM83 instructions // SM83 instructions
%token Z80_ADC "adc" %token SM83_ADC "adc"
%token Z80_ADD "add" %token SM83_ADD "add"
%token Z80_AND "and" %token SM83_AND "and"
%token Z80_BIT "bit" %token SM83_BIT "bit"
%token Z80_CALL "call" %token SM83_CALL "call"
%token Z80_CCF "ccf" %token SM83_CCF "ccf"
%token Z80_CP "cp" %token SM83_CP "cp"
%token Z80_CPL "cpl" %token SM83_CPL "cpl"
%token Z80_DAA "daa" %token SM83_DAA "daa"
%token Z80_DEC "dec" %token SM83_DEC "dec"
%token Z80_DI "di" %token SM83_DI "di"
%token Z80_EI "ei" %token SM83_EI "ei"
%token Z80_HALT "halt" %token SM83_HALT "halt"
%token Z80_INC "inc" %token SM83_INC "inc"
%token Z80_JP "jp" %token SM83_JP "jp"
%token Z80_JR "jr" %token SM83_JR "jr"
%token Z80_LDD "ldd" %token SM83_LDD "ldd"
%token Z80_LDH "ldh" %token SM83_LDH "ldh"
%token Z80_LDI "ldi" %token SM83_LDI "ldi"
%token Z80_LD "ld" %token SM83_LD "ld"
%token Z80_NOP "nop" %token SM83_NOP "nop"
%token Z80_OR "or" %token SM83_OR "or"
%token Z80_POP "pop" %token SM83_POP "pop"
%token Z80_PUSH "push" %token SM83_PUSH "push"
%token Z80_RES "res" %token SM83_RES "res"
%token Z80_RETI "reti" %token SM83_RETI "reti"
%token Z80_RET "ret" %token SM83_RET "ret"
%token Z80_RLA "rla" %token SM83_RLA "rla"
%token Z80_RLCA "rlca" %token SM83_RLCA "rlca"
%token Z80_RLC "rlc" %token SM83_RLC "rlc"
%token Z80_RL "rl" %token SM83_RL "rl"
%token Z80_RRA "rra" %token SM83_RRA "rra"
%token Z80_RRCA "rrca" %token SM83_RRCA "rrca"
%token Z80_RRC "rrc" %token SM83_RRC "rrc"
%token Z80_RR "rr" %token SM83_RR "rr"
%token Z80_RST "rst" %token SM83_RST "rst"
%token Z80_SBC "sbc" %token SM83_SBC "sbc"
%token Z80_SCF "scf" %token SM83_SCF "scf"
%token Z80_SET "set" %token SM83_SET "set"
%token Z80_SLA "sla" %token SM83_SLA "sla"
%token Z80_SRA "sra" %token SM83_SRA "sra"
%token Z80_SRL "srl" %token SM83_SRL "srl"
%token Z80_STOP "stop" %token SM83_STOP "stop"
%token Z80_SUB "sub" %token SM83_SUB "sub"
%token Z80_SWAP "swap" %token SM83_SWAP "swap"
%token Z80_XOR "xor" %token SM83_XOR "xor"
// Statement keywords // Statement keywords
%token POP_ALIGN "ALIGN" %token POP_ALIGN "ALIGN"
@@ -254,7 +254,7 @@
%token POP_REPT "REPT" %token POP_REPT "REPT"
%token POP_RSRESET "RSRESET" %token POP_RSRESET "RSRESET"
%token POP_RSSET "RSSET" %token POP_RSSET "RSSET"
// There is no POP_RL, only Z80_RL // There is no POP_RL, only SM83_RL
%token POP_RW "RW" %token POP_RW "RW"
%token POP_SECTION "SECTION" %token POP_SECTION "SECTION"
%token POP_SETCHARMAP "SETCHARMAP" %token POP_SETCHARMAP "SETCHARMAP"
@@ -1060,7 +1060,7 @@ def_rw:
; ;
def_rl: def_rl:
def_id Z80_RL rs_uconst { def_id SM83_RL rs_uconst {
$$ = std::move($1); $$ = std::move($1);
uint32_t rs = sym_GetRSValue(); uint32_t rs = sym_GetRSValue();
sym_AddEqu($$, rs); sym_AddEqu($$, rs);
@@ -1734,221 +1734,221 @@ cpu_commands:
; ;
cpu_command: cpu_command:
z80_adc sm83_adc
| z80_add | sm83_add
| z80_and | sm83_and
| z80_bit | sm83_bit
| z80_call | sm83_call
| z80_ccf | sm83_ccf
| z80_cp | sm83_cp
| z80_cpl | sm83_cpl
| z80_daa | sm83_daa
| z80_dec | sm83_dec
| z80_di | sm83_di
| z80_ei | sm83_ei
| z80_halt | sm83_halt
| z80_inc | sm83_inc
| z80_jp | sm83_jp
| z80_jr | sm83_jr
| z80_ld | sm83_ld
| z80_ldd | sm83_ldd
| z80_ldh | sm83_ldh
| z80_ldi | sm83_ldi
| z80_nop | sm83_nop
| z80_or | sm83_or
| z80_pop | sm83_pop
| z80_push | sm83_push
| z80_res | sm83_res
| z80_ret | sm83_ret
| z80_reti | sm83_reti
| z80_rl | sm83_rl
| z80_rla | sm83_rla
| z80_rlc | sm83_rlc
| z80_rlca | sm83_rlca
| z80_rr | sm83_rr
| z80_rra | sm83_rra
| z80_rrc | sm83_rrc
| z80_rrca | sm83_rrca
| z80_rst | sm83_rst
| z80_sbc | sm83_sbc
| z80_scf | sm83_scf
| z80_set | sm83_set
| z80_sla | sm83_sla
| z80_sra | sm83_sra
| z80_srl | sm83_srl
| z80_stop | sm83_stop
| z80_sub | sm83_sub
| z80_swap | sm83_swap
| z80_xor | sm83_xor
; ;
z80_adc: sm83_adc:
Z80_ADC op_a_n { SM83_ADC op_a_n {
sect_ConstByte(0xCE); sect_ConstByte(0xCE);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_ADC op_a_r { | SM83_ADC op_a_r {
sect_ConstByte(0x88 | $2); sect_ConstByte(0x88 | $2);
} }
; ;
z80_add: sm83_add:
Z80_ADD op_a_n { SM83_ADD op_a_n {
sect_ConstByte(0xC6); sect_ConstByte(0xC6);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_ADD op_a_r { | SM83_ADD op_a_r {
sect_ConstByte(0x80 | $2); sect_ConstByte(0x80 | $2);
} }
| Z80_ADD MODE_HL COMMA reg_ss { | SM83_ADD MODE_HL COMMA reg_ss {
sect_ConstByte(0x09 | ($4 << 4)); sect_ConstByte(0x09 | ($4 << 4));
} }
| Z80_ADD MODE_SP COMMA reloc_8bit { | SM83_ADD MODE_SP COMMA reloc_8bit {
sect_ConstByte(0xE8); sect_ConstByte(0xE8);
sect_RelByte($4, 1); sect_RelByte($4, 1);
} }
; ;
z80_and: sm83_and:
Z80_AND op_a_n { SM83_AND op_a_n {
sect_ConstByte(0xE6); sect_ConstByte(0xE6);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_AND op_a_r { | SM83_AND op_a_r {
sect_ConstByte(0xA0 | $2); sect_ConstByte(0xA0 | $2);
} }
; ;
z80_bit: sm83_bit:
Z80_BIT bit_const COMMA reg_r { SM83_BIT bit_const COMMA reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x40 | ($2 << 3) | $4); sect_ConstByte(0x40 | ($2 << 3) | $4);
} }
; ;
z80_call: sm83_call:
Z80_CALL reloc_16bit { SM83_CALL reloc_16bit {
sect_ConstByte(0xCD); sect_ConstByte(0xCD);
sect_RelWord($2, 1); sect_RelWord($2, 1);
} }
| Z80_CALL ccode_expr COMMA reloc_16bit { | SM83_CALL ccode_expr COMMA reloc_16bit {
sect_ConstByte(0xC4 | ($2 << 3)); sect_ConstByte(0xC4 | ($2 << 3));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
; ;
z80_ccf: sm83_ccf:
Z80_CCF { SM83_CCF {
sect_ConstByte(0x3F); sect_ConstByte(0x3F);
} }
; ;
z80_cp: sm83_cp:
Z80_CP op_a_n { SM83_CP op_a_n {
sect_ConstByte(0xFE); sect_ConstByte(0xFE);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_CP op_a_r { | SM83_CP op_a_r {
sect_ConstByte(0xB8 | $2); sect_ConstByte(0xB8 | $2);
} }
; ;
z80_cpl: sm83_cpl:
Z80_CPL { SM83_CPL {
sect_ConstByte(0x2F); sect_ConstByte(0x2F);
} }
| Z80_CPL MODE_A { | SM83_CPL MODE_A {
sect_ConstByte(0x2F); sect_ConstByte(0x2F);
} }
; ;
z80_daa: sm83_daa:
Z80_DAA { SM83_DAA {
sect_ConstByte(0x27); sect_ConstByte(0x27);
} }
; ;
z80_dec: sm83_dec:
Z80_DEC reg_r { SM83_DEC reg_r {
sect_ConstByte(0x05 | ($2 << 3)); sect_ConstByte(0x05 | ($2 << 3));
} }
| Z80_DEC reg_ss { | SM83_DEC reg_ss {
sect_ConstByte(0x0B | ($2 << 4)); sect_ConstByte(0x0B | ($2 << 4));
} }
; ;
z80_di: sm83_di:
Z80_DI { SM83_DI {
sect_ConstByte(0xF3); sect_ConstByte(0xF3);
} }
; ;
z80_ei: sm83_ei:
Z80_EI { SM83_EI {
sect_ConstByte(0xFB); sect_ConstByte(0xFB);
} }
; ;
z80_halt: sm83_halt:
Z80_HALT { SM83_HALT {
sect_ConstByte(0x76); sect_ConstByte(0x76);
} }
; ;
z80_inc: sm83_inc:
Z80_INC reg_r { SM83_INC reg_r {
sect_ConstByte(0x04 | ($2 << 3)); sect_ConstByte(0x04 | ($2 << 3));
} }
| Z80_INC reg_ss { | SM83_INC reg_ss {
sect_ConstByte(0x03 | ($2 << 4)); sect_ConstByte(0x03 | ($2 << 4));
} }
; ;
z80_jp: sm83_jp:
Z80_JP reloc_16bit { SM83_JP reloc_16bit {
sect_ConstByte(0xC3); sect_ConstByte(0xC3);
sect_RelWord($2, 1); sect_RelWord($2, 1);
} }
| Z80_JP ccode_expr COMMA reloc_16bit { | SM83_JP ccode_expr COMMA reloc_16bit {
sect_ConstByte(0xC2 | ($2 << 3)); sect_ConstByte(0xC2 | ($2 << 3));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
| Z80_JP MODE_HL { | SM83_JP MODE_HL {
sect_ConstByte(0xE9); sect_ConstByte(0xE9);
} }
; ;
z80_jr: sm83_jr:
Z80_JR reloc_16bit { SM83_JR reloc_16bit {
sect_ConstByte(0x18); sect_ConstByte(0x18);
sect_PCRelByte($2, 1); sect_PCRelByte($2, 1);
} }
| Z80_JR ccode_expr COMMA reloc_16bit { | SM83_JR ccode_expr COMMA reloc_16bit {
sect_ConstByte(0x20 | ($2 << 3)); sect_ConstByte(0x20 | ($2 << 3));
sect_PCRelByte($4, 1); sect_PCRelByte($4, 1);
} }
; ;
z80_ldi: sm83_ldi:
Z80_LDI LBRACK MODE_HL RBRACK COMMA MODE_A { SM83_LDI LBRACK MODE_HL RBRACK COMMA MODE_A {
sect_ConstByte(0x02 | (2 << 4)); sect_ConstByte(0x02 | (2 << 4));
} }
| Z80_LDI MODE_A COMMA LBRACK MODE_HL RBRACK { | SM83_LDI MODE_A COMMA LBRACK MODE_HL RBRACK {
sect_ConstByte(0x0A | (2 << 4)); sect_ConstByte(0x0A | (2 << 4));
} }
; ;
z80_ldd: sm83_ldd:
Z80_LDD LBRACK MODE_HL RBRACK COMMA MODE_A { SM83_LDD LBRACK MODE_HL RBRACK COMMA MODE_A {
sect_ConstByte(0x02 | (3 << 4)); sect_ConstByte(0x02 | (3 << 4));
} }
| Z80_LDD MODE_A COMMA LBRACK MODE_HL RBRACK { | SM83_LDD MODE_A COMMA LBRACK MODE_HL RBRACK {
sect_ConstByte(0x0A | (3 << 4)); sect_ConstByte(0x0A | (3 << 4));
} }
; ;
z80_ldh: sm83_ldh:
Z80_LDH MODE_A COMMA op_mem_ind { SM83_LDH MODE_A COMMA op_mem_ind {
if ($4.makeCheckHRAM()) { if ($4.makeCheckHRAM()) {
warning( warning(
WARNING_OBSOLETE, WARNING_OBSOLETE,
@@ -1959,7 +1959,7 @@ z80_ldh:
sect_ConstByte(0xF0); sect_ConstByte(0xF0);
sect_RelByte($4, 1); sect_RelByte($4, 1);
} }
| Z80_LDH op_mem_ind COMMA MODE_A { | SM83_LDH op_mem_ind COMMA MODE_A {
if ($2.makeCheckHRAM()) { if ($2.makeCheckHRAM()) {
warning( warning(
WARNING_OBSOLETE, WARNING_OBSOLETE,
@@ -1970,16 +1970,16 @@ z80_ldh:
sect_ConstByte(0xE0); sect_ConstByte(0xE0);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_LDH MODE_A COMMA c_ind { | SM83_LDH MODE_A COMMA c_ind {
sect_ConstByte(0xF2); sect_ConstByte(0xF2);
} }
| Z80_LDH MODE_A COMMA ff00_c_ind { | SM83_LDH MODE_A COMMA ff00_c_ind {
sect_ConstByte(0xF2); sect_ConstByte(0xF2);
} }
| Z80_LDH c_ind COMMA MODE_A { | SM83_LDH c_ind COMMA MODE_A {
sect_ConstByte(0xE2); sect_ConstByte(0xE2);
} }
| Z80_LDH ff00_c_ind COMMA MODE_A { | SM83_LDH ff00_c_ind COMMA MODE_A {
sect_ConstByte(0xE2); sect_ConstByte(0xE2);
} }
; ;
@@ -1994,71 +1994,71 @@ ff00_c_ind:
} }
; ;
z80_ld: sm83_ld:
z80_ld_mem sm83_ld_mem
| z80_ld_c_ind | sm83_ld_c_ind
| z80_ld_rr | sm83_ld_rr
| z80_ld_ss | sm83_ld_ss
| z80_ld_hl | sm83_ld_hl
| z80_ld_sp | sm83_ld_sp
| z80_ld_r_no_a | sm83_ld_r_no_a
| z80_ld_a | sm83_ld_a
; ;
z80_ld_hl: sm83_ld_hl:
Z80_LD MODE_HL COMMA MODE_SP reloc_8bit_offset { SM83_LD MODE_HL COMMA MODE_SP reloc_8bit_offset {
sect_ConstByte(0xF8); sect_ConstByte(0xF8);
sect_RelByte($5, 1); sect_RelByte($5, 1);
} }
| Z80_LD MODE_HL COMMA reloc_16bit { | SM83_LD MODE_HL COMMA reloc_16bit {
sect_ConstByte(0x01 | (REG_HL << 4)); sect_ConstByte(0x01 | (REG_HL << 4));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
; ;
z80_ld_sp: sm83_ld_sp:
Z80_LD MODE_SP COMMA MODE_HL { SM83_LD MODE_SP COMMA MODE_HL {
sect_ConstByte(0xF9); sect_ConstByte(0xF9);
} }
| Z80_LD MODE_SP COMMA reloc_16bit { | SM83_LD MODE_SP COMMA reloc_16bit {
sect_ConstByte(0x01 | (REG_SP << 4)); sect_ConstByte(0x01 | (REG_SP << 4));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
; ;
z80_ld_mem: sm83_ld_mem:
Z80_LD op_mem_ind COMMA MODE_SP { SM83_LD op_mem_ind COMMA MODE_SP {
sect_ConstByte(0x08); sect_ConstByte(0x08);
sect_RelWord($2, 1); sect_RelWord($2, 1);
} }
| Z80_LD op_mem_ind COMMA MODE_A { | SM83_LD op_mem_ind COMMA MODE_A {
sect_ConstByte(0xEA); sect_ConstByte(0xEA);
sect_RelWord($2, 1); sect_RelWord($2, 1);
} }
; ;
z80_ld_c_ind: sm83_ld_c_ind:
Z80_LD ff00_c_ind COMMA MODE_A { SM83_LD ff00_c_ind COMMA MODE_A {
sect_ConstByte(0xE2); sect_ConstByte(0xE2);
} }
| Z80_LD c_ind COMMA MODE_A { | SM83_LD c_ind COMMA MODE_A {
warning(WARNING_OBSOLETE, "LD [C], A is deprecated; use LDH [C], A\n"); warning(WARNING_OBSOLETE, "LD [C], A is deprecated; use LDH [C], A\n");
sect_ConstByte(0xE2); sect_ConstByte(0xE2);
} }
; ;
z80_ld_rr: sm83_ld_rr:
Z80_LD reg_rr COMMA MODE_A { SM83_LD reg_rr COMMA MODE_A {
sect_ConstByte(0x02 | ($2 << 4)); sect_ConstByte(0x02 | ($2 << 4));
} }
; ;
z80_ld_r_no_a: sm83_ld_r_no_a:
Z80_LD reg_r_no_a COMMA reloc_8bit { SM83_LD reg_r_no_a COMMA reloc_8bit {
sect_ConstByte(0x06 | ($2 << 3)); sect_ConstByte(0x06 | ($2 << 3));
sect_RelByte($4, 1); sect_RelByte($4, 1);
} }
| Z80_LD reg_r_no_a COMMA reg_r { | SM83_LD reg_r_no_a COMMA reg_r {
if ($2 == REG_HL_IND && $4 == REG_HL_IND) if ($2 == REG_HL_IND && $4 == REG_HL_IND)
::error("LD [HL], [HL] is not a valid instruction\n"); ::error("LD [HL], [HL] is not a valid instruction\n");
else else
@@ -2066,147 +2066,147 @@ z80_ld_r_no_a:
} }
; ;
z80_ld_a: sm83_ld_a:
Z80_LD reg_a COMMA reloc_8bit { SM83_LD reg_a COMMA reloc_8bit {
sect_ConstByte(0x06 | ($2 << 3)); sect_ConstByte(0x06 | ($2 << 3));
sect_RelByte($4, 1); sect_RelByte($4, 1);
} }
| Z80_LD reg_a COMMA reg_r { | SM83_LD reg_a COMMA reg_r {
sect_ConstByte(0x40 | ($2 << 3) | $4); sect_ConstByte(0x40 | ($2 << 3) | $4);
} }
| Z80_LD reg_a COMMA ff00_c_ind { | SM83_LD reg_a COMMA ff00_c_ind {
sect_ConstByte(0xF2); sect_ConstByte(0xF2);
} }
| Z80_LD reg_a COMMA c_ind { | SM83_LD reg_a COMMA c_ind {
warning(WARNING_OBSOLETE, "LD A, [C] is deprecated; use LDH A, [C]\n"); warning(WARNING_OBSOLETE, "LD A, [C] is deprecated; use LDH A, [C]\n");
sect_ConstByte(0xF2); sect_ConstByte(0xF2);
} }
| Z80_LD reg_a COMMA reg_rr { | SM83_LD reg_a COMMA reg_rr {
sect_ConstByte(0x0A | ($4 << 4)); sect_ConstByte(0x0A | ($4 << 4));
} }
| Z80_LD reg_a COMMA op_mem_ind { | SM83_LD reg_a COMMA op_mem_ind {
sect_ConstByte(0xFA); sect_ConstByte(0xFA);
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
; ;
z80_ld_ss: sm83_ld_ss:
Z80_LD MODE_BC COMMA reloc_16bit { SM83_LD MODE_BC COMMA reloc_16bit {
sect_ConstByte(0x01 | (REG_BC << 4)); sect_ConstByte(0x01 | (REG_BC << 4));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
| Z80_LD MODE_DE COMMA reloc_16bit { | SM83_LD MODE_DE COMMA reloc_16bit {
sect_ConstByte(0x01 | (REG_DE << 4)); sect_ConstByte(0x01 | (REG_DE << 4));
sect_RelWord($4, 1); sect_RelWord($4, 1);
} }
// HL is taken care of in z80_ld_hl // HL is taken care of in sm83_ld_hl
// SP is taken care of in z80_ld_sp // SP is taken care of in sm83_ld_sp
; ;
z80_nop: sm83_nop:
Z80_NOP { SM83_NOP {
sect_ConstByte(0x00); sect_ConstByte(0x00);
} }
; ;
z80_or: sm83_or:
Z80_OR op_a_n { SM83_OR op_a_n {
sect_ConstByte(0xF6); sect_ConstByte(0xF6);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_OR op_a_r { | SM83_OR op_a_r {
sect_ConstByte(0xB0 | $2); sect_ConstByte(0xB0 | $2);
} }
; ;
z80_pop: sm83_pop:
Z80_POP reg_tt { SM83_POP reg_tt {
sect_ConstByte(0xC1 | ($2 << 4)); sect_ConstByte(0xC1 | ($2 << 4));
} }
; ;
z80_push: sm83_push:
Z80_PUSH reg_tt { SM83_PUSH reg_tt {
sect_ConstByte(0xC5 | ($2 << 4)); sect_ConstByte(0xC5 | ($2 << 4));
} }
; ;
z80_res: sm83_res:
Z80_RES bit_const COMMA reg_r { SM83_RES bit_const COMMA reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x80 | ($2 << 3) | $4); sect_ConstByte(0x80 | ($2 << 3) | $4);
} }
; ;
z80_ret: sm83_ret:
Z80_RET { SM83_RET {
sect_ConstByte(0xC9); sect_ConstByte(0xC9);
} }
| Z80_RET ccode_expr { | SM83_RET ccode_expr {
sect_ConstByte(0xC0 | ($2 << 3)); sect_ConstByte(0xC0 | ($2 << 3));
} }
; ;
z80_reti: sm83_reti:
Z80_RETI { SM83_RETI {
sect_ConstByte(0xD9); sect_ConstByte(0xD9);
} }
; ;
z80_rl: sm83_rl:
Z80_RL reg_r { SM83_RL reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x10 | $2); sect_ConstByte(0x10 | $2);
} }
; ;
z80_rla: sm83_rla:
Z80_RLA { SM83_RLA {
sect_ConstByte(0x17); sect_ConstByte(0x17);
} }
; ;
z80_rlc: sm83_rlc:
Z80_RLC reg_r { SM83_RLC reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x00 | $2); sect_ConstByte(0x00 | $2);
} }
; ;
z80_rlca: sm83_rlca:
Z80_RLCA { SM83_RLCA {
sect_ConstByte(0x07); sect_ConstByte(0x07);
} }
; ;
z80_rr: sm83_rr:
Z80_RR reg_r { SM83_RR reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x18 | $2); sect_ConstByte(0x18 | $2);
} }
; ;
z80_rra: sm83_rra:
Z80_RRA { SM83_RRA {
sect_ConstByte(0x1F); sect_ConstByte(0x1F);
} }
; ;
z80_rrc: sm83_rrc:
Z80_RRC reg_r { SM83_RRC reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x08 | $2); sect_ConstByte(0x08 | $2);
} }
; ;
z80_rrca: sm83_rrca:
Z80_RRCA { SM83_RRCA {
sect_ConstByte(0x0F); sect_ConstByte(0x0F);
} }
; ;
z80_rst: sm83_rst:
Z80_RST reloc_8bit { SM83_RST reloc_8bit {
$2.makeCheckRST(); $2.makeCheckRST();
if (!$2.isKnown()) if (!$2.isKnown())
sect_RelByte($2, 0); sect_RelByte($2, 0);
@@ -2215,84 +2215,84 @@ z80_rst:
} }
; ;
z80_sbc: sm83_sbc:
Z80_SBC op_a_n { SM83_SBC op_a_n {
sect_ConstByte(0xDE); sect_ConstByte(0xDE);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_SBC op_a_r { | SM83_SBC op_a_r {
sect_ConstByte(0x98 | $2); sect_ConstByte(0x98 | $2);
} }
; ;
z80_scf: sm83_scf:
Z80_SCF { SM83_SCF {
sect_ConstByte(0x37); sect_ConstByte(0x37);
} }
; ;
z80_set: sm83_set:
Z80_SET bit_const COMMA reg_r { SM83_SET bit_const COMMA reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0xC0 | ($2 << 3) | $4); sect_ConstByte(0xC0 | ($2 << 3) | $4);
} }
; ;
z80_sla: sm83_sla:
Z80_SLA reg_r { SM83_SLA reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x20 | $2); sect_ConstByte(0x20 | $2);
} }
; ;
z80_sra: sm83_sra:
Z80_SRA reg_r { SM83_SRA reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x28 | $2); sect_ConstByte(0x28 | $2);
} }
; ;
z80_srl: sm83_srl:
Z80_SRL reg_r { SM83_SRL reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x38 | $2); sect_ConstByte(0x38 | $2);
} }
; ;
z80_stop: sm83_stop:
Z80_STOP { SM83_STOP {
sect_ConstByte(0x10); sect_ConstByte(0x10);
sect_ConstByte(0x00); sect_ConstByte(0x00);
} }
| Z80_STOP reloc_8bit { | SM83_STOP reloc_8bit {
sect_ConstByte(0x10); sect_ConstByte(0x10);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
; ;
z80_sub: sm83_sub:
Z80_SUB op_a_n { SM83_SUB op_a_n {
sect_ConstByte(0xD6); sect_ConstByte(0xD6);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_SUB op_a_r { | SM83_SUB op_a_r {
sect_ConstByte(0x90 | $2); sect_ConstByte(0x90 | $2);
} }
; ;
z80_swap: sm83_swap:
Z80_SWAP reg_r { SM83_SWAP reg_r {
sect_ConstByte(0xCB); sect_ConstByte(0xCB);
sect_ConstByte(0x30 | $2); sect_ConstByte(0x30 | $2);
} }
; ;
z80_xor: sm83_xor:
Z80_XOR op_a_n { SM83_XOR op_a_n {
sect_ConstByte(0xEE); sect_ConstByte(0xEE);
sect_RelByte($2, 1); sect_RelByte($2, 1);
} }
| Z80_XOR op_a_r { | SM83_XOR op_a_r {
sect_ConstByte(0xA8 | $2); sect_ConstByte(0xA8 | $2);
} }
; ;