MASM32 错误 A2070:无效的指令操作数
MASM32 error A2070: invalid instruction operands
我有一个 Hanoi 的 assembly32 代码,但我无法编译它,我收到错误:
hanoi.asm(9):错误 A2070:指令操作数无效
我用MASM32.
完整代码:
.586
.MODEL FLAT
PUBLIC _towers
EXTERN _printf:NEAR
.CODE
_towers:PUSH EBP
MOV EBP, ESP
SUB ESP, 4
CMP [EBP+8], 1 ;ERROR
JNE L1
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
PUSH OFFSET FLAT:format;
CALL _printf
ADD ESP, 12
JMP Done
L1: MOV EAX, 6
SUB EAX, [EBP+12]
SUB EAX, [EBP+16]
MOV [EBP-4], EAX
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
MOV EAX, [EBP+8]
DEC EAX
PUSH EAX
CALL _towers
ADD ESP, 12
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
PUSH 1
CALL _towers
ADD ESP,12
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP-4]
PUSH EAX
MOV EAX, [EBP+8]
DEC EAX
PUSH EAX
CALL _towers
ADD ESP, 12
Done: MOV ESP,EBP
POP EBP
RET 0
.DATA
format DB "Move from %d to %d\n"
END
你能帮帮我吗,我该怎么做?
你的代码对我不起作用,我运行它但算法有问题,它从未找到解决方案。
所以,这是另一个实际有效的河内塔解决方案。它是用 EMU8086(MASM Intel 语法)制作的,你只需复制粘贴然后 运行 :
.model small
.stack 300H
.data
x dw 3
text db "Move from peg "
d1 db ?
text2 db " to peg "
d2 db ?
newline db 0AH, 0DH, '$'
.code
main proc
mov ax, @data
mov ds, ax
mov ax, 1
push ax
mov ax, 3
push ax
mov ax, 2
push ax
mov ax, x
push ax
call solve
mov ax, 4C00H
int 21h
main endp
solve proc
push bp
mov bp, sp
cmp word ptr ss:[bp+4], 0
je down
push word ptr ss:[bp+0AH]
push word ptr ss:[bp+6]
push word ptr ss:[bp+8]
mov ax, word ptr ss:[bp+4]
dec ax
push ax
call solve
push word ptr ss:[bp+0AH]
push word ptr ss:[bp+08]
call print
push word ptr ss:[bp+06H]
push word ptr ss:[bp+8]
push word ptr ss:[bp+0AH]
mov ax, word ptr ss:[bp+4]
dec ax
push ax
call solve
pop bp
ret 8
down:
pop bp
ret 8
solve endp
print proc
push bp
mov bp, sp
mov d1, '0'
mov al, byte ptr ss:[bp+06]
add d1, al
mov d2, '0'
mov al, byte ptr ss:[bp+4]
add d2, al
lea dx, text
mov ah, 09
int 21h
pop bp
ret 4
print endp
end
还记得我说的初始化数据吗?好吧,这个有它!也许这就是它起作用的原因。
我有一个 Hanoi 的 assembly32 代码,但我无法编译它,我收到错误: hanoi.asm(9):错误 A2070:指令操作数无效 我用MASM32.
完整代码:
.586
.MODEL FLAT
PUBLIC _towers
EXTERN _printf:NEAR
.CODE
_towers:PUSH EBP
MOV EBP, ESP
SUB ESP, 4
CMP [EBP+8], 1 ;ERROR
JNE L1
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
PUSH OFFSET FLAT:format;
CALL _printf
ADD ESP, 12
JMP Done
L1: MOV EAX, 6
SUB EAX, [EBP+12]
SUB EAX, [EBP+16]
MOV [EBP-4], EAX
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
MOV EAX, [EBP+8]
DEC EAX
PUSH EAX
CALL _towers
ADD ESP, 12
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP+12]
PUSH EAX
PUSH 1
CALL _towers
ADD ESP,12
MOV EAX, [EBP+16]
PUSH EAX
MOV EAX, [EBP-4]
PUSH EAX
MOV EAX, [EBP+8]
DEC EAX
PUSH EAX
CALL _towers
ADD ESP, 12
Done: MOV ESP,EBP
POP EBP
RET 0
.DATA
format DB "Move from %d to %d\n"
END
你能帮帮我吗,我该怎么做?
你的代码对我不起作用,我运行它但算法有问题,它从未找到解决方案。
所以,这是另一个实际有效的河内塔解决方案。它是用 EMU8086(MASM Intel 语法)制作的,你只需复制粘贴然后 运行 :
.model small
.stack 300H
.data
x dw 3
text db "Move from peg "
d1 db ?
text2 db " to peg "
d2 db ?
newline db 0AH, 0DH, '$'
.code
main proc
mov ax, @data
mov ds, ax
mov ax, 1
push ax
mov ax, 3
push ax
mov ax, 2
push ax
mov ax, x
push ax
call solve
mov ax, 4C00H
int 21h
main endp
solve proc
push bp
mov bp, sp
cmp word ptr ss:[bp+4], 0
je down
push word ptr ss:[bp+0AH]
push word ptr ss:[bp+6]
push word ptr ss:[bp+8]
mov ax, word ptr ss:[bp+4]
dec ax
push ax
call solve
push word ptr ss:[bp+0AH]
push word ptr ss:[bp+08]
call print
push word ptr ss:[bp+06H]
push word ptr ss:[bp+8]
push word ptr ss:[bp+0AH]
mov ax, word ptr ss:[bp+4]
dec ax
push ax
call solve
pop bp
ret 8
down:
pop bp
ret 8
solve endp
print proc
push bp
mov bp, sp
mov d1, '0'
mov al, byte ptr ss:[bp+06]
add d1, al
mov d2, '0'
mov al, byte ptr ss:[bp+4]
add d2, al
lea dx, text
mov ah, 09
int 21h
pop bp
ret 4
print endp
end
还记得我说的初始化数据吗?好吧,这个有它!也许这就是它起作用的原因。