fix(asm): inb/inw/inl 显式 mov 到输出寄存器——加 CLOBBER_RAX 后 LLVM 不再把 value 绑 RAX,原写法读到 asm 前残留导致 waitReady err=8(status 0x50 被读成含 DF);按 mm.vp 模式 asm 内 mov {AsmOut}, eax
This commit is contained in:
1 parent
4bcc66c571
commit
d6d06b2f1a
1 file changed
+9
-3
@@ -18,9 +18,13 @@ def pause():
|
||||
|
||||
def inb(port: t.CUInt16T) -> t.CUInt8T:
|
||||
value: t.CUInt32T
|
||||
# 显式 mov 到输出寄存器:EAX 作临时(CLOBBER_RAX 声明),避免
|
||||
# AsmOut 分配到非 RAX 时读到 asm 前残留(加 CLOBBER_RAX 后 LLVM
|
||||
# 不再把 value 绑到 RAX,需 asm 内显式存值)。
|
||||
c.Asm(f"""mov edx, {c.AsmInp(t.CUInt32T(port), t.ASM_DESCR.REG_ANY)}
|
||||
in al, dx
|
||||
movzx eax, al""",
|
||||
movzx eax, al
|
||||
mov {c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)}, eax""",
|
||||
out = [c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op =[t.ASM_DESCR.CLOBBER_RDX, t.ASM_DESCR.CLOBBER_RAX])
|
||||
return t.CUInt8T(value)
|
||||
@@ -36,7 +40,8 @@ def inw(port: t.CUInt16T) -> t.CUInt16T:
|
||||
value: t.CUInt32T
|
||||
c.Asm(f"""mov edx, {c.AsmInp(t.CUInt32T(port), t.ASM_DESCR.REG_ANY)}
|
||||
in ax, dx
|
||||
movzx eax, ax""",
|
||||
movzx eax, ax
|
||||
mov {c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)}, eax""",
|
||||
out = [c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op =[t.ASM_DESCR.CLOBBER_RDX, t.ASM_DESCR.CLOBBER_RAX])
|
||||
return t.CUInt16T(value)
|
||||
@@ -50,7 +55,8 @@ def outw(port: t.CUInt16T, value: t.CUInt16T):
|
||||
def inl(port: t.CUInt16T) -> t.CUInt32T:
|
||||
value: t.CUInt32T
|
||||
c.Asm(f"""mov edx, {c.AsmInp(t.CUInt32T(port), t.ASM_DESCR.REG_ANY)}
|
||||
in eax, dx""",
|
||||
in eax, dx
|
||||
mov {c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)}, eax""",
|
||||
out = [c.AsmOut(value, t.ASM_DESCR.OUTPUT_REG)],
|
||||
op =[t.ASM_DESCR.CLOBBER_RDX, t.ASM_DESCR.CLOBBER_RAX])
|
||||
return value
|
||||
|
||||
Reference in new issue
Block a user