Assembly 这些错误意味着什么?汇编语言
我不明白为什么我的XOR和masm.target(文件)会出现错误。XOR表示“指令操作数无效”,而masm.targets错误将我带到该文件Assembly 这些错误意味着什么?汇编语言,assembly,visual-studio-2013,masm,irvine32,Assembly,Visual Studio 2013,Masm,Irvine32,我不明白为什么我的XOR和masm.target(文件)会出现错误。XOR表示“指令操作数无效”,而masm.targets错误将我带到该文件 masm.targets是文件名,第50行第5列的错误代码是MSB3721(它再次将我带到另一个页面,因此我假设我的masm设置有问题?)。这两种方法都有帮助吗?您正在使用一种将[esi]作为参考的符号,您可能打算做的是xor esi,0——但即使如此,这样的操作也没有真正意义(esi将保持不变) 如果你想修改在ESI中的值所标识的内存位置,你可能会考虑
masm.targets是文件名,第50行第5列的错误代码是MSB3721(它再次将我带到另一个页面,因此我假设我的masm设置有问题?)。这两种方法都有帮助吗?您正在使用一种将[esi]作为参考的符号,您可能打算做的是
xor esi,0
——但即使如此,这样的操作也没有真正意义(esi将保持不变)
如果你想修改在ESI中的值所标识的内存位置,你可能会考虑在XOR操作之前将它移动到登记器中,因为我不相信XOR在内存操作数上操作(我可能是错误的,它已经有一段时间了)。
数组1字节1,0,1,0,0,0,1,0,0,1
数组2字节1,0,0,0,0,0,1,0,0,1
; 声明两个10位数组
; 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
MASM将抱怨不知道此异或操作的大小。只需像xor byte ptr[esi]那样编写它,0
xor [esi], 0 ; Xor data bits
这两个与奇偶校验相关的跳转都将基于ESI中地址递增的奇偶校验。它们不反映从测试数组中的字节中获得的任何奇偶校验值!
以下是一个例行程序:
jpe L2 ; jumps to L2 if even
jpo L3 ; jumps to L3 if odd
在显示过程中,您忘记了数组元素的实际大小。改变这个
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
进入
因为“操作数”是指指令输入,在您的例子中是“[esi]”和“0”,汇编程序告诉您其中一个对XOR指令无效。
mov eax, [esi] ; Store array in eax
movzx eax, byte ptr [esi]