-- varargs-check.lua -- load the varargs ABI probe with the M4 COFF loader and -- check the three sums. The callee walks the contiguous program stack below -- its last fixed argument; these values prove the variadic slots are real. -- -- M4_LOADER_LUA path to vendor/vt1200/dwt/loader/loader.lua -- LOADER_END loader inspection/exit frame dofile(os.getenv("M4_LOADER_LUA")) local ENDF = tonumber(os.getenv("LOADER_END") or "2700") local frames = 0 local checked = false emu.register_frame_done(function() frames = frames + 1 if frames == ENDF - 1 and not checked then checked = true local prog = manager.machine.devices[':maincpu'].spaces['program'] local m = {} for i = 0, 2 do m[i] = prog:read_u32(0x018A8000 + i * 0x20) end print(string.format("M4: varargs sum1=%d sum2=%d sum3=%d", m[0], m[1], m[2])) if m[0] == 15 and m[1] == 150 and m[2] == 1500 then print("M4 MAME: PASS") else print("M4 MAME: FAIL (want 15, 150, 1500)") end end end, "varargs-check")