Jump to content
  • 0

Break flag set after calling CHAROUT



Hello everyone,

i've noticed that when i call CHAROUT (the kernal call to output a character), the break flag on the processor status is set.

After turning on the debug option on the X16 emulator, i found out that after a few instructions, the kernal pushes the status onto the stack and till that moment, the break flag is clear. But the "copy" of the status pushed in the stack has the break flag set, so that when the status is pulled back, it has the flag set.

Now i think this is a bug of the emulator, but i wanted to ask if anybody has experienced this before.

Hope i've been clear and i'm sorry, but i've not spoken english in a while😅

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0


Okay, this is a quirk of the 6502 CPU.  There actually is no B bit stored in the 6502 status register (it will always read as a 1, as you noticed).  The only time the B bit matters is when the CPU flags are pushed on the stack by an IRQ or BRK opcode, then the CPU will make sure to clear or set the B bit value in memory on the stack (for IRQ or BRK).  This is why you need to actually read the flags from the stack after an IRQ/BRK to see which it is (since the B bit in flags register will always be a 1).

A bit more info: https://www.nesdev.org/the 'B' flag & BRK instruction.txt and http://forum.6502.org/viewtopic.php?t=24


  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

Please review our Terms of Use