我正在开发一个项目,我目前在我的一行中遇到访问冲突。我想知道我是否可以对错在哪里得到第二个意见。这里是我的代码(注意,我在运行时出现错误,但它确实建):访问冲突MASM x86程序集
.data
BlueTextOnGray = blue + (lightGray * 16)
DefaultColor = lightGray + (black * 16)
arrayD SDWORD 12345678h,1A4B2000h,3434h,7AB9h
fib BYTE 1,2
BYTE NUMBER_FIBS_TO_COMPUTE dup(0)
prompt BYTE "Enter an ending integer: ",0
error BYTE "Invalid stopping point!
.code
main PROC
mov eax,BlueTextOnGray
call SetTextColor
call Clrscr ; Clear the screen
call Crlf ; New line
mov edx,OFFSET prompt
call WriteString
call ReadInt ; Input integer into EAX
call Crlf ; New line
lea esi, [fib+2]
mov cl, NUMBER_FIBS_TO_COMPUTE
@@:
mov al, [esi-2]
add al, [esi-1]
mov [esi], al ;<------------This is where the error occurs
inc esi
loop @B
; here print out the results or examine them with debugger
E1: call Crlf ; New line
call WaitMsg ; "Press any key..."
mov eax,DefaultColor
call SetTextColor
call Clrscr
exit
main ENDP
END main
有没有办法,我缺少的规则。我已经完成了我的研究,但似乎无法找到符合我的情况的答案。
任何帮助将是伟大的! (另外请注意,我没有这样做,所以可能会有其他错误。)
谢谢!
'fib'在哪里?还要注意'loop'使用'ecx'而不是'cl',所以你应该设置它的全部32位。 – Jester
@Jester 'fib'在'.data'字段中初始化。 我在原文中添加了以上内容 – LAMBY
当您的代码出错时,ESI有什么值? “fib”有多远? ECX里有什么,你为什么不读Jester评论的后半部分? –