【发布时间】:2022-12-22 01:26:20
【问题描述】:
我想在另一个过程中调用一个过程。之前必须从内部推送 proc,内部 proc 已 ret 4。当我运行它时,我的计算机停止工作有没有办法做到这一点?也许添加另一个流行音乐?我想要改变颜色的值。
proc borders ;the out proc , before calling I pushed offset head
push bp
mov bp,sp
push ax dx di si
mov di, [bp+4] ; offset of head
mov si, [di] ; value of head
sub si, 158
push offset color
call random ; the in proc
mov [di], si
pop si di dx ax bp
ret 4
endp borders
proc random ;before used I pushed offset color
push bp
mov bp,sp
push ax bx dx
push ds
xor dx, dx ; The word-sized `DIV` division requires initiating
mov ds, dx
mov ax, [046Ch] ; read timer counter
pop ds
xor ax, [cs:bx] ; XOR counter and a WORD from memory
mov bx, 2000 ; limit : 0-3998
div bx ; DX:AX / BX -> Remainder in DX is [0,1999]
shl dx, 1
mov bx, [bp+4] ; changes the value of food/color depend on use.
mov [bx], dx
pop dx bx ax bp
ret 4
endp random
【问题讨论】:
-
由于您只传递了 1 个参数,
random应该以ret 2结尾。你没有展示它所以无法判断是否是这种情况。 -
另外这个函数似乎只使用 1 个参数,那么为什么它最后有
ret 4? -
回复:你的标题,你当然可以在 proc 中推送和调用,如果你做对了,然后正确地恢复堆栈。如果不能使用,这些说明将毫无用处。
标签: assembly x86-16 callstack stack-memory