Skip to content

Commit

Permalink
Deprecate LDIO (gbdev#1567)
Browse files Browse the repository at this point in the history
* Deprecate `LDIO`

* `ld [$ff00+n8], a` is not treated as `ldh [n8], a`
  • Loading branch information
Rangi42 authored Dec 5, 2024
1 parent ceb43c7 commit 573e044
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
14 changes: 0 additions & 14 deletions man/gbz80.7
Original file line number Diff line number Diff line change
Expand Up @@ -1008,11 +1008,6 @@ Cycles: 3
Bytes: 2
.Pp
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
.Sy A
Expand All @@ -1026,8 +1021,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
Expand Down Expand Up @@ -1066,11 +1059,6 @@ Cycles: 3
Bytes: 2
.Pp
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
.Ad $FF00+c
Expand All @@ -1084,8 +1072,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
Expand Down
8 changes: 7 additions & 1 deletion src/asm/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ static std::unordered_map<std::string, int, CaseInsensitive, CaseInsensitive> ke
{"OPT", T_(POP_OPT) },
};

static auto ldio = keywordDict.find("LDIO");

static bool isWhitespace(int c) {
return c == ' ' || c == '\t';
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/asm/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1752,8 +1752,8 @@ cpu_command:
| z80_jr
| z80_ld
| z80_ldd
| z80_ldh
| z80_ldi
| z80_ldio
| z80_nop
| z80_or
| z80_pop
Expand Down Expand Up @@ -1947,7 +1947,7 @@ z80_ldd:
}
;

z80_ldio:
z80_ldh:
Z80_LDH MODE_A COMMA op_mem_ind {
$4.makeCheckHRAM();

Expand Down
31 changes: 31 additions & 0 deletions test/asm/deprecated-ldio.asm
Original file line number Diff line number Diff line change
@@ -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]
16 changes: 16 additions & 0 deletions test/asm/deprecated-ldio.err
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/asm/deprecated-ldio.out.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
����������������������������

0 comments on commit 573e044

Please sign in to comment.