BRK masking bug and reliability of B pseudoflag

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

tepples
Posts: 22286
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: BRK masking bug and reliability of B pseudoflag

Post by tepples » Wed Feb 17, 2021 8:03 pm

STA $8000 would never be followed by a STP, unlike BRK.

Oziphantom
Posts: 1080
Joined: Tue Feb 07, 2017 2:03 am

Re: BRK masking bug and reliability of B pseudoflag

Post by Oziphantom » Wed Feb 17, 2021 10:46 pm

Here is the VICE test that, tests the B flag and shows that a BRK can abort an NMI https://sourceforge.net/p/vice-emu/code ... cpu_bugs.s

calima
Posts: 1304
Joined: Tue Oct 06, 2015 10:16 am

Re: BRK masking bug and reliability of B pseudoflag

Post by calima » Thu Feb 18, 2021 1:39 am

This is getting pretty ridiculous just to save a byte per function call. If you're that strapped for space, look up the paper implementing a huffman code interpreter (without decompression, it's a streaming thing), and yay, your code size just went to 0.6-0.8.

Oziphantom
Posts: 1080
Joined: Tue Feb 07, 2017 2:03 am

Re: BRK masking bug and reliability of B pseudoflag

Post by Oziphantom » Thu Feb 18, 2021 3:10 am

with a massive const cost of the decoder, the table and you now have to run all of your code from the 2K or RAM so you need to unpack run unpack run.

stan423321
Posts: 34
Joined: Wed Sep 09, 2020 3:08 am

Re: BRK masking bug and reliability of B pseudoflag

Post by stan423321 » Thu Feb 18, 2021 4:31 am

As calima suggests, you can "unpack" the code into program counter as it goes (with a few bytes of RAM used for bitstream's program counter and such, but not loads of it). You lose some performance for tight loops, besides that it's an overall win. I can see that being a useful technique for rarely executed code like RPG NPC scripting. It could be still combined with BRK though, in more ways than one.


Post Reply