如何使用MASM检查输入字符串是否在使用MASM的程序集x86中是字符,数字

时间:2017-07-13 09:48:51

标签: assembly x86 masm

所以这是我的代码,我似乎无法想到我在哪里弄错了。我正在尝试做一个接受5位数字作为输入的练习,并告诉你这个数字是奇数还是偶数。如果数字超过5位,程序应该能够处理错误,并且有非数字字符作为输入。我仍然是汇编语言的初学者,几乎在谷歌的每个地方搜索,以回答每一步和功能

getNumber:
         push offset msg        ; put in to stack the effective addr of msg
       call StdOut                  ; call console display API

       push 100                    ; set the maximum input character
       push offset buffer       ; put in to stack the effective addr of input storage
       call StdIn                    ; call console input API

       push offset input       ; put in to stack the effective addr of msg2
       call StdOut                 ; call console display API

       push offset buffer      ; put in to stack the effective addr of input storage
       call compare
compare:
            lea edx, [buffer]
            mov al, byte ptr [edx]
            cmp al,'/'  
            jle notNumber
            cmp al, 'a'
            jb notNumber
            cmp al, 'z'
            ja notNumber
            cmp al,':'  
            jge notNumber
            cmp al,30h
            jge aNumber
            ret

aNumber:
            push offset aNum
            call StdOut
            call exit
notNumber:
            push offset notNum
            call StdOut
            call exit
end getNumber

0 个答案:

没有答案