diff --git a/src/da65/main.c b/src/da65/main.c index 8d68dc4cc..67a01dc3b 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -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); diff --git a/src/da65/output.c b/src/da65/output.c index 5b0b6b79c..8e786e130 100644 --- a/src/da65/output.c +++ b/src/da65/output.c @@ -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 (); +} diff --git a/src/da65/output.h b/src/da65/output.h index 13ea0cc85..bc20aace0 100644 --- a/src/da65/output.h +++ b/src/da65/output.h @@ -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 */