Skip to content

Commit

Permalink
6502 improvements
Browse files Browse the repository at this point in the history
6502 JMP (indirect) is always 16-bit
  • Loading branch information
Arakula committed Jun 6, 2022
1 parent 5f859b8 commit 52a1a6b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
29 changes: 15 additions & 14 deletions Dasm6500.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ forceExtendedAddr = true;
forceDirectAddr = true;
closeCC = false;
useDPLabels = false;
textDirectAddr = "p-<";
textExtendedAddr = "p->";
textZpgAddr = "p-<";
textAbsAddr = "p->";

mnemo.resize(mnemo6500_count); /* set up mnemonics table */
for (int i = 0; i < mnemo6500_count; i++)
Expand Down Expand Up @@ -321,9 +321,9 @@ else if (lname == "forceaddr")
return bIsBool ? 1 : 0;
}
else if (lname == "forcezpgaddr")
textDirectAddr = value;
textZpgAddr = value;
else if (lname == "forceabsaddr")
textExtendedAddr = value;
textAbsAddr = value;
else
return 0; /* only name consumed */

Expand All @@ -348,9 +348,9 @@ else if (lname == "dplabel")
else if (lname == "forceaddr")
return (forceExtendedAddr || forceDirectAddr) ? "on" : "off";
else if (lname == "forcezpgaddr")
return textDirectAddr;
return textZpgAddr;
else if (lname == "forceabsaddr")
return textExtendedAddr;
return textAbsAddr;

return "";
}
Expand Down Expand Up @@ -484,12 +484,12 @@ return s; /* pass back generated string */
}

/*****************************************************************************/
/* AddForced : add forced direct or extended addressing specifier */
/* AddForced : add forced zero-page or absolute addressing specifier */
/*****************************************************************************/

void Dasm650X::AddForced(string &smnemo, string &sparm, bool bExtended)
void Dasm650X::AddForced(string &smnemo, string &sparm, bool bAbsolute)
{
string sf = bExtended ? textExtendedAddr : textDirectAddr;
string sf = bAbsolute ? textAbsAddr : textZpgAddr;
bool bMnemo = false;
bool bAppend = false;
int txtat = 0;
Expand Down Expand Up @@ -652,7 +652,6 @@ switch (mode) /* which mode is this ? */
case _zpg: /* zero-page */
case _zpx: /* zero-page,X */
case _zpy: /* zero-page,Y */
case _ind: /* indirect */
case _idx: /* (indirect,X) */
case _idy: /* (indirect),Y */
bSetLabel = !IsConst(PC);
Expand All @@ -677,6 +676,7 @@ switch (mode) /* which mode is this ? */
PC++;
break;

case _ind: /* indirect */
case _abs: /* absolute */
case _abs|_nof: /* absolute, no forced addressing */
case _abx: /* absolute,X */
Expand Down Expand Up @@ -922,7 +922,6 @@ switch (mode) /* which mode is this? */
case _zpg: /* zero page */
case _zpx: /* zero page,X */
case _zpy: /* zero page,Y */
case _ind: /* indirect */
case _idx: /* (indirect,X) */
case _idy: /* (indirect),Y */
{
Expand All @@ -949,8 +948,6 @@ switch (mode) /* which mode is this? */
sparm += MnemoCase(",X");
else if (mode == _zpy)
sparm += MnemoCase(",Y");
else if (mode == _ind)
sparm = "(" + sparm + ")";
else if (mode == _idx)
sparm = "(" + sparm + MnemoCase(",X)");
else if (mode == _idy)
Expand All @@ -959,6 +956,7 @@ switch (mode) /* which mode is this? */
}
break;

case _ind: /* indirect */
case _abs: /* absolute */
case _abs|_nof: /* absolute, no forced addressing */
case _abx: /* absolute,X */
Expand All @@ -977,13 +975,16 @@ switch (mode) /* which mode is this? */
dp = 0;
if (forceExtendedAddr &&
(W & (uint16_t)0xff00) == (uint16_t)dp &&
!(mode & _nof))
!(mode & _nof) &&
(mode != _ind)) // ind is always 16bit!
AddForced(smnemo, slbl, true);
sparm = slbl;
if (mode == _abx)
sparm += MnemoCase(",X");
else if (mode == _aby)
sparm += MnemoCase(",Y");
else if (mode == _ind)
sparm = "(" + sparm + ")";
PC += 2;
}
break;
Expand Down
4 changes: 2 additions & 2 deletions Dasm6500.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Dasm650X :
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 &MI, const char *&I, string *smnemo = NULL);
void AddForced(string &smnemo, string &sparm, bool bExtended = true);
void AddForced(string &smnemo, string &sparm, bool bAbsolute = true);

protected:
// 6500 addressing modes
Expand Down Expand Up @@ -201,7 +201,7 @@ class Dasm650X :
bool forceExtendedAddr;
bool forceDirectAddr;
bool useDPLabels;
string textExtendedAddr, textDirectAddr;
string textAbsAddr, textZpgAddr;
};


Expand Down
2 changes: 1 addition & 1 deletion dasmfw.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ using namespace std;
/* Global definitions */
/*****************************************************************************/

#define DASMFW_VERSION "0.29"
#define DASMFW_VERSION "0.30"

// set these to int64_t once 64bit processors become part of the framework
typedef uint32_t cadr_t; /* container for maximal code address*/
Expand Down
1 change: 1 addition & 0 deletions history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ v0.28 2022-05-18 crude fix for https://github.com/Arakula/dasmfw/issues/8
addressing
v0.29 2022-05-20 "option offset,begin,end,bus,interleave" info file statements preceding
a "file" statement should work now
v0.30 2022-06-06 Updates to 6502 disassembler

0 comments on commit 52a1a6b

Please sign in to comment.