为什么程序集 8086 中不允许使用变量名 "name"?

Why is the variable name "name" not allowed in assembly 8086?

当我尝试用名称 "name" 声明一个变量时它不起作用,它给我一个错误,这个 there are errors. 有以下解释

(22) wrong parameters: MOV  BL, name
(22) probably no zero prefix for hex; or no 'h' suffix; or wrong addressing; or undefined var: name

这是我的代码

; multi-segment executable file template.

data segment
    ; add your data here!
    pkey db "press any key...$"
    name db "myname"
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax

    ; add your code here

    MOV BL, name


    ;;;;;

    lea dx, pkey
    mov ah, 9
    int 21h        ; output string at ds:dx

    ; wait for any key....
    mov ah, 1
    int 21h

    mov ax, 4c00h ; exit to operating system.
    int 21h
ends

end start ; set entry point and stop the assembler.

问题是,如果我为变量尝试任何其他名称,nameennamename_,但大写字母不起作用,我试过了网上到处找,要么是我找错了,要么是我不知道要找什么。

NAMEMASM 指令的名称,被视为保留字。使用保留字作为变量名会引起问题。 NAME 指令特别没有做任何有用的事情,因为文档建议 MASM 只是忽略它。来自 MASM manual:

NAME modulename

Ignored.

EMU8086 中,除了将 name 变量重命名为其他名称外,没有任何真正的解决方法。

MASM 5.x+ 中,您可以通过使用 OPTION 指令来解决此问题:

OPTION NOKEYWORD:<NAME>

OPTION NOKEYWORDMASM 手册中是这样定义的:

MASM reserved words are not case sensitive except for predefined symbols (see “Predefined Symbols,” later in this chapter).

The assembler generates an error if you use a reserved word as a variable, code label, or other identifier within your source code. However, if you need to use a reserved word for another purpose, the OPTION NOKEYWORD directive can selectively disable a word’s status as a reserved word.

For example, to remove the STR instruction, the MASK operator, and the NAME directive from the set of words MASM recognizes as reserved, use this statement in the code segment of your program before the first reference to STR, MASK, or NAME:

OPTION NOKEYWORD:<STR MASK NAME>