1 Commits

Author SHA1 Message Date
Duncan Ogilvie e62b6a9622 Add exception for hlt instruction 2025-10-26 12:23:37 +01:00
2 changed files with 19 additions and 1 deletions
@@ -2728,7 +2728,8 @@ enterFrames: low5 is low5 { tmp:1 = low5; export tmp; }
# as a NOP. We treat it as a NOP as well.
:FSETPM is vexMode=0 & byte=0xdb; byte=0xe4 { } # 80287 set protected mode
:HLT is vexMode=0 & byte=0xf4 { goto inst_start; }
define pcodeop hlt;
:HLT is vexMode=0 & byte=0xf4 { hlt(); }
:IDIV rm8 is vexMode=0 & byte=0xf6; rm8 & reg_opcode=7 ... { rm8ext:2 = sext(rm8);
local quotient = AX s/ rm8ext; # DE exception if quotient doesn't fit in AL
+17
View File
@@ -0,0 +1,17 @@
from icicle import *
def hlt():
vm = Icicle("x86_64", jit=False, tracing=True)
page = 0x10000
vm.mem_map(page, 0x1000, MemoryProtection.ExecuteRead)
vm.mem_write(page, b"\xF4\xEB\xFE")
vm.reg_write("rip", page)
status = vm.step(1000)
print(status, vm.exception_code)
print(hex(vm.reg_read("rip")))
def main():
hlt()
if __name__ == "__main__":
main()