Skip to content

Commit

Permalink
[ASM] FPU directive accepts ON/OFF
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed Jun 24, 2024
1 parent ebdecf5 commit aea855a
Show file tree
Hide file tree
Showing 17 changed files with 18,793 additions and 18,757 deletions.
4 changes: 2 additions & 2 deletions src/asm_i8086.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void AsmI8086::reset() {
Error AsmI8086::setFpu(StrScanner &scan) {
auto p = scan;
p.iexpect('i');
if (p.iequals_P(TEXT_FPU_8087)) {
if (scan.expectTrue() || p.iequals_P(TEXT_FPU_8087)) {
setFpuType(FPU_I8087);
} else if (scan.iequals_P(TEXT_none)) {
} else if (scan.expectFalse() || scan.iequals_P(TEXT_none)) {
setFpuType(FPU_NONE);
} else {
return UNKNOWN_OPERAND;
Expand Down
4 changes: 2 additions & 2 deletions src/asm_mc68000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ void AsmMc68000::reset() {
}

Error AsmMc68000::setFpu(StrScanner &scan) {
if (scan.iequals_P(TEXT_FPU_68881) || scan.iequals_P(TEXT_FPU_MC68881)) {
if (scan.expectTrue() || scan.iequals_P(TEXT_FPU_68881) || scan.iequals_P(TEXT_FPU_MC68881)) {
setFpuType(FPU_MC68881);
} else if (scan.iequals_P(TEXT_none)) {
} else if (scan.expectFalse() || scan.iequals_P(TEXT_none)) {
setFpuType(FPU_NONE);
} else {
return UNKNOWN_OPERAND;
Expand Down
14 changes: 2 additions & 12 deletions src/option_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,17 @@ namespace libasm {

namespace {

bool expectTrue(StrScanner &scan) {
return scan.iexpectWord_P(PSTR("enable")) || scan.iexpectWord_P(PSTR("true")) ||
scan.iexpectWord_P(PSTR("yes")) || scan.iexpectWord_P(PSTR("on"));
}

bool expectFalse(StrScanner &scan) {
return scan.iexpectWord_P(PSTR("disable")) || scan.iexpectWord_P(PSTR("false")) ||
scan.iexpectWord_P(PSTR("no")) || scan.iexpectWord_P(PSTR("off"));
}

Error parseBool(StrScanner &scan, bool &value) {
auto p = scan;
const auto dquote = p.expect('"');
if (expectTrue(p)) {
if (p.expectTrue()) {
if (dquote && !p.expect('"'))
return MISSING_CLOSING_DQUOTE;
scan = p;
value = true;
return OK;
}
if (expectFalse(p)) {
if (p.expectFalse()) {
if (dquote && !p.expect('"'))
return MISSING_CLOSING_DQUOTE;
scan = p;
Expand Down
10 changes: 10 additions & 0 deletions src/str_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ bool StrScanner::iexpectWord_P(const /*PROGMEM*/ char *text_P) {
return false;
}

bool StrScanner::expectTrue() {
return iexpectWord_P(PSTR("enable")) || iexpectWord_P(PSTR("true")) ||
iexpectWord_P(PSTR("yes")) || iexpectWord_P(PSTR("on"));
}

bool StrScanner::expectFalse() {
return iexpectWord_P(PSTR("disable")) || iexpectWord_P(PSTR("false")) ||
iexpectWord_P(PSTR("no")) || iexpectWord_P(PSTR("off"));
}

} // namespace libasm

// Local Variables:
Expand Down
10 changes: 10 additions & 0 deletions src/str_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ struct StrScanner {
*/
bool iexpectWord_P(const /*PROGMEM*/ char *text_P);

/**
* return true if this starts with "true", "on", "enable", or "yes" with ignore case.
*/
bool expectTrue();

/**
* return true if this starts with "false", "off", "disable", or "no" with ignore case.
*/
bool expectFalse();

/** return true if this equals to |text| with ignore case. */
bool iequals(const StrScanner &text) const;

Expand Down
2 changes: 1 addition & 1 deletion test/autogen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ help:
# target which has ".inc" suffix for output.
INC_targets = \
w65c816 tlcs90 i8080_z80syn i8085_z80syn v30emu_z80syn i8086 i80186 v30 \
z8001 z8002 z8k1 z8k2 ns32000 ns32k mn1610 mn1613 tms7000 tms9980
mc68000 z8001 z8002 z8k1 z8k2 ns32000 ns32k mn1610 mn1613 tms7000 tms9980
# target which for GNU assembler
GAS_targets = z8k1 z8k2 ns32k

Expand Down
24 changes: 0 additions & 24 deletions test/autogen/gen_i80186.asl

This file was deleted.

2 changes: 1 addition & 1 deletion test/autogen/gen_i80186.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
; limitations under the License.

cpu 80186
fpu 8087
fpu on
org 0000h
include "gen_i8086.inc"
end
Expand Down
24 changes: 0 additions & 24 deletions test/autogen/gen_i8086.asl

This file was deleted.

2 changes: 1 addition & 1 deletion test/autogen/gen_i8086.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
; limitations under the License.

cpu 8086
fpu 8087
fpu on
org 0000h
include "gen_i8086.inc"
end
Expand Down
Loading

0 comments on commit aea855a

Please sign in to comment.