Login
Forum Help



Post Your Message
Username: (Login)

Topic:
Message:
 


Previous Messages
Posted By

SVS
on 2017-09-22
14:02:49
 Re: The B flag doesn't exist! :)

Yes me too, I think it's a simple fork flag in order to use the same vector.
Maybe it was added as a last minute patch to solve the problem.

BTW any info regarding the unused(?) bit 5 of the PR?

Posted By

bubis
on 2017-09-22
05:54:48
 The B flag doesn't exist! :)

Hi!

Learned something interesting about the B "flag" recently. We all know that there are no CLB, SEB instructions to clear or set the B flag or any branch instructions to test it. The only way to inspect B is pushing the status register to the stack with PHP. Opps, but PHP always pushes B=1! BRK also pushes B=1 to the stack (naturally) and hardware interrupts push B=0, so we can distinguish between them in the interrupt handler by checking what is on the stack.

So, I suspected that there are no physical representation of the B flag in the CPU and it's state is not stored at all. It's just that for hardware interrupts B=0 is pushed on the stack, and that's all.

I turned out to be right, you can learn more about it on the excellent visual6502.org wiki:

http://visual6502.org/wiki/index.php?title=6502_BRK_and_B_bit

Btw, I am writing a small python 6502 emulator what I will use in my projects to test/profile (maybe disassembly) machine code, it's early stage, but you can find it here:
http://github.com/dotscha/sandbox/tree/master/emu6502


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon