SolraBizna / j6502

Cycle-accurate W65C02 emulator in Java
Other
2 stars 1 forks source link

Reduce reliance on overflow flag #4

Open atirut-w opened 2 years ago

atirut-w commented 2 years ago

Checking the overflow flag requires assembly codes since C does not have a built in way to check it. While CC65 allow you to easily mix C and ASM, it is slow. The only other good compile I've found allows inline assembly but I have no earthly idea how to make my inline ASM codes work.

While the component list port is easy because if you last wrote 0 and got an ff, you know you've reached EOL, but the UIF component port is a pain because there are a lot more variables(0xff numbers in reply, etc.).

SolraBizna commented 2 years ago

One of the rules I've applied on all my real 6502 stuff is that I never make a state detectable only by checking the V flag. Looks like I forgot to apply that principle when designing OCMOS. In a lot of places. Yikes!

Some of this stuff you can handle correctly by just never making a single mistake in your state machine(!), but there are definitely a few places where V is unavoidably necessary. Unfortunately, since I can't change the hardware interface anymore, the only way forward for you is to make assembly glue routines for handling the various IO functions that use the V flag for signalling. Sorry!

To put things into context, I made OCMOS as a single-weekend side project. I had needed to make a Java port of my 6502 emulator for some work purpose (I don't remember what), and I thought "I could use this to make an OpenComputers arch!" I figured I could get it done in a single weekend, but it ended up encroaching two or three days into the following work week. It was all very rushed; I was trying to get it done and move on as soon as possible. Looking back on the design now, there are many small things I would change. Unfortunately, since I can't ever log into my Minecraft account again, I can't test any changes anymore. (Breaking backwards compatibility wouldn't be an issue, I would simply make an "OCMOS v2" arch, and existing computers would continue using the "OCMOS v1" arch, or maybe I would make a new bitflag to enable more-C-friendly behavior.)

You're actually the first person I've heard of actually using this arch, apart from me. Helps me feel like that long weekend might not have been wasted after all.

atirut-w commented 2 years ago

It's actually very impressive for a weekend project. I initially moved from Thistle because of a fatal big, but I have found OCMOS to have a lot of convenient features like MMU and drive controllers.

On Sun, 5 Jun 2022, 04:02 Solra Bizna, @.***> wrote:

One of the rules I've applied on all my real 6502 stuff is that I never make a state detectable only by checking the V flag. Looks like I forgot to apply that principle when designing OCMOS. In a lot of places. Yikes!

Some of this stuff you can handle correctly by just never making a single mistake in your state machine(!), but there are definitely a few places where V is unavoidably necessary. Unfortunately, since I can't change the hardware interface anymore, the only way forward for you is to make assembly glue routines for handling the various IO functions that use the V flag for signalling. Sorry!

To put things into context, I made OCMOS as a single-weekend side project. I had needed to make a Java port of my 6502 emulator for some work purpose (I don't remember what), and I thought "I could use this to make an OpenComputers arch!" I figured I could get it done in a single weekend, but it ended up encroaching two or three days into the following work week. It was all very rushed; I was trying to get it done and move on as soon as possible. Looking back on the design now, there are many small things I would change. Unfortunately, since I can't ever log into my Minecraft account again, I can't test any changes anymore. (Breaking backwards compatibility wouldn't be an issue, I would simply make an "OCMOS v2" arch, and existing computers would continue using the "OCMOS v1" arch, or maybe I would make a new bitflag to enable more-C-friendly behavior.)

You're actually the first person I've heard of actually using this arch, apart from me. Helps me feel like that long weekend might not have been wasted after all.

— Reply to this email directly, view it on GitHub https://github.com/SolraBizna/j6502/issues/4#issuecomment-1146685220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGBGNX7RRADCVBK3NA5AGSDVNO77JANCNFSM5X3RYVBA . You are receiving this because you authored the thread.Message ID: @.***>