Skip to content

Commit

Permalink
REG directive added
Browse files Browse the repository at this point in the history
  • Loading branch information
Arakula committed Oct 13, 2022
1 parent 6ada59c commit ac81dc9
Show file tree
Hide file tree
Showing 21 changed files with 499 additions and 136 deletions.
87 changes: 60 additions & 27 deletions Dasm6309.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,19 @@ CMatrixEntry Dasm6309::h6309_codes11[256] =
{_ill ,_nom}, {_ill ,_nom}, {_ill ,_nom}, {_ill ,_nom}, /* FC..FF */
};

static const char *h6309_exg_tfr[] =
const int Dasm6309::bit_r[] = { _cc, _a, _b, _unkr };

const int Dasm6309::block_r[] =
{
_d, _x, _y, _u, _s, _unkr, _unkr, _unkr,
_unkr, _unkr, _unkr, _unkr, _unkr, _unkr, _unkr, _unkr
};


const int Dasm6309::h6309_exg_tfr[] =
{
"D", "X", "Y", "U", "S", "PC","W" ,"V",
"A", "B", "CC","DP","0", "0", "E", "F"
_d, _x, _y, _u, _s, _pc, _w, _v,
_a, _b, _cc, _dp, _reg0, _reg0, _e, _f
};

/*****************************************************************************/
Expand Down Expand Up @@ -359,6 +368,20 @@ OpCode Dasm6309::opcodes[mnemo6309_count - mnemo6809_count] =
{ "FQB", Data }, /* _fqb */
};

/*****************************************************************************/
/* regnames : additional register names over 6809 */
/*****************************************************************************/

const char *Dasm6309::regnames[reg6309_count - reg6809_count] =
{
"E", /* _e */
"F", /* _f */
"V", /* _v */
"W", /* _w */
"MD", /* _md */
"0", /* _reg0 */
};

/*****************************************************************************/
/* Dasm6309 : constructor */
/*****************************************************************************/
Expand All @@ -371,9 +394,13 @@ codes10 = h6309_codes10;
codes11 = h6309_codes11;
exg_tfr = h6309_exg_tfr;

int i;
mnemo.resize(mnemo6309_count); /* set up additional mnemonics */
for (int i = 0; i < mnemo6309_count - mnemo6809_count; i++)
for (i = 0; i < mnemo6309_count - mnemo6809_count; i++)
mnemo[mnemo6809_count + i] = opcodes[i];
regname.resize(reg6309_count); /* set up additional register names */
for (i = 0; i < reg6309_count - reg6809_count; i++)
regname[reg6809_count + i] = regnames[i];
}

/*****************************************************************************/
Expand Down Expand Up @@ -494,39 +521,45 @@ if (T & 0x80)
switch (T & 0x1F)
{
case 0x07:
buf = MnemoCase(sformat("E,%c", R));
buf = MnemoCase(sformat("%s,%s",
regname[_e].c_str(), regname[R].c_str()));
break;
case 0x17:
buf = MnemoCase(sformat("[E,%c]", R));
buf = MnemoCase(sformat("[%s,%s]",
regname[_e].c_str(), regname[R].c_str()));
break;
case 0x0A:
buf = MnemoCase(sformat("F,%c",R));
buf = MnemoCase(sformat("%s,%s",
regname[_f].c_str(), regname[R].c_str()));
break;
case 0x1A:
buf = MnemoCase(sformat("[F,%c]",R));
buf = MnemoCase(sformat("[s,%s]",
regname[_f].c_str(), regname[R].c_str()));
break;
case 0x0E:
buf = MnemoCase(sformat("W,%c",R));
buf = MnemoCase(sformat("%s,%s",
regname[_w].c_str(), regname[R].c_str()));
break;
case 0x1E:
buf = MnemoCase(sformat("[W,%c]",R));
buf = MnemoCase(sformat("[%s,%s]",
regname[_w].c_str(), regname[R].c_str()));
break;
default:
switch (T)
{
case 0x8F:
buf = MnemoCase(sformat(",W"));
buf = "," + MnemoCase(regname[_w]);
break;
case 0x90:
buf = MnemoCase(sformat("[,W]"));
buf = MnemoCase(sformat("[,%s]", regname[_w].c_str()));
break;
case 0xAF:
{
bGetLabel = !IsConst(PC);
lbl = bGetLabel ? NULL : FindLabel(PC, Const);
W = GetUWord(PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
buf = sformat("%s,%s", slbl.c_str(), MnemoCase("W").c_str());
buf = sformat("%s,%s", slbl.c_str(), MnemoCase(regname[_w]).c_str());
PC += 2;
}
break;
Expand All @@ -536,21 +569,21 @@ if (T & 0x80)
lbl = bGetLabel ? NULL : FindLabel(PC, Const);
W = GetUWord(PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
buf = sformat("[%s,%s]", slbl.c_str(),MnemoCase("W").c_str());
buf = sformat("[%s,%s]", slbl.c_str(),MnemoCase(regname[_w]).c_str());
PC += 2;
}
break;
case 0xCF:
buf = MnemoCase(sformat(",W++"));
buf = MnemoCase(sformat(",%s++", regname[_w].c_str()));
break;
case 0xD0:
buf = MnemoCase(sformat("[,W++]"));
buf = MnemoCase(sformat("[,%s++]", regname[_w].c_str()));
break;
case 0xEF:
buf = MnemoCase(sformat(",--W"));
buf = MnemoCase(sformat(",--%s", regname[_w].c_str()));
break;
case 0xF0:
buf = MnemoCase(sformat("[,--W]"));
buf = MnemoCase(sformat("[,--%s]", regname[_w].c_str()));
break;
default:
return Dasm6809::IndexString(smnemo, pc);
Expand Down Expand Up @@ -815,7 +848,7 @@ switch (mode) /* which mode is this? */
if (forceDirectAddr || GetForcedAddr(PC))
AddForced(smnemo, slbl, false);
sparm = sformat("%s,%d,%s,%s",
MnemoCase(bit_r[M >> 6]).c_str(),
MnemoCase(regname[bit_r[M >> 6]]).c_str(),
(M >> 3) & 7,
snum.c_str(),
slbl.c_str());
Expand All @@ -826,29 +859,29 @@ switch (mode) /* which mode is this? */
case _t1: /* Block Transfer r0+,r1+ */
T = GetUByte(PC++);
sparm = sformat("%s+,%s+",
MnemoCase(block_r[T >> 4]).c_str(),
MnemoCase(block_r[T & 0xF]).c_str());
MnemoCase(regname[block_r[T >> 4]]).c_str(),
MnemoCase(regname[block_r[T & 0xF]]).c_str());
break;

case _t2: /* Block Transfer r0-,r1- */
T = GetUByte(PC++);
sparm = sformat("%s-,%s-",
MnemoCase(block_r[T >> 4]).c_str(),
MnemoCase(block_r[T & 0xF]).c_str());
MnemoCase(regname[block_r[T >> 4]]).c_str(),
MnemoCase(regname[block_r[T & 0xF]]).c_str());
break;

case _t3: /* Block Transfer r0+,r1 */
T = GetUByte(PC++);
sparm = sformat("%s+,%s",
MnemoCase(block_r[T >> 4]).c_str(),
MnemoCase(block_r[T & 0xF]).c_str());
MnemoCase(regname[block_r[T >> 4]]).c_str(),
MnemoCase(regname[block_r[T & 0xF]]).c_str());
break;

case _t4: /* Block Transfer r0,r1+ */
T = GetUByte(PC++);
sparm = sformat("%s,%s+",
MnemoCase(block_r[T >> 4]).c_str(),
MnemoCase(block_r[T & 0xF]).c_str());
MnemoCase(regname[block_r[T >> 4]]).c_str(),
MnemoCase(regname[block_r[T & 0xF]]).c_str());
break;

case _iml: /* immediate 32-bit */
Expand Down
16 changes: 16 additions & 0 deletions Dasm6309.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,26 @@ class Dasm6309 : public Dasm6809
mnemo6309_count
};

enum Reg6309
{
_e = reg6809_count,
_f,
_v,
_w,
_md,
_reg0, /* not really a register, but hey... */

reg6309_count
};

static CMatrixEntry h6309_codes[256];
static CMatrixEntry h6309_codes10[256];
static CMatrixEntry h6309_codes11[256];
static OpCode opcodes[mnemo6309_count - mnemo6809_count];
static const char *regnames[reg6309_count - reg6809_count];
static const int h6309_exg_tfr[];
static const int bit_r[];
static const int block_r[];

protected:
virtual adr_t IndexParse(int MI, adr_t pc, adr_t instaddr = NO_ADDRESS);
Expand Down
31 changes: 24 additions & 7 deletions Dasm6500.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ OpCode Dasm650X::opcodes[mnemo6500_count] =
{ "TYA", Data }, /* _tya */
};

/*****************************************************************************/
/* regnames : 6500 register names array for initialization */
/*****************************************************************************/

const char *Dasm650X::regnames[reg6500_count] =
{
"A", /* _a */
"X", /* _x */
"Y", /* _y */
"P", /* _p */
"PC", /* _pc */
};

/*****************************************************************************/
/* Dasm650X : constructor */
/*****************************************************************************/
Expand All @@ -261,6 +274,10 @@ mnemo.resize(mnemo6500_count); /* set up mnemonics table */
for (int i = 0; i < mnemo6500_count; i++)
mnemo[i] = opcodes[i];

regname.resize(reg6500_count); /* set up register name table */
for (int i = 0; i < reg6500_count; i++)
regname[i] = regnames[i];

// set up options table
// class uses one generic option setter/getter pair (not mandatory)
#if 0
Expand Down Expand Up @@ -923,7 +940,7 @@ switch (mode) /* which mode is this? */
break;
case _acc: /* accumulator */
if (accparm)
sparm = MnemoCase("A");
sparm = MnemoCase(regname[_a]);
break;

case _imm: /* immediate byte */
Expand Down Expand Up @@ -959,13 +976,13 @@ switch (mode) /* which mode is this? */
else // if no direct page, this can't be interpreted as a label
sparm = (lbl ? lbl->GetText() : Number2String(T, 2, PC));
if (mode == _zpx)
sparm += MnemoCase(",X");
sparm += "," + MnemoCase(regname[_x]);
else if (mode == _zpy)
sparm += MnemoCase(",Y");
sparm += "," + MnemoCase(regname[_y]);
else if (mode == _idx)
sparm = "(" + sparm + MnemoCase(",X)");
sparm = "(" + sparm + "," + MnemoCase(regname[_x]) + ")";
else if (mode == _idy)
sparm = "(" + sparm + MnemoCase("),Y");
sparm = "(" + sparm + ")," + MnemoCase(regname[_y]);
PC++;
}
break;
Expand Down Expand Up @@ -994,9 +1011,9 @@ switch (mode) /* which mode is this? */
AddForced(smnemo, slbl, true);
sparm = slbl;
if (mode == _abx)
sparm += MnemoCase(",X");
sparm += "," + MnemoCase(regname[_x]);
else if (mode == _aby)
sparm += MnemoCase(",Y");
sparm += "," + MnemoCase(regname[_y]);
else if (mode == _ind)
sparm = "(" + sparm + ")";
PC += 2;
Expand Down
13 changes: 11 additions & 2 deletions Dasm6500.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,21 @@ class Dasm650X :
mnemo6500_count
};

enum Reg6500
{
_a,
_x,
_y,
_p,
_pc,
reg6500_count
};

static CMatrixEntry m6500_codes[256];

CMatrixEntry *codes;
static const char *bit_r[];
static const char *block_r[];
static OpCode opcodes[mnemo6500_count];
static const char *regnames[reg6500_count];
adr_t dirpage;

bool useConvenience;
Expand Down
29 changes: 21 additions & 8 deletions Dasm6800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ CMatrixEntry Dasm6800::m6800_codes[256] =
{_ill ,_nom}, {_ill ,_nom}, {_ldx ,_ext}, {_stx ,_ext}, /* FC..FF */
};

const char *Dasm6800::bit_r[] = {"CC","A","B","??"};

const char *Dasm6800::block_r[] =
{
"D","X","Y","U","S","?","?","?","?","?","?","?","?","?","?","?"
};

/*****************************************************************************/
/* opcodes : 6800 opcodes array for initialization */
/*****************************************************************************/
Expand Down Expand Up @@ -269,6 +262,21 @@ OpCode Dasm6800::opcodes[mnemo6800_count] =
{ "LSRD", Data }, /* _lsrd */
};

/*****************************************************************************/
/* regnames : 6800 register names array for initialization */
/*****************************************************************************/

const char *Dasm6800::regnames[reg6800_count] =
{
"?", /* _unk */
"A", /* _a */
"B", /* _b */
"X", /* _x */
"S", /* _s */
"PC", /* _pc */
"CC", /* _cc */
};

/*****************************************************************************/
/* Dasm6800 : constructor */
/*****************************************************************************/
Expand All @@ -294,10 +302,15 @@ useDPLabels = false;
textDirectAddr = "p-<";
textExtendedAddr = "p->";

int i;
mnemo.resize(mnemo6800_count); /* set up mnemonics table */
for (int i = 0; i < mnemo6800_count; i++)
for (i = 0; i < mnemo6800_count; i++)
mnemo[i] = opcodes[i];

regname.resize(reg6800_count); /* set up register name table */
for (i = 0; i < reg6800_count; i++)
regname[i] = regnames[i];

// set up options table
// class uses one generic option setter/getter pair (not mandatory)
AddOption("conv", "{off|on}\tUse convenience macros",
Expand Down
18 changes: 15 additions & 3 deletions Dasm6800.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Dasm6800 :
virtual string Address2String(adr_t addr, int bus = BusCode)
{ (void)bus; return sformat("$%04X", addr); }
virtual adr_t FetchInstructionDetails(adr_t PC, uint8_t &instpg, uint8_t &instb, uint8_t &mode, int &mnemoIndex);
virtual string GetIx8IndexReg(uint8_t instpg) { (void)instpg; return MnemoCase(",X"); }
virtual string GetIx8IndexReg(uint8_t instpg) { (void)instpg; return "," + MnemoCase(regname[_x]); }
virtual bool SetConvenience(uint8_t instpg, uint16_t u2, string &smnemo, adr_t &PC);
void AddForced(string &smnemo, string &sparm, bool bExtended = true);

Expand Down Expand Up @@ -281,12 +281,24 @@ class Dasm6800 :
mnemo6800_count
};

enum Reg6800
{
_unkr,
_a,
_b,
_x,
_s,
_pc,
_cc,

reg6800_count
};

static CMatrixEntry m6800_codes[256];

CMatrixEntry *codes;
static const char *bit_r[];
static const char *block_r[];
static OpCode opcodes[mnemo6800_count];
static const char *regnames[reg6800_count];
adr_t dirpage;

bool useConvenience;
Expand Down
Loading

0 comments on commit ac81dc9

Please sign in to comment.