【发布时间】:2021-04-27 18:43:37
【问题描述】:
.586 ;Target processor. Use instructions for Pentium class machines
.MODEL FLAT, C ;Use the flat memory model. Use C calling conventions
.CODE ;Indicates the start of the code segment.
PUBLIC binarize
binarize PROC
push ebp
mov ebp,esp
;-------Variaveis----------
mov eax ,0; Counter
mov ebx, [ebp+8]; Limite
mov ecx, [ebp+12];ArrayChars
mov edx, [ebp+18];Tamanho
mov edi, 0
;--------------------------
LoopVer:
cmp [ecx+eax], ebx
jle elseloop
mov edi, 0
mov [ecx+eax], edi
jmp end_if
elseloop:
mov edi, 255
mov [ecx+eax], edi
end_if:
inc eax
cmp eax, edx
jne LoopVer
pop ebp
ret
binarize ENDP
END
}
在行中的表达式中出现语法错误 mov [ecx+eax], edi
我制作了一个 unsigned char 数组、一个 unsigned char 和一个要循环的整数。 我尝试将十六进制的 0 移动到 edi,将十六进制的 255 移动到 edi,仍然是同样的错误
【问题讨论】:
-
语法错误或运行时错误?如果 ecx 在某种程度上是一个坏指针,我会在运行时看到异常。如果
cmp/mov [ecx+eax]指向只读的内存部分(如果 ArrayChars 是常量),我可以看到您在mov指令上遇到异常。 -
据我所知没有语法错误。嗯,
}很奇怪,但 MASM 似乎忽略了它,因为它出现在END之后。