Output MX states

This commit is contained in:
Lauri Kasanen 2022-10-12 15:16:24 +03:00
parent 4b04f81d37
commit 65907b1f10
3 changed files with 46 additions and 0 deletions

View File

@ -64,6 +64,8 @@
#include "segment.h"
static unsigned PrevAddrMode;
/*****************************************************************************/
/* Code */
@ -442,6 +444,22 @@ static void OneOpcode (unsigned RemainingBytes)
** following insn, fall through to byte mode.
*/
if (D->Size <= RemainingBytes) {
if (CPU == CPU_65816) {
const unsigned AddrMode = GetAttr (PC) & at65816Mask;
if (PrevAddrMode != AddrMode) {
if ((PrevAddrMode & atMem8) != (AddrMode & atMem8) ||
(PrevAddrMode & atMem16) != (AddrMode & atMem16)) {
OutputMFlag(!!(AddrMode & atMem8));
}
if ((PrevAddrMode & atIdx8) != (AddrMode & atIdx8) ||
(PrevAddrMode & atIdx16) != (AddrMode & atIdx16)) {
OutputXFlag(!!(AddrMode & atIdx8));
}
PrevAddrMode = AddrMode;
}
}
/* Output labels within the next insn */
for (I = 1; I < D->Size; ++I) {
ForwardLabel (I);
@ -517,6 +535,8 @@ static void OnePass (void)
{
unsigned Count;
PrevAddrMode = 0;
/* Disassemble until nothing left */
while ((Count = GetRemainingBytes()) > 0) {
OneOpcode (Count);

View File

@ -401,3 +401,23 @@ void OutputSettings (void)
LineFeed ();
LineFeed ();
}
void OutputMFlag (unsigned char enabled)
/* Output the 65816 M-flag state */
{
Indent (MCol);
Output (enabled ? ".a8" : ".a16");
LineFeed ();
}
void OutputXFlag (unsigned char enabled)
/* Output the 65816 X-flag state */
{
Indent (MCol);
Output (enabled ? ".i8" : ".i16");
LineFeed ();
}

View File

@ -108,6 +108,12 @@ void LineComment (unsigned PC, unsigned Count);
void OutputSettings (void);
/* Output CPU and other settings */
void OutputMFlag (unsigned char enabled);
/* Output the 65816 M-flag state */
void OutputXFlag (unsigned char enabled);
/* Output the 65816 X-flag state */
/* End of output.h */