From 4fc6e4b56c3bc64fd4c084d120016620cf59f7e8 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 3 Dec 2024 21:39:40 -0500 Subject: [PATCH 1/2] Deprecate `LDIO` --- man/gbz80.7 | 8 -------- src/asm/lexer.cpp | 8 +++++++- src/asm/parser.y | 4 ++-- test/asm/deprecated-ldio.asm | 31 +++++++++++++++++++++++++++++++ test/asm/deprecated-ldio.err | 16 ++++++++++++++++ test/asm/deprecated-ldio.out.bin | 1 + 6 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 test/asm/deprecated-ldio.asm create mode 100644 test/asm/deprecated-ldio.err create mode 100644 test/asm/deprecated-ldio.out.bin diff --git a/man/gbz80.7 b/man/gbz80.7 index 139f365a4..ebb7b9330 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -1010,8 +1010,6 @@ Bytes: 2 Flags: None affected. .Pp This is sometimes written as -.Ql LDIO [n16],A , -or .Ql LD [$FF00+n8],A . .Ss LDH [C],A Copy the value in register @@ -1026,8 +1024,6 @@ Bytes: 1 Flags: None affected. .Pp This is sometimes written as -.Ql LDIO [C],A , -or .Ql LD [$FF00+C],A . .Ss LD A,[r16] Copy the byte pointed to by @@ -1068,8 +1064,6 @@ Bytes: 2 Flags: None affected. .Pp This is sometimes written as -.Ql LDIO A,[n16] , -or .Ql LD A,[$FF00+n8] . .Ss LDH A,[C] Copy the byte at address @@ -1084,8 +1078,6 @@ Bytes: 1 Flags: None affected. .Pp This is sometimes written as -.Ql LDIO A,[C] , -or .Ql LD A,[$FF00+C] . .Ss LD [HLI],A Copy the value in register diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 9574622d9..161b4b6a5 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -329,6 +329,8 @@ static std::unordered_map ke {"OPT", T_(POP_OPT) }, }; +static auto ldio = keywordDict.find("LDIO"); + static bool isWhitespace(int c) { return c == ' ' || c == '\t'; } @@ -1168,8 +1170,12 @@ static Token readIdentifier(char firstChar, bool raw) { // Attempt to check for a keyword if the identifier is not raw if (!raw) { - if (auto search = keywordDict.find(identifier); search != keywordDict.end()) + if (auto search = keywordDict.find(identifier); search != keywordDict.end()) { + if (search == ldio) { + warning(WARNING_OBSOLETE, "LDIO is deprecated; use LDH\n"); + } return Token(search->second); + } } // Label scopes `.` and `..` are the only nonlocal identifiers that start with a dot diff --git a/src/asm/parser.y b/src/asm/parser.y index 40c50a198..f4aae733b 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -1752,8 +1752,8 @@ cpu_command: | z80_jr | z80_ld | z80_ldd + | z80_ldh | z80_ldi - | z80_ldio | z80_nop | z80_or | z80_pop @@ -1947,7 +1947,7 @@ z80_ldd: } ; -z80_ldio: +z80_ldh: Z80_LDH MODE_A COMMA op_mem_ind { $4.makeCheckHRAM(); diff --git a/test/asm/deprecated-ldio.asm b/test/asm/deprecated-ldio.asm new file mode 100644 index 000000000..4c381e4b4 --- /dev/null +++ b/test/asm/deprecated-ldio.asm @@ -0,0 +1,31 @@ +SECTION "LDIO", ROM0 + + ldh [c], a + ldh a, [c] + ldh [$11], a + ldh a, [$11] + + ld [$ff00+c], a + ld a, [$ff00+c] + ld [$ff11], a + ld a, [$ff11] + + ldio [c], a + ldio a, [c] + ldio [$ff11], a + ldio a, [$ff11] + + LDH [C], A + LDH A, [C] + LDH [$11], A + LDH A, [$11] + + LD [$FF00+C], A + LD A, [$FF00+C] + LD [$FF11], A + LD A, [$FF11] + + LDIO [C], A + LDIO A, [C] + LDIO [$FF11], A + LDIO A, [$FF11] diff --git a/test/asm/deprecated-ldio.err b/test/asm/deprecated-ldio.err new file mode 100644 index 000000000..b6c038321 --- /dev/null +++ b/test/asm/deprecated-ldio.err @@ -0,0 +1,16 @@ +warning: deprecated-ldio.asm(13): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(14): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(15): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(16): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(28): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(29): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(30): [-Wobsolete] + LDIO is deprecated; use LDH +warning: deprecated-ldio.asm(31): [-Wobsolete] + LDIO is deprecated; use LDH diff --git a/test/asm/deprecated-ldio.out.bin b/test/asm/deprecated-ldio.out.bin new file mode 100644 index 000000000..12fc9a906 --- /dev/null +++ b/test/asm/deprecated-ldio.out.bin @@ -0,0 +1 @@ +âòàðâòêÿúÿâòàðâòàðâòêÿúÿâòàð \ No newline at end of file From b0495b3d5b919cfae74ef2ebd78eafdf148f7690 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 3 Dec 2024 21:55:24 -0500 Subject: [PATCH 2/2] `ld [$ff00+n8], a` is not treated as `ldh [n8], a` --- man/gbz80.7 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/man/gbz80.7 b/man/gbz80.7 index ebb7b9330..a51f1acfd 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -1008,9 +1008,6 @@ Cycles: 3 Bytes: 2 .Pp Flags: None affected. -.Pp -This is sometimes written as -.Ql LD [$FF00+n8],A . .Ss LDH [C],A Copy the value in register .Sy A @@ -1062,9 +1059,6 @@ Cycles: 3 Bytes: 2 .Pp Flags: None affected. -.Pp -This is sometimes written as -.Ql LD A,[$FF00+n8] . .Ss LDH A,[C] Copy the byte at address .Ad $FF00+c