name "mycode"   ; output file name (max 8 chars for DOS compatibility)

org  100h	; set location counter to 100h


    ;call somme_tab
    ;push 5
    ;call carree
    ;mov dx, ax
    ;add dx, 30h
    ;mov ah, 2
    ;int 21h
    ;call affiche_tab
    call carree_tab
    
    
    
    
    
    hlt
    ret

msg         db "press any key..."
msg_size =  $ - offset msg

somme proc
    
    push bp
    mov bp, sp
    mov ax, s
    add ax, [bp+4]
    mov s, ax
    pop bp
    ret 2 
somme endp 


carree proc
    
    push bp
    mov bp, sp
    mov ax, [bp+4]
    mul ax

    pop bp

    ret 2
     
carree endp

somme_tab proc
    
    mov si, 0
    mov cx, 10
    
    mov dx, 0    ;contient la somme  
    
boucle:
    push tab[si]
    call somme
    inc si
    loop boucle
    mov ax, s
    mov bx, 10
    div bx
    mov d, ah
    ret 2 
    
somme_tab endp 

carree_tab proc
    
    mov si, 0
    mov cx, 10
    
    mov dx, 0    ;contient la somme  
    
boucle2:
    push tab[si]
    call carree
    mov tab[si],ax
    
    mov dx, tab[si]
    mov ah, 2
    int 21h 
    
    inc si
    loop boucle2
    
    ret 2 
    
carree_tab endp


affiche_tab proc
       
    mov si, 0
    mov cx, 10
    
boucle3:
   
    mov dx, tab[si]
    mov ah, 2
    int 21h
    inc si
    loop boucle3
    ret
    
affiche_tab endp    
    

tab db 4, 5, 7, 9, 2, 6, 0, 0, 4, 3 
tabsize db 10
s db 0
d db ?