Skip to content

Commit

Permalink
[TMS9900] Add TMS99110 variant
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed Oct 21, 2024
1 parent aed90eb commit 26579be
Show file tree
Hide file tree
Showing 16 changed files with 1,083 additions and 82 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ It can generate Intel HEX or Motorola S-Record output.
i80C48 MSM80C39 MSM80C48 i8051 i8080 i8085 V30EMU Z80 Z8 Z86C Z88
TLCS90 INS8060 INS8070 CDP1802 CDP1804 CDP1804A SCN2650 F3850 IM6100
HD6120 TMS7000 TMS32010 TMS32015 i8086 i80186 V30 i8096 MC68000
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 Z8001 Z8002 NS32032 MN1610
MN1613 MN1613A J11 T11
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 TMS99110 Z8001 Z8002 NS32032
MN1610 MN1613 MN1613A J11 T11
-o <output> : output file
-l <list> : list file
-S[<bytes>] : output Motorola S-Record format
Expand Down Expand Up @@ -122,8 +122,8 @@ It can read Intel HEX or Motorola S-Record input.
i80C48 MSM80C39 MSM80C48 i8051 i8080 i8085 V30EMU Z80 Z8 Z86C Z88
TLCS90 INS8060 INS8070 CDP1802 CDP1804 CDP1804A SCN2650 F3850 IM6100
HD6120 TMS7000 TMS32010 TMS32015 i8086 i80186 V30 i8096 MC68000
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 Z8001 Z8002 NS32032 MN1610
MN1613 MN1613A J11 T11
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 TMS99110 Z8001 Z8002 NS32032
MN1610 MN1613 MN1613A J11 T11
-o <output> : output file
-l <list> : list file
<input> : file can be Motorola S-Record or Intel HEX format
Expand Down
8 changes: 4 additions & 4 deletions README_.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ usage: asm [-o <output>] [-l <list>] <input>
i80C48 MSM80C39 MSM80C48 i8051 i8080 i8085 V30EMU Z80 Z8 Z86C Z88
TLCS90 INS8060 INS8070 CDP1802 CDP1804 CDP1804A SCN2650 F3850 IM6100
HD6120 TMS7000 TMS32010 TMS32015 i8086 i80186 V30 i8096 MC68000
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 Z8001 Z8002 NS32032 MN1610
MN1613 MN1613A J11 T11
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 TMS99110 Z8001 Z8002 NS32032
MN1610 MN1613 MN1613A J11 T11
-o <output> : output file
-l <list> : list file
-S[<bytes>] : output Motorola S-Record format
Expand Down Expand Up @@ -128,8 +128,8 @@ usage: dis -C <CPU> [-o <output>] [-l <list>] <input>
i80C48 MSM80C39 MSM80C48 i8051 i8080 i8085 V30EMU Z80 Z8 Z86C Z88
TLCS90 INS8060 INS8070 CDP1802 CDP1804 CDP1804A SCN2650 F3850 IM6100
HD6120 TMS7000 TMS32010 TMS32015 i8086 i80186 V30 i8096 MC68000
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 Z8001 Z8002 NS32032 MN1610
MN1613 MN1613A J11 T11
MC68010 TMS9900 TMS9980 TMS9995 TMS99105 TMS99110 Z8001 Z8002 NS32032
MN1610 MN1613 MN1613A J11 T11
-o <output> : output file
-l <list> : list file
<input> : file can be Motorola S-Record or Intel HEX format
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.arch
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TGT_scn2650 = scn2650
TGT_tlcs90 = tlcs90
TGT_tms32010 = tms32010
TGT_tms7000 = tms7000
TGT_tms9900 = tms9900 tms9980 tms9995 tms99105
TGT_tms9900 = tms9900 tms9980 tms9995 tms99105 tms99110
TGT_z8000 = z8001 z8002 z8k1 z8k2
TGT_z80 = z80 i8080_z80syn i8085_z80syn v30emu_z80syn
TGT_z8 = z8 z86c z88
Expand Down Expand Up @@ -126,6 +126,7 @@ CPU_tms32010 = 32010
CPU_tms7000 = TMS7000
CPU_tms9900 = TMS9900
CPU_tms99105 = TMS99105
CPU_tms99110 = TMS99110
CPU_tms9980 = TMS9980
CPU_tms9995 = TMS9995
CPU_v30emu = V30EMU
Expand Down
10 changes: 5 additions & 5 deletions src/asm_tms9900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void AsmTms9900::encodeCruOffset(AsmInsn &insn, const Operand &op) const {
}

void AsmTms9900::encodeModeReg(AsmInsn &insn, const Operand &op, AddrMode mode) const {
if (mode == M_SRC2 && insn.dst() == M_BIT2 && op.mode == M_INCR)
if (mode == M_SRC2 && insn.dst() == M_BIT0 && op.mode == M_INCR)
insn.setErrorIf(op, OPERAND_NOT_ALLOWED);
auto opc = encodeRegNumber(op.reg);
switch (op.mode) {
Expand All @@ -83,7 +83,6 @@ void AsmTms9900::encodeModeReg(AsmInsn &insn, const Operand &op, AddrMode mode)
break;
case M_SYBL:
opc = (2 << 4);
// if (op.getError() != UNDEFINED_SYMBOL)
insn.setErrorIf(op, checkAddr(op.val.getUnsigned(), !insn.byteOp()));
insn.emitOperand16(op.val.getUnsigned());
break;
Expand Down Expand Up @@ -123,9 +122,10 @@ void AsmTms9900::encodeOperand(AsmInsn &insn, const Operand &op, AddrMode mode)
case M_DREG:
insn.embed(encodeRegNumber(op.reg) << 6);
break;
case M_DST2:
case M_DST4:
insn.embedPostfix(0x4000);
/* Fall-through */
case M_DST0:
case M_SRC:
case M_SRC2:
case M_DST:
Expand Down Expand Up @@ -164,7 +164,7 @@ void AsmTms9900::encodeOperand(AsmInsn &insn, const Operand &op, AddrMode mode)
}
insn.embed((val16 & 0xF) << 4);
break;
case M_CNT2:
case M_CNT4:
insn.embedPostfix(0x4000);
if (op.mode == M_REG) {
if (op.reg != REG_R0)
Expand All @@ -174,7 +174,7 @@ void AsmTms9900::encodeOperand(AsmInsn &insn, const Operand &op, AddrMode mode)
if (op.val.isZero())
insn.setErrorIf(op, OPERAND_NOT_ALLOWED);
/* Fall-through */
case M_BIT2:
case M_BIT0:
if (op.val.overflow(15))
insn.setErrorIf(op, OVERFLOW_RANGE);
insn.embedPostfix((val16 & 0xF) << 6);
Expand Down
1 change: 1 addition & 0 deletions src/config_tms9900.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum CpuType : uint8_t {
TMS9980,
TMS9995,
TMS99105,
TMS99110,
};

struct Config : ConfigImpl<CpuType, ADDRESS_16BIT, ADDRESS_BYTE, OPCODE_16BIT, ENDIAN_BIG, 8, 4> {
Expand Down
23 changes: 14 additions & 9 deletions src/dis_tms9900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ Error DisTms9900::checkPostWord(DisInsn &insn) const {
const auto post = insn.postfix();
const auto src = (post >> 4 & 3);
switch (insn.dst()) {
case M_DST2:
case M_DST0:
if ((post & 0xF000) != 0x0000)
insn.setErrorIf(UNKNOWN_POSTBYTE);
break;
case M_DST4:
if ((post & 0xF000) != 0x4000)
insn.setErrorIf(UNKNOWN_POSTBYTE);
break;
case M_CNT2:
case M_CNT4:
if ((post & 0xFC00) != 0x4000)
insn.setErrorIf(UNKNOWN_POSTBYTE);
break;
case M_BIT2:
case M_BIT0:
// no auto increment mode.
if ((post & 0xFC00) != 0x0000 || src == 3)
insn.setErrorIf(UNKNOWN_POSTBYTE);
Expand Down Expand Up @@ -98,29 +102,30 @@ void DisTms9900::decodeOperand(DisInsn &insn, StrBuffer &out, AddrMode mode) con
case M_DREG:
outRegName(out, opc >> 6);
break;
case M_SRC2:
case M_SRC:
case M_SRC2:
val8 = (mode == M_SRC) ? opc : post;
decodeModeReg(insn, out, val8);
break;
case M_DST2:
case M_DST:
case M_DST0:
case M_DST4:
val8 = ((mode == M_DST) ? opc : post) >> 6;
decodeModeReg(insn, out, val8);
break;
case M_CNT2:
case M_CNT4:
case M_XOP:
case M_CNT:
val8 = (((mode == M_CNT2) ? post : opc) >> 6) & 0xF;
if (mode == M_CNT2 && val8 == 0) {
val8 = (((mode == M_CNT4) ? post : opc) >> 6) & 0xF;
if (mode == M_CNT4 && val8 == 0) {
outRegName(out, REG_R0);
break;
}
if (mode == M_CNT && val8 == 0)
val8 = 16;
outDec(out, val8, 5);
break;
case M_BIT2:
case M_BIT0:
val8 = (post >> 6) & 0xF;
outDec(out, val8, 4);
break;
Expand Down
9 changes: 5 additions & 4 deletions src/entry_tms9900.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ enum AddrMode : uint8_t {
M_REL = 10, // ---- ---- nnnn nnnn
M_CRU = 11, // ---- ---- nnnn nnnn
M_RTWP = 12, // ---- ---- ---- -nnn RTWP mode
M_DST2 = 13, // 0100 DDdd dd-- ---- in 2nd word
M_CNT2 = 14, // 0100 00cc cc-- ---- in 2nd word
M_BIT2 = 15, // 0000 00bb bb-- ---- in 2nd word
M_SRC2 = 16, // ---- ---- --SS ssss in 2nd word
M_SRC2 = 13, // ---- ---- --SS ssss in 2nd word
M_DST0 = 14, // 0000 DDdd dd-- ---- in 2nd word
M_DST4 = 15, // 0100 DDdd dd-- ---- in 2nd word
M_BIT0 = 16, // 0000 00bb bb-- ---- in 2nd word
M_CNT4 = 17, // 0100 00cc cc-- ---- in 2nd word
// Only for assembler.
M_IREG = 17, // Work Register Indirect Addressing: *Rn
M_INCR = 18, // Work Register Indirect Auto Increment Addressing: *Rn+
Expand Down
70 changes: 58 additions & 12 deletions src/table_tms9900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ static constexpr uint8_t INDEX_TMS9995[] PROGMEM = {
};

static constexpr Entry TABLE_TMS99105[] PROGMEM = {
E2(0x001C, TEXT_SRAM, M_SRC2, M_CNT2),
E2(0x001D, TEXT_SLAM, M_SRC2, M_CNT2),
E2(0x0029, TEXT_SM, M_SRC2, M_DST2),
E2(0x002A, TEXT_AM, M_SRC2, M_DST2),
E2(0x001C, TEXT_SRAM, M_SRC2, M_CNT4),
E2(0x001D, TEXT_SLAM, M_SRC2, M_CNT4),
E2(0x0029, TEXT_SM, M_SRC2, M_DST4),
E2(0x002A, TEXT_AM, M_SRC2, M_DST4),
E2(0x00B0, TEXT_BLSK, M_REG, M_IMM),
E1(0x0140, TEXT_BIND, M_SRC),
E2(0x0C09, TEXT_TMB, M_SRC2, M_BIT2),
E2(0x0C0A, TEXT_TCMB, M_SRC2, M_BIT2),
E2(0x0C0B, TEXT_TSMB, M_SRC2, M_BIT2),
E2(0x0C09, TEXT_TMB, M_SRC2, M_BIT0),
E2(0x0C0A, TEXT_TCMB, M_SRC2, M_BIT0),
E2(0x0C0B, TEXT_TSMB, M_SRC2, M_BIT0),
E1(0x0100, TEXT_EVAD, M_SRC),
E1(0x0380, TEXT_RTWP, M_RTWP),
// Extra
Expand All @@ -222,6 +222,43 @@ static constexpr uint8_t INDEX_TMS99105[] PROGMEM = {
6, // TEXT_TMB
8, // TEXT_TSMB
};

static constexpr Entry TABLE_TMS99110[] PROGMEM = {
E0(0x0780, TEXT_LDS),
E0(0x07C0, TEXT_LDD),
E0(0x0C00, TEXT_CRI),
E0(0x0C02, TEXT_NEGR),
E0(0x0C04, TEXT_CRE),
E0(0x0C06, TEXT_CER),
E1(0x0C40, TEXT_AR, M_SRC),
E1(0x0C80, TEXT_CIR, M_SRC),
E1(0x0CC0, TEXT_SR, M_SRC),
E1(0x0D00, TEXT_MR, M_SRC),
E1(0x0D40, TEXT_DR, M_SRC),
E1(0x0D80, TEXT_LR, M_SRC),
E1(0x0DC0, TEXT_STR, M_SRC),
E2(0x0301, TEXT_CR, M_SRC2, M_DST0),
E2(0x0302, TEXT_MM, M_SRC2, M_DST0),
};

static constexpr uint8_t INDEX_TMS99110[] PROGMEM = {
6, // TEXT_AR
5, // TEXT_CER
7, // TEXT_CIR
13, // TEXT_CR
4, // TEXT_CRE
2, // TEXT_CRI
10, // TEXT_DR
1, // TEXT_LDD
0, // TEXT_LDS
11, // TEXT_LR
14, // TEXT_MM
9, // TEXT_MR
3, // TEXT_NEGR
8, // TEXT_SR
12, // TEXT_STR
};

// clang-format on

using EntryPage = entry::TableBase<Entry>;
Expand All @@ -241,13 +278,21 @@ static constexpr EntryPage TMS99105_PAGES[] PROGMEM = {
{ARRAY_RANGE(TABLE_TMS9995), ARRAY_RANGE(INDEX_TMS9995)},
};

static constexpr EntryPage TMS99110_PAGES[] PROGMEM = {
{ARRAY_RANGE(TABLE_TMS99105), ARRAY_RANGE(INDEX_TMS99105)},
{ARRAY_RANGE(TABLE_TMS9900), ARRAY_RANGE(INDEX_TMS9900)},
{ARRAY_RANGE(TABLE_TMS9995), ARRAY_RANGE(INDEX_TMS9995)},
{ARRAY_RANGE(TABLE_TMS99110), ARRAY_RANGE(INDEX_TMS99110)},
};

using Cpu = entry::CpuBase<CpuType, EntryPage>;

static constexpr Cpu CPU_TABLE[] PROGMEM = {
{TMS9900, TEXT_CPU_9900, ARRAY_RANGE(TMS9900_PAGES)},
{TMS9980, TEXT_CPU_9980, ARRAY_RANGE(TMS9900_PAGES)},
{TMS9995, TEXT_CPU_9995, ARRAY_RANGE(TMS9995_PAGES)},
{TMS99105, TEXT_CPU_99105, ARRAY_RANGE(TMS99105_PAGES)},
{TMS99110, TEXT_CPU_99110, ARRAY_RANGE(TMS99110_PAGES)},
};

static const Cpu *cpu(CpuType cpuType) {
Expand All @@ -269,13 +314,14 @@ static bool acceptMode(AddrMode opr, AddrMode table) {
if (opr == table)
return true;
if (opr == M_IREG || opr == M_INCR || opr == M_SYBL || opr == M_INDX)
return table == M_SRC || table == M_DST || table == M_SRC2 || table == M_DST2;
return table == M_SRC || table == M_DST || table == M_SRC2 || table == M_DST0 ||
table == M_DST4;
if (opr == M_REG)
return table == M_SRC || table == M_DST || table == M_SRC2 || table == M_DST2 ||
table == M_DREG || table == M_SCNT || table == M_CNT2;
return table == M_SRC || table == M_DST || table == M_SRC2 || table == M_DST0 ||
table == M_DST4 || table == M_DREG || table == M_SCNT || table == M_CNT4;
if (opr == M_IMM)
return table == M_REL || table == M_SCNT || table == M_CNT || table == M_CNT2 ||
table == M_CRU || table == M_BIT2 || table == M_XOP || table == M_RTWP;
return table == M_REL || table == M_SCNT || table == M_CNT || table == M_CNT4 ||
table == M_CRU || table == M_BIT0 || table == M_XOP || table == M_RTWP;
return false;
}

Expand Down
22 changes: 20 additions & 2 deletions src/text_tms9900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ namespace text {
namespace tms9900 {

// clang-format off
constexpr char TEXT_TMS9900_LIST[] PROGMEM = "TMS9900, TMS9980, TMS9995, TMS99105";
constexpr char TEXT_TMS9900_LIST[] PROGMEM = "TMS9900, TMS9980, TMS9995, TMS99105, TMS99110";
constexpr char TEXT_CPU_9900[] PROGMEM = "9900";
constexpr char TEXT_CPU_9980[] PROGMEM = "9980";
constexpr char TEXT_CPU_9995[] PROGMEM = "9995";
constexpr char TEXT_CPU_99105[] PROGMEM = "99105";
constexpr char TEXT_CPU_99110[] PROGMEM = "99110";

// TMS9900
// constexpr char TEXT_A[] PROGMEM = "A";
Expand Down Expand Up @@ -115,8 +116,25 @@ constexpr char TEXT_SRAM[] PROGMEM = "SRAM";
constexpr char TEXT_TCMB[] PROGMEM = "TCMB";
constexpr char TEXT_TMB[] PROGMEM = "TMB";
constexpr char TEXT_TSMB[] PROGMEM = "TSMB";
// clang-format on

// TMS99110
constexpr char TEXT_AR[] PROGMEM = "AR";
constexpr char TEXT_CER[] PROGMEM = "CER";
constexpr char TEXT_CIR[] PROGMEM = "CIR";
constexpr char TEXT_CR[] PROGMEM = "CR";
constexpr char TEXT_CRE[] PROGMEM = "CRE";
constexpr char TEXT_CRI[] PROGMEM = "CRI";
constexpr char TEXT_DR[] PROGMEM = "DR";
// constexpr char TEXT_LDD[] PROGMEM = "LDD";
// constexpr char TEXT_LDS[] PROGMEM = "LDS";
// constexpr char TEXT_LR[] PROGMEM = "LR";
constexpr char TEXT_MM[] PROGMEM = "MM";
constexpr char TEXT_MR[] PROGMEM = "MR";
constexpr char TEXT_NEGR[] PROGMEM = "NEGR";
// constexpr char TEXT_SR[] PROGMEM = "SR";
// constexpr char TEXT_STR[] PROGMEM = "STR";

// clang-format on
} // namespace tms9900
} // namespace text
} // namespace libasm
Expand Down
20 changes: 19 additions & 1 deletion src/text_tms9900.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern const char TEXT_CPU_9900[] PROGMEM;
extern const char TEXT_CPU_9980[] PROGMEM;
extern const char TEXT_CPU_9995[] PROGMEM;
extern const char TEXT_CPU_99105[] PROGMEM;
extern const char TEXT_CPU_99110[] PROGMEM;

// TMS9900
using common::TEXT_A;
Expand Down Expand Up @@ -118,8 +119,25 @@ extern const char TEXT_SRAM[] PROGMEM;
extern const char TEXT_TCMB[] PROGMEM;
extern const char TEXT_TMB[] PROGMEM;
extern const char TEXT_TSMB[] PROGMEM;
// clang-format on

// TMS99110
extern const char TEXT_AR[] PROGMEM;
extern const char TEXT_CER[] PROGMEM;
extern const char TEXT_CIR[] PROGMEM;
extern const char TEXT_CR[] PROGMEM;
extern const char TEXT_CRE[] PROGMEM;
extern const char TEXT_CRI[] PROGMEM;
extern const char TEXT_DR[] PROGMEM;
using common::TEXT_LDD;
using common::TEXT_LDS;
using common::TEXT_LR;
extern const char TEXT_MM[] PROGMEM;
extern const char TEXT_MR[] PROGMEM;
extern const char TEXT_NEGR[] PROGMEM;
using common::TEXT_SR;
using common::TEXT_STR;

// clang-format on
} // namespace tms9900
} // namespace text
} // namespace libasm
Expand Down
Loading

0 comments on commit 26579be

Please sign in to comment.