You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2022 Community(MASM)报A4011错误:仅一个.MODEL指令却提示重复

解决MASM报错A4011:存在多个.MODEL指令的问题

我正在使用Visual Studio 2022 Community版本,搭配MASM和Kip Irvine库进行开发(课程要求必须用这些工具)。好不容易配置完所有文件路径,现在碰到报错A4011,提示存在多个.MODEL指令,但我的代码里明明只写了一个。

我的代码如下:

.386
.MODEL flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword


includelib \Irvine\Irvine32.lib
include    \Irvine\Irvine32.inc
include    \Irvine\macros.inc
includelib \Irvine\kernel32.lib

.data
    prompt1 db "Please enter your Name >> ",0
    prompt2 db "Please enter your age >>",0
    fname db 20 DUP(?)
    age DWORD ?
    prompt3 db "Your name is: ",0
    prompt4 db "Your age is: ",0
    

.code
main proc
    mov edx,offset prompt1
    call writestring

    mov edx, offset fname
    mov ecx, sizeof fname
    call readstring
    call Crlf

    mov edx, offset prompt2
    call writestring
    
    call Readdec
    mov age,eax
    call Crlf

    mov edx, offset prompt3
    call writestring
    
    mov edx,offset fname
    call writestring
    call Crlf
    mov edx, offset prompt4
    call writestring
    
    mov eax,age
    call writedec
    call Crlf

    invoke ExitProcess,0
main endp
end main

问题原因及解决方法

  • 问题根源:你引入的Irvine32.inc头文件内部已经定义了.MODEL flat,stdcall指令,和你代码中手动添加的这一行重复,导致MASM抛出A4011错误。
  • 解决步骤:直接删除代码中的.MODEL flat,stdcall行即可。修改后的代码开头应为:
.386
.stack 4096
ExitProcess proto,dwExitCode:dword

内容的提问来源于stack exchange,提问作者Dkeane1

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 15:40:28