来自 Windows 10 - Visual Studio 的 MASM 错误 A2006

Error A2006 with MASM from Windows 10 - Visual Studio

首先,对不起我的英语。好吧,我正在尝试执行从这本书中获取的一些指令,它被称为“现代 x86 汇编语言程序”。而且这本书在 Visual Studio 如何混合使用 C++ 和 MASM 方面不是很清楚。因为从字面上看,第一个例子给了我一个错误。

ch02_01.asm(15):错误 A2006:未定义的符号:r8d

代码不是很广泛:

ch02_01.asm(15):错误 A2006:未定义的符号:r8d

; ------------------------------------------------------
;                       Ch02_01.asm
; ------------------------------------------------------

; extern "C" int IntegerAddSub_(int a, int b, int c, int d);
    
    .model flat
    .code

IntegerAddSub_ proc

; Calculate a + b + c - d
        mov eax, ecx                ;eax = a
        add eax, edx                ;eax = a + b
        add eax, r8d                ;eax = a + b + c
        sub eax, r9d                ;eax = a + b + c - d

        ret                         ;return result to caller
IntegerAddSub_ endp
        end

使用 r8dr9d 意味着该程序集实际上是 x64 原生的,因此需要使用 64 位版本的 MASM。