mirror of
https://github.com/st3fan/ewm.git
synced 2024-06-01 12:41:27 +00:00
32 lines
862 B
Lua
32 lines
862 B
Lua
|
-- EWM Meets Lua
|
||
|
|
||
|
local function myerrhandler(err)
|
||
|
print(err)
|
||
|
print(debug.traceback())
|
||
|
return false
|
||
|
end
|
||
|
|
||
|
-- TODO How do we do this in C?
|
||
|
xpcall(function()
|
||
|
-- Add some random intercepts to measure the performance impact
|
||
|
|
||
|
local cpu = require 'cpu'
|
||
|
|
||
|
cpu.onBeforeExecuteInstruction(0x60, function(state, opcode, operand)
|
||
|
--print(string.format('Before RTS from 0x%.4x', state.pc))
|
||
|
end)
|
||
|
|
||
|
cpu.onBeforeExecuteInstruction(0x20, function(state, opcode, operand)
|
||
|
--print(string.format('Before JSR from 0x%.4x', state.pc))
|
||
|
end)
|
||
|
|
||
|
cpu.onAfterExecuteInstruction(0x60, function(state, opcode, operand)
|
||
|
--print(string.format('After RTS from 0x%.4x', state.pc))
|
||
|
end)
|
||
|
|
||
|
cpu.onAfterExecuteInstruction(0x20, function(state, opcode, operand)
|
||
|
--print(string.format('After JSR from 0x%.4x', state.pc))
|
||
|
end)
|
||
|
|
||
|
end , myerrhandler)
|