如果跳得太远,检查和调试的最佳方法是什么?
所以我有一个var inBuffer
,其中BYTE
长度为115。
我将其移动到bufSize
并尝试对一组3个密钥进行xor'ing以解密消息。
我的代码编译但是我无法构建,除了这部分,它说我跳得太远了。
bufSize DWORD ?
mov eax,115
mov bufSize,eax
;-------------------------------------------------
AnalyzeBuffer PROC
;receives nothing
;returns nothing
;-------------------------------------------------
pushad ; pushes all data in this method into a stack
mov ecx,bufSize ; loop count
mov esi,0 ; start at index 0 in translated buffer
top:
cmp buffer[esi],20h ; checks if character is space which is ok
je yes
cmp buffer[esi],2ch ; checks if character is comma wich is okay
je yes
cmp buffer[esi],2eh ; checks if character is period which is okay
je yes
cmp buffer[esi],41h ; checks if character is above A in the ascii chart
jb no
;the following are all unacceptable characters
cmp buffer[esi],5bh ;checks if character is [
je no
cmp buffer[esi],5ch ; checks if character is \
je no
cmp buffer[esi],5dh ;checks if character is ]
je no
cmp buffer[esi],5eh ; checks if character is ^
je no
cmp buffer[esi],5fh ; checks if character is _
je no
cmp buffer[esi],60h ; checks if character is `
je no
cmp buffer[esi],7bh ; checks if characre is {
je no
cmp buffer[esi],7ch ; checks if character is |
je no
cmp buffer[esi],7dh ; checks if }
je no
cmp buffer[esi],7eh ; checks if ~
je no
cmp buffer[esi],7fh ; checks if
je no
yes:
inc esi ; going to next character
loop top
;getting to this step means these keys worked for all characters in buffer
mov edx,OFFSET goodMsg
call WriteString
call DisplayAllKeys ; shows 3 keys used
call Crlf
call Crlf
mov edx,OFFSET buffer ; displays decrypted message
call WriteString
call Crlf
call Crlf
no:
;the current character wasnt good so trying next key
popad
ret
AnalyzeBuffer ENDP
答案 0 :(得分:3)
下次你应该告诉哪一行导致错误。我猜它是loop
指令,因为它只存在8位偏移量。由于优化原因,建议不要使用它,这也将解决您的跳跃范围问题。因此,只需将其替换为dec ecx; jnz top
。
你也可以优化你的支票,但这是另一个故事。