AdoHTQ / Batpu2-VM

MIT License
28 stars 10 forks source link

Setting execution rate to high speeds skips parts of code #24

Closed saaawdust closed 4 weeks ago

saaawdust commented 4 weeks ago

If you set your execution rate to a high number, such as 1000, parts of the code seem to be skipped. Here's an example with a piece of code that individually draws each pixel of a space invader when the execution rate is 100: image It works perfectly fine. Now the same code, again, but the execution rate is 1000: image You can see the top part of the render has started to disappear. Finally, I set the execution rate to 10000: image The entire code is skipped. The higher the execution rate seems to be, the more code it skips - and this doesn't only happen with rendering, I've had this issue everywhere!

Reproduction Steps:

If it helps, I'm on windows! Paste this very large and inefficient chuck of code: https://pastebin.com/xV57PTmm This is just an example.

saaawdust commented 4 weeks ago

Looking at this more: For me atleast, this seems to happen SPECIFICALLY when the execution rate is above 700. image image

AdoHTQ commented 4 weeks ago

If you are in Matt's discord, could you try running some of the programs in the #cpu-programs channel. People have run programs at tens of thousands of instructions per second with no issues.

saaawdust commented 4 weeks ago

Interesting that these programs work - Do you think it's possibly to do something with the way I programmed it? (Since it doesn't use any loops as of?)

AdoHTQ commented 4 weeks ago

Just looked at your code. I'm pretty sure it goes over the instruction limit of 1024. Not sure why execution speed would affect this though.

Noname-Official commented 4 weeks ago

In the beginning, you JMP to .main but after you use RET. Changing this to a HLT fixes it.