I wonder how do I have to pass pointer argument to procedure?
I have to create function who have 2 arguments:
- words array
- array's size
The function gets array that the array's size and sum the column.
That's what I've coded:
.MODEL Small
.STACK 64
; +===============================+
; | DATA |
; +===============================+
.DATA
array1 dw 1,2,3,4
array1size dw 4
result dw ?
address dw ?
; print
TMP dw 0 ; general temporary variable ..
.code
addNumbers proc
; reset result
lea di,result
; use stack
mov bp,sp
; get num array
mov bx,[bp+2]
; get num of numbers
mov cx,[bp+4]
; making additiontion
adding:
add [di],bx
inc bx; go to the next bx
loop adding
ret 2
endp
; start
start:
mov ax,@DATA
mov ds,ax
; set strings
push array1size
push offset array1
call addNumbers
; print
mov dx:ax,result
call printNumber
mov ah,4ch
mov al,0
int 21H
end start
the problem - it's adding to result the offset pointer (here is cs:0000,cs:0001,cs:0002,cs:0003) and not the offset value (here is: 1,2,3,4).
Because of this, result will be 6 and not 10.
could someone help me?