branlwyd / bdcpu16

DCPU-16 simulator based on version 1.7 of the DCPU-16 specification. See http://dcpu.com/.
0 stars 0 forks source link

Core: CPU performance ideas #18

Closed branlwyd closed 11 years ago

branlwyd commented 11 years ago

A couple of performance ideas:

branlwyd commented 11 years ago

For the step handler idea, could also introduce an "error step handler" used only in error situations that does nothing, to remove need to check error each time a step is taken.

Also, need to be careful about conditions for adding/removing the Interrupt step handler. It can also fail to handle an interrupt when the "skip" flag is set. Would need to take this into account.

For that matter, could also create a Skip step handler that handles the CPU's skip state. Would need to keep track of which state to go back to after skip finished.

Device notification through cyclesElapsed() can be factored out of the individual step handlers. (This would nicely also allow the debugger device to immediately get notification when an interrupt is received, breaking on the first instruction.)

branlwyd commented 11 years ago

Single-threadedness returned in fb1b6a7310d2f4248758b243a09986f990e897e9. Step handlers introduced in 39a8035ec9ffe16e525b2c79d309a38fddcd1628 (and they're great). Closing.