在8086中将参数发送到proc

时间:2015-01-14 13:23:31

标签: assembly x86 x86-16

我想在程序集8086中编写一个子程序,它将两个数组作为参数。 我该怎么做? 这是我的代码,直到现在:

mov dl,[arr1]
mov dh, [arr2]
call adding

这是我的子程序:

adding proc
    push ax
    push bx
    push cx


    mov [arrx],dl
    mov [arry],dh
       mov     cx, duplen 
       mov  bx, cx  ; point to lest significant digit!
       dec bx
    next_digit:

        ; add digits:
        mov     al, arrx[bx]
        adc     al, arry[bx]

        ; this is a very useful instruction that
        ; adjusts the value of addition
        ; to be string compatible
        aaa
        mov     sum[bx], al
        dec     bx
       loop    next_digit

    pop cx
    pop bx
    pop ax


    ret

它出了什么问题?

1 个答案:

答案 0 :(得分:0)

而不是

mov dl,[arr1]
mov dh, [arr2]
call adding

使用类似

的内容
mov si,arr1
mov di,arr2
call adding

在子程序中

clc           ;You forgot this !!!
next_digit:
; add digits:
mov al,[si+bx]
adc al,[di+bx]
aaa
mov sum[bx],al
dec bx
loop next_digit