Skip to content

Commit e62b6a9

Browse files
committed
Add exception for hlt instruction
1 parent ba5d002 commit e62b6a9

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

  • python/icicle/Ghidra/Processors/x86/data/languages
  • tests

python/icicle/Ghidra/Processors/x86/data/languages/ia.sinc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2728,7 +2728,8 @@ enterFrames: low5 is low5 { tmp:1 = low5; export tmp; }
27282728
# as a NOP. We treat it as a NOP as well.
27292729
:FSETPM is vexMode=0 & byte=0xdb; byte=0xe4 { } # 80287 set protected mode
27302730

2731-
:HLT is vexMode=0 & byte=0xf4 { goto inst_start; }
2731+
define pcodeop hlt;
2732+
:HLT is vexMode=0 & byte=0xf4 { hlt(); }
27322733

27332734
:IDIV rm8 is vexMode=0 & byte=0xf6; rm8 & reg_opcode=7 ... { rm8ext:2 = sext(rm8);
27342735
local quotient = AX s/ rm8ext; # DE exception if quotient doesn't fit in AL

tests/hlt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from icicle import *
2+
3+
def hlt():
4+
vm = Icicle("x86_64", jit=False, tracing=True)
5+
page = 0x10000
6+
vm.mem_map(page, 0x1000, MemoryProtection.ExecuteRead)
7+
vm.mem_write(page, b"\xF4\xEB\xFE")
8+
vm.reg_write("rip", page)
9+
status = vm.step(1000)
10+
print(status, vm.exception_code)
11+
print(hex(vm.reg_read("rip")))
12+
13+
def main():
14+
hlt()
15+
16+
if __name__ == "__main__":
17+
main()

0 commit comments

Comments
 (0)