[英]What does these errors mean? Assembly Language
; This program checks for even or odd parities inside of an array. Displays 1 if even or 0 if odd.
Include Irvine32.inc
TRUE = 1
FALSE = 0
.data
str1 BYTE "Even Parity", 0
str2 BYTE "Odd Parity", 0
str3 BYTE "The block of data under checking is: ", 0
array1 BYTE 1,0,1,0,0,0,1,0,0,1
array2 BYTE 1,0,0,0,0,0,1,0,0,1
; declares two 10-bit arrays
.code
main proc
call Clrscr ; Clears the screen
mov esi, OFFSET array1 ; Pass address
mov ecx, LENGTHOF array1 ; Pass length
call Display ; Display on Console
call Parity_Check
cmp eax,0
je L1 ; if EAX = 0 then odd
mov edx, OFFSET str1
call WriteString ; Write str1
call Crlf
L1:
mov edx, OFFSET str2
Call WriteString ; Write str2
call Crlf
call Crlf ; Check if array2 is even or odd
mov esi, OFFSET array2 ; Pass Address
mov ecx, LENGTHOF array2 ; Pass length
call Display ; Display on console
call Parity_Check
cmp eax, 0
je L2 ; if eax = 0 then odd
mov edx, OFFSET str1
call WriteString ;Write str1
call Crlf
L2:
mov edx, OFFSET str2
call WriteString ; Write str2
call Crlf
call Crlf
invoke ExitProcess,0
main endp
Parity_Check PROC USES eax ecx esi edi ;Returns 1 if even 0 if odd
mov edi, 0 ; array pointer 0
L1:
xor [esi], 0 ; Xor data bits
inc esi ; points to next bit
loop L1 ; continue loop
jpe L2 ; jumps to L2 if even
jpo L3 ; jumps to L3 if odd
L2:
mov eax, TRUE ; copies 1(true) to eax
jmp L4
L3:
mov eax, FALSE ; copies 0(false) to eax
L4:
ret
Parity_Check ENDP
Display PROC USES esi ecx edx ; Displays array elements
mov edx, OFFSET str3
call WriteString ; Writes str3
L1:
mov eax, [esi] ; Store array in eax
call WriteDec ; Write EAX
inc esi ; Point to next item in array
loop L1 ; Continue Traversing
call Crlf
ret
Display endp
end main
我無法弄清楚為什么我的XOR和masm.target(文件)錯誤導致錯誤。 XOR說“無效的指令操作數”,而masm.targets錯誤將我帶到該文件。
masm.targets是文件名,錯誤代碼是第50行第5列的MSB3721(再次它將我帶到另一頁,所以我假設我的MASM設置有問題?)。 對這兩種方面有任何幫助嗎?
array1 BYTE 1,0,1,0,0,0,1,0,0,1
array2 BYTE 1,0,0,0,0,0,1,0,0,1
; 聲明兩個10位數組
你實際上聲明了兩個10 字節的數組。
xor [esi], 0 ; Xor data bits
MASM會抱怨不知道這個xor
操作的大小。 只需將其寫為xor byte ptr [esi], 0
jpe L2 ; jumps to L2 if even
jpo L3 ; jumps to L3 if odd
這兩個奇偶校驗相關的跳轉都將基於增加ESI中地址的奇偶校驗。 它們不反映您在測試數組中的字節時獲得的任何奇偶校驗值! 這是一個例行程序:
Parity_Check PROC USES eax ecx esi ;Returns 1 if even, 0 if odd
mov al, 0
L1:
add al, [esi]
inc esi ; points to next byte
loop L1 ; continue loop
test al, 1
jnz L3 ; jumps to L3 if odd
L2:
mov eax, TRUE ; copies 1(true) to eax
jmp L4
L3:
mov eax, FALSE ; copies 0(false) to eax
L4:
ret
Parity_Check ENDP
在您的顯示過程中,您忘記了數組元素的真實大小。
改變這個
mov eax, [esi] ; Store array in eax
成
movzx eax, byte ptr [esi]
你正在使用一種將[esi]視為參考的符號,你可能想要做的是xor esi, 0
- 但即便如此,這樣的操作也沒有多大意義(esi將保持不變。)
如果您打算修改'esi'中值所標識的內存位置,您可能需要考慮在'xor'操作之前將其移入寄存器,因為我不相信xor對內存操作數進行操作(我可能會弄錯,它我已經有一段時間了。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.