簡體   English   中英

x86 assembly-masm32:無效的指令操作數

[英]x86 assembly-masm32: invalid instruction operands

我正在嘗試制作一個密碼文件,您可以在其中輸入密碼,它會顯示所有密碼。 我當前的代碼是這個,但是有一個錯誤:

.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\masm32.inc
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\masm32.lib

.data
        input   db 'Enter the password:',13,10,0
        string  db 'The passwords are:',0
        space db '       ',0
        pass1 db 'example password 1',0
        pass2 db 'example password 2',0
        pass3 db 'example password 3',0
        pass4 db 'example password 4',0
        ermsg db 'Incorrect Password. Exiting....',0
        count dd 0
            comp dd 13243546

.data?
        buffer db 100 dup(?)
.code
start:
_top:
        invoke StdOut,ADDR input
        invoke StdIn,ADDR buffer,100 ; receive text input
        cmp buffer, comp ;sorry for not pointing this out - this is line 32
        jz _next
        jmp _error
_next:
        invoke StdOut, ADDR string
        invoke StdOut, ADDR space
        invoke StdOut, ADDR pass1
        invoke StdOut, ADDR pass2
        invoke StdOut, ADDR pass3
        invoke StdOut, ADDR pass4
        invoke ExitProcess,0
_error:
        invoke StdOut, ADDR ermsg
        mov eax, 1
            mov count, eax
            cmp count, 3
            jz _exit
            jmp _top:
_exit:
            invoke ExitProcess, 0

這是錯誤:

 test.asm(32) : error a2070: invalid instruction operands

為什么會這樣。 我知道該錯誤在第32行上,但我不知道該錯誤是什么。

cmp用於比較兩個字節/字/雙字,而不是字符串 因此,您基本上是在要求它將buffer的前四個字節與comp的四個字節進行comp 使用無效的語法來做到這一點。

要比較字符串,您需要使用cmps或手動循環。

此外, comp應該聲明為comp db '13243546', 0 您現在聲明的方式使其變成雙字00CA149A ,它等效於C字符串"\\x9A\\x14\\xCA" -輸入起來非常復雜:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM