0
我有一個問題,理解爲什麼我的cmp語句無法正常工作。裝配不正常
當我運行這個,我在第一個輸入0,它進入storeValue。我輸入0作爲第二個值,它會像它應該的那樣進入searchArray。
我在我的cmp和跳轉語句的斷點和AL的一個表上,所以我不明白爲什麼它存儲的第一個0當它應該提示搜索值在那一點。
感謝您的期待。
.DATA
prompt1 BYTE "Enter a value to put in array or 0 to search array.", 0
prompt2 BYTE "Enter a value to search array for.",0
intArray DWORD ?
numElem DWORD 0
SearchVal DWORD ?
resultNope BYTE "Not in array.",0
.CODE
_MainProc PROC
lea ebx, intArray ;get the address of array.
start: input prompt1, intArray, 50 ;read in integer
atod intArray ;convert to int
mov al, [ebx] ;move int to register
cmp al, 0 ;if integer is positive - store it!
jg storeValue ;JUMP!
cmp al, 0 ;if 0 - time to search array!
je searchArray ;JUMP!
storeValue: add numElem, 1 ;Adds 1 to num of elements in array.
mov [ebx], al ;moves number into array.
add ebx, 1 ;increment to next array address.
jmp start ;get next number for array. JUMP!
searchArray:input prompt2, searchVal, 50 ;What are we searching array for?
atod searchVal ;convert to int
lea ebx, intArray ;get address of array.
mov ecx, 1 ;set loop counter to 1.
對不起,我是s直到學習80x86 asm,我假設atod和輸入是本書解釋它的標準語法。仔細研究它,我發現它們是宏。雖然謝謝!我明白了,在我從EAX調用atod到[EBX]之後,我愚蠢地忘了移動這個值,從而解決了我的問題。謝謝! – Arcath