xchg 2“指针”-功能组件8086

时间:2018-11-21 19:27:26

标签: function pointers stack x86-16 emu8086

我的任务是构建一个替换2个指针值的函数。

有我的代码:

org 100h
jmp main

toSwap1     db 'a'
toSwap2     db 'b'
result         dw ?
numToNeg    dw -9
string      db  'm', 'a', 'g', 's', 'h', 'i', 'm', 'i', 'm', 'v', 'e', 'n', 'e', 'h', 'e', 'n', 'i', 'm' ,0Dh,0Ah,'$'
array        db "0000", 0Dh,0Ah, 24h ; line feed   return   and  stop symbol 24h=$ (ASCII).
num1        dw 0xAC45
; There is some vars thats i need for other missions

main:

; Second function: should print b and a - MAIN CODE FOR FUNC ~
push offset toSwap1
push offset toSwap2
call xChange
mov al, toSwap1
call print_al_chr
PRINTN "and"
mov al, toSwap2
call print_al_chr

mov ah, 0
int 16h
ret

xChange proc ; THE FUNC ~
push bp
push ax
push bx
push cx
mov bp, sp

mov bx, [bp + 12]
mov al, [bx]
mov bx, [bp + 10]
mov cx, [bx]
mov [bx], ax
mov bx, [bp + 12]
mov [bx], cx

pop cx
pop bx
pop ax
pop bp
retn 4
xChange endp

现在的问题是第二个var的值(那应该在函数末尾打印'a'了)。 图片: enter image description here

0 个答案:

没有答案