推送和弹出错误 A2070
push and pop error A2070
当我 运行 程序时,我收到第 16 行错误,指出错误 A2070,第 16 行是 mov ax, message[si]
。是因为我要从一个寄存器转到另一个寄存器吗?另外我该如何解决这个问题?
该程序是一个简单的推入和弹出存储堆栈中每个字符的字符串,递增堆栈消息,然后弹出堆栈以向后显示字符串。
;
.model small
.data
message db "Hello, DOS Here!",0 ; the string
nameSize = ($ - message) - 1 ;gives length of the string
.code
main proc
mov ax,@data
mov ds,ax
mov cx, nameSize ;size of the string stored in cx
mov si, 0 ;stack index 0
Li:
mov ax, message[si] ;
push ax ;push ax
inc si ;incremting stack index
loop Li ; looping through message character
mov cx, nameSize ;Popping
mov si, 0 ; popping from stack
L2:
pop ax ;pop of the ax
mov message[si], al ;
inc si
loop L2
mov dx, offset message ; displaying of string
mov ah,9
int 21
mov ax,4c00h
int 21h
main endp
end main
您将字符串声明为 DB
类型:
▼
message db "Hello, DOS Here!",0 ; the string
DB
表示"one byte",但是你是将一个字节移动到两个字节寄存器AX
,这是一个大小冲突。让我们修复它:
mov cx, nameSize ;size of the string stored in cx
mov si, 0 ;stack index 0
xor ax, ax ;◄■■■ CLEAR AX.
Li:
mov al, message[si] ;◄■■■ USE AL.
push ax ;push ax
inc si ;incremting stack index
loop Li ; looping through message character
顺便说一句,您对 int 21
的打印字符串调用缺少 "h" :int 21h
.
当我 运行 程序时,我收到第 16 行错误,指出错误 A2070,第 16 行是 mov ax, message[si]
。是因为我要从一个寄存器转到另一个寄存器吗?另外我该如何解决这个问题?
该程序是一个简单的推入和弹出存储堆栈中每个字符的字符串,递增堆栈消息,然后弹出堆栈以向后显示字符串。
;
.model small
.data
message db "Hello, DOS Here!",0 ; the string
nameSize = ($ - message) - 1 ;gives length of the string
.code
main proc
mov ax,@data
mov ds,ax
mov cx, nameSize ;size of the string stored in cx
mov si, 0 ;stack index 0
Li:
mov ax, message[si] ;
push ax ;push ax
inc si ;incremting stack index
loop Li ; looping through message character
mov cx, nameSize ;Popping
mov si, 0 ; popping from stack
L2:
pop ax ;pop of the ax
mov message[si], al ;
inc si
loop L2
mov dx, offset message ; displaying of string
mov ah,9
int 21
mov ax,4c00h
int 21h
main endp
end main
您将字符串声明为 DB
类型:
▼
message db "Hello, DOS Here!",0 ; the string
DB
表示"one byte",但是你是将一个字节移动到两个字节寄存器AX
,这是一个大小冲突。让我们修复它:
mov cx, nameSize ;size of the string stored in cx
mov si, 0 ;stack index 0
xor ax, ax ;◄■■■ CLEAR AX.
Li:
mov al, message[si] ;◄■■■ USE AL.
push ax ;push ax
inc si ;incremting stack index
loop Li ; looping through message character
顺便说一句,您对 int 21
的打印字符串调用缺少 "h" :int 21h
.