Skip to content

Commit

Permalink
Added 68000 Disassembler
Browse files Browse the repository at this point in the history
Some small changes to the other disassemblers, too
  • Loading branch information
Arakula committed Jul 28, 2017
1 parent b743c22 commit 1d72233
Show file tree
Hide file tree
Showing 16 changed files with 3,022 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
*.exe
*.out
*.app

# Specfics for dasmfw
Debugger*.txt
*.bat
*.zip
5 changes: 3 additions & 2 deletions Dasm6301.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ switch (M) /* which mode is this? */
if (Wrel)
{
W = (int)((unsigned char)T) + (uint16_t)Wrel;
sparm += Label2String((addr_t)((int)((unsigned char)T)), bGetLabel, PC) + ",X";
sparm += Label2String((addr_t)((int)((unsigned char)T)), 4,
bGetLabel, PC) + ",X";
}
else if (lbl)
sparm += lbl->GetText() + ",X";
Expand All @@ -274,7 +275,7 @@ switch (M) /* which mode is this? */
W = GetUByte(PC);
if (bGetLabel)
W = (uint16_t)PhaseInner(W, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
sparm = sformat("#%s,%s",
snum.c_str(),
slbl.c_str());
Expand Down
8 changes: 4 additions & 4 deletions Dasm6309.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ if (T & 0x80)
bGetLabel = !IsConst(PC);
lbl = bGetLabel ? NULL : FindLabel(PC, Const);
W = GetUWord(PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
buf = sformat("%s,W", slbl.c_str());
PC += 2;
}
Expand All @@ -531,7 +531,7 @@ if (T & 0x80)
bGetLabel = !IsConst(PC);
lbl = bGetLabel ? NULL : FindLabel(PC, Const);
W = GetUWord(PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
buf = sformat("[%s,W]", slbl.c_str());
PC += 2;
}
Expand Down Expand Up @@ -763,7 +763,7 @@ switch (M) /* which mode is this? */
W = (uint16_t)dp | T;
if (bGetLabel)
W = (uint16_t)PhaseInner(W, PC - 1);
string slbl = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
sparm = sformat("#%s,%s",
snum.c_str(),
slbl.c_str());
Expand Down Expand Up @@ -801,7 +801,7 @@ switch (M) /* which mode is this? */
W = GetUWord(PC);
if (bGetLabel)
W = (uint16_t)PhaseInner(W, addr);
string slbl = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
string slbl = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
if ((dp != NO_ADDRESS) &&
((W & (uint16_t)0xff00) == (uint16_t)dp) &&
(forceExtendedAddr))
Expand Down
32 changes: 23 additions & 9 deletions Dasm6800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ if (disp == MemAttribute::DefaultDisplay)
if ((nDigits == 2) && /* if 2-digit value */
(disp == MemAttribute::Char)) /* and character output requested */
{
value &= 0xff;
if (isprint(value))
s = sformat("'%c%s", value, closeCC ? "'" : "");
else
Expand All @@ -573,7 +574,13 @@ else if (disp == MemAttribute::Binary) /* if a binary */
s.push_back('0' + (!!(value & (1 << nBit))));
}
else if (disp == MemAttribute::Hex) /* if hex */
{
addr_t mask = 0;
for (int i = 0; i < nDigits; i++)
mask |= (0x0f << (i * 4));
value &= mask;
s = sformat("$%0*X", nDigits, value); /* prepare a hex value */
}
else if (disp == MemAttribute::Octal) /* if octal display */
s = sformat("@%0*o", (nDigits * 4) + 2 / 3, value);
else /* otherwise */
Expand All @@ -587,7 +594,13 @@ else /* otherwise */
s = sformat("%d", sval); /* prepare signed decimal value */
}
else
{
addr_t mask = 0;
for (int i = 0; i < nDigits; i++)
mask |= (0x0f << (i * 4));
value &= mask;
s = sformat("%u", value); /* prepare unsigned decimal value */
}
}
return s; /* pass back generated string */
}
Expand Down Expand Up @@ -811,7 +824,7 @@ if (lbltxt.find_first_of("+-") == string::npos)
if (lbltxt.size() && !GetRelative(laddr, bus))
slabel = lbltxt;
else
slabel = Label2String(laddr, true, laddr, bus);
slabel = Label2String(laddr, 4, true, laddr, bus);
smnemo = "EQU";
sparm = Address2String(laddr, bus);
return true;
Expand Down Expand Up @@ -883,7 +896,7 @@ else if (flags & 0xff) /* if not byte-sized */
/* assemble as many as possible */
for (done = addr; done < end; done += 2)
{
string s = Label2String(GetUWord(done), !IsConst(done), done);
string s = Label2String(GetUWord(done), 4, !IsConst(done), done);
if (sparm.size()) /* if already something there */
{ /* if this would become too long */
if (sparm.size() + s.size() + 1 > (string::size_type)maxparmlen)
Expand Down Expand Up @@ -979,7 +992,7 @@ switch (M) /* which mode is this? */
W = GetUWord(PC);
if (bGetLabel)
W = (uint16_t)PhaseInner(W, PC);
sparm = "#" + (lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC));
sparm = "#" + (lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC));
PC += 2;
break;

Expand All @@ -990,7 +1003,7 @@ switch (M) /* which mode is this? */
W = (uint16_t)T;
if (bGetLabel)
W = (uint16_t)PhaseInner(W, PC);
sparm = Label2String(W, bGetLabel, PC);
sparm = Label2String(W, 4, bGetLabel, PC);
PC++;
break;

Expand All @@ -1001,9 +1014,9 @@ switch (M) /* which mode is this? */
if (bGetLabel)
W = (uint16_t)PhaseInner(W, PC);
if (forceExtendedAddr && (W & (uint16_t)0xff00) == 0)
sparm = ">" + (lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC));
sparm = ">" + (lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC));
else
sparm = lbl ? lbl->GetText() : Label2String(W, bGetLabel, PC);
sparm = lbl ? lbl->GetText() : Label2String(W, 4, bGetLabel, PC);
PC += 2;
break;

Expand All @@ -1015,7 +1028,8 @@ switch (M) /* which mode is this? */
if (Wrel)
{
W = (int)((unsigned char)T) + (uint16_t)Wrel;
sparm = Label2String((addr_t)((int)((unsigned char)T)), bGetLabel, PC) + ",X";
sparm = Label2String((addr_t)((int)((unsigned char)T)), 4,
bGetLabel, PC) + ",X";
}
else if (lbl)
sparm = lbl->GetText() + ",X";
Expand All @@ -1034,7 +1048,7 @@ switch (M) /* which mode is this? */
{
W = (uint16_t)(PC + (int8_t)T);
W = (uint16_t)DephaseOuter(W, PC - 1);
sparm = Label2String(W, bGetLabel, PC - 1);
sparm = Label2String(W, 4, bGetLabel, PC - 1);
}
else
{
Expand Down Expand Up @@ -1076,7 +1090,7 @@ if (addr == NO_ADDRESS && prevaddr == NO_ADDRESS)
chg.oper = "END";
if (load != NO_ADDRESS && /* if entry point address given */
bLoadLabel) /* and labelling wanted */
chg.opnds = Label2String(load, true, load);
chg.opnds = Label2String(load, 4, true, load);
changes.push_back(chg);
}
}
Expand Down
Loading

0 comments on commit 1d72233

Please sign in to comment.