gpt4 book ai didi

程序 RET 后程序集 x86 无限循环问题 MOV CX, 12

转载 作者:行者123 更新时间:2023-12-02 21:41:55 25 4
gpt4 key购买 nike

NUM EQU 3
.MODEL small
.STACK
.DATA
tempi DW 8,27,17,12,21,34,9,41,7,18,15,5
risultato DW NUM DUP (?)
.CODE
.STARTUP
PUSH OFFSET tempi
PUSH OFFSET risultato
CALL copiaVettore
ADD SP,4
MOV CX, 0
MOV CX,12
LEA BX, risultato
salta:
MOV DX, [BX]
ADD DX, 30h
ADD BX, 2
MOV AH, 2h
INT 21h
LOOP salta
.EXIT
copiaVettore PROC
PUSH BP
MOV BP, SP
PUSH DI
PUSH SI

MOV DI, [BP+4] ;risultato
MOV SI, [BP+6] ;sorgente
MOV CX, 12
ciclo1:
MOV AX, [SI]
MOV [DI], AX
ADD DI, 2
ADD SI, 2
LOOP ciclo1

POP SI
POP DI
POP BP
RET
copiaVettore ENDP
END

当过程 RET 结束时,调试器停止在 MOV CX, 12 上,并显示

unknown opcode skipped: 00 not 8086 instruction - not supported yet.

但是程序中的MOV CX, 12运行良好。

最佳答案

这是一个很好的破坏例子。大多数人都会破坏寄存器,而您却“破坏”了代码:)

NUM EQU 3          ; <-- here's the problem
.MODEL small
.STACK
.DATA
tempi DW 8,27,17,12,21,34,9,41,7,18,15,5 ; 12 words source
risultato DW NUM DUP (?) ; but only 3 words data

由于您只有 3 个单词的空间用于复制,因此后面的 9 个单词将覆盖代码,从而破坏 RET 返回的代码

.CODE
.STARTUP
PUSH OFFSET tempi ; 3 bytes 12,0,21
PUSH OFFSET risultato ; 3 bytes 0,34,0
CALL copiaVettore ; 3 bytes 9,0,14
ADD SP,4 ; <-- this is where the RET will return,
MOV CX, 0 ; but starting from here the code
MOV CX,12 ; is overwritten with 0,7,0,18 ...
LEA BX, risultato

所以您期望的代码不再存在。

关于程序 RET 后程序集 x86 无限循环问题 MOV CX, 12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51127666/

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