From d6d06b2f1a4c08220cdc0766ee0fbf143857eeca Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 27 Aug 2026 01:16:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(asm):=20inb/inw/inl=20=E6=98=BE=E5=BC=8F=20?= =?UTF-8?q?mov=20=E5=88=B0=E8=BE=93=E5=87=BA=E5=AF=84=E5=AD=98=E5=99=A8?= =?UTF-8?q?=E2=80=94=E2=80=94=E5=8A=A0=20CLOBBER=5FRAX=20=E5=90=8E=20LLVM?= =?UTF-8?q?=20=E4=B8=8D=E5=86=8D=E6=8A=8A=20value=20=E7=BB=91=20RAX?= =?UTF-8?q?=EF=BC=8C=E5=8E=9F=E5=86=99=E6=B3=95=E8=AF=BB=E5=88=B0=20asm=20?= =?UTF-8?q?=E5=89=8D=E6=AE=8B=E7=95=99=E5=AF=BC=E8=87=B4=20waitReady=20err?= =?UTF-8?q?=3D8=EF=BC=88status=200x50=20=E8=A2=AB=E8=AF=BB=E6=88=90?= =?UTF-8?q?=E5=90=AB=20DF=EF=BC=89=EF=BC=9B=E6=8C=89=20mm.vp=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=20asm=20=E5=86=85=20mov=20{AsmOut},=20eax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asm.vp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/asm.vp b/asm.vp index f1b0f4c..ae55d66 100644 --- a/asm.vp +++ b/asm.vp @@ -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