wiremod / wire-cpu

Legacy CPU/GPU/SPU as a separate addon.
Apache License 2.0
8 stars 6 forks source link

Fix emits killing lua on emitted interrupt #28

Closed DerelictDrone closed 11 months ago

DerelictDrone commented 11 months ago

Currently from the main branch after #27, attempting to use the INT, SPG, CPG, SPP, CPP, SRL, and SMAP instructions may cause a lua error, relating to string.format of Dyn_EmitInterrupt expecting both arguments to be numbers(how naive of me)

In the case of INT, because it passes the string $1(macro for first operand of the instruction, which hasn't been replaced with the final name yet) to Dyn_EmitInterrupt()

In the case of the paging instructions listed, because they pass the string IDX as second argument to Dyn_EmitInterrupt().

DerelictDrone commented 11 months ago

Still, this is an error we have right now that's affecting 7 instructions, it would be nice if we can get this merged since it's an issue that's user-facing.

thegrb93 commented 11 months ago

Is it possible to get a test that shows what all the possible values of intNo,intParam can be? To prove that injecting code into them isn't possible?

DerelictDrone commented 11 months ago

Is it possible to get a test that shows what all the possible values of intNo,intParam can be? To prove that injecting code into them isn't possible?

I don't know if this was necessarily what you were asking for, but see the written test here

Results I got: image

Note that the last emitted interrupt has a $1 because that's the macro for operand 1, the CPU seems to be emitting interrupt 2 afterward because it ran out of instructions

thegrb93 commented 11 months ago

Can you add a comment stating that 'intNo' can only be numeric or '$1' and intParam can only be numeric or 'IDX'?