gpt4 book ai didi

assembly - 在 Irvine32 中使用像 foo[si] 这样的 16 位地址(在 32 位模式下)?

转载 作者:行者123 更新时间:2023-12-02 01:51:52 24 4
gpt4 key购买 nike

由于某种原因,当我调试时它停在 mov al,data1[si] 并给了我一个异常

Exception thrown at 0x00D53668 in Week 5.exe: 0xC0000005: Access violation reading location 0x01AA6000.

请问原因是什么?

INCLUDE Irvine32.inc

.data

data1 byte "MILK",0
data2 byte 4 dup('*'),0


.code
main proc

mov CX,4
mov si,0


l1:
mov al,data1[si] <<EXCEPTION THROWN AT THIS LINE>>

mov data2[si],al

inc si ; before go in the loop l1, cx will auto deduct by 1, then cx==0?

loop l1

mov EDX, offset data2
call WriteString

exit
main endp
end main

最佳答案

您已标记您的问题这表明您正在使用 32 位指令,但正在尝试使用 16 位索引寄存器(=SI)

mov al,data1[si]

这(几乎)肯定会失败。使用(并之前设置)像 ESI 这样的 32 位寄存器来代替:

mov al, byte ptr data1[esi]

如果您正在编写 32 位代码,则通常应该在正常程序流程中使用 32 位寄存器。而 16 位仅在罕见的、经过深思熟虑的场合使用。

关于assembly - 在 Irvine32 中使用像 foo[si] 这样的 16 位地址(在 32 位模式下)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70149479/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com