From e79064709c316fbf59bf806cb8554a73936d1dc1 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 29 Oct 2019 10:18:48 -0700 Subject: [PATCH] Clarify BRK explanation --- Asm65/OpDef.cs | 8 ++++++-- Asm65/OpDescription.cs | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Asm65/OpDef.cs b/Asm65/OpDef.cs index eb1ba92..48d7c38 100644 --- a/Asm65/OpDef.cs +++ b/Asm65/OpDef.cs @@ -939,8 +939,12 @@ namespace Asm65 { Mnemonic = OpName.BRK, Effect = FlowEffect.NoCont, BaseMemEffect = MemoryEffect.None, - // On 6502/65C02 this also affects the 'B' flag, which overlaps with X. Nobody - // really cares though. On 6502 this doesn't clear the 'D' flag. + // On 6502 this doesn't clear the 'D' flag. Easier to explain that in text than + // create a separate definition. + // + // The processor status flags have the 'B' flag set on 6502/65C02/65816 emu mode + // when pushed onto the stack, but it doesn't affect the actual processor status + // flag in the code executed next. // // We don't set a StatusFlagUpdater because the flags are only changed for the // software break handler function. If we could actually track this into that, diff --git a/Asm65/OpDescription.cs b/Asm65/OpDescription.cs index 349157b..b88576f 100644 --- a/Asm65/OpDescription.cs +++ b/Asm65/OpDescription.cs @@ -286,7 +286,12 @@ namespace Asm65 { { OpName.BRK, "Pushes state onto the stack, and jumps to the software break vector at " + "$fffe-ffff. While this is technically a single-byte instruction, the " + - "program counter pushed onto the stack is incremented by two." + "program counter pushed onto the stack is incremented by two. The interrupt " + + "flag is set, and on 65C02/65816 the D flag is cleared. " + + "On 6502, 65C02, and 65816 in emulation mode, the status flags pushed onto " + + "the stack will have the 'B' flag (which overlaps the 'X' flag) set so the " + + "interrupt handler can tell the difference between hardware and software " + + "interrupts." }, { OpName.BRL, "Branches to a long relative address."