.model small
.stack 100h
.data
    a dw 1, 2, 3, 4, 5, 6, 7, 8, 9
    b dw 9, 8, 7, 6, 5, 4, 3, 2, 1
    c dw 0, 0, 0, 0, 0, 0, 0, 0, 0
    scalar dw 2
.code
    mov ax, @data
    mov ds, ax
    ; Matrix multiplication
    mov cx, 3 ; outer loop counter (rows of a)
    mov di, 0 ; index for a
    mov si, 0 ; index for b
multiply_loop:
    push cx ; save outer loop counter
    mov bx, 0 ; index for c
    mov dx, 0 ; inner loop counter
    inner_loop:
        mov ax, a[di]
        mov bx, b[si]
        mul bx
        add c[bx], ax
        add di, 2 ; move to next element in a
        add si, 2 ; move to next element in b
        inc dx ; increment inner loop counter
        cmp dx, 3 ; check if inner loop counter reached 3
        jl inner_loop ; if not, continue inner loop
    pop cx ; restore outer loop counter
    add di, 2 ; move to next row in a
    mov si, 0 ; reset index for b
    inc bx ; increment index for c
    cmp bx, 3 ; check if outer loop counter reached 3
    jl multiply_loop ; if not, continue outer loop
    ; Print the result of matrix multiplication
    mov ah, 2 ; print character function
    mov dl, 13 ; carriage return
    int 21h
    mov dl, 10 ; line feed
    int 21h
    mov cx, 9 ; total elements in c
    mov di, 0 ; index for c
print_loop:
    mov ax, c[di]
    add ax, 48 ; convert to ASCII
    mov dl, al ; move lower byte to dl
    mov ah, 2 ; print character function
    int 21h
    inc di ; move to next element in c
    loop print_loop ; continue printing until all elements are printed
    ; Multiply the result by the scalar
    mov cx, 9 ; total elements in c
    mov di, 0 ; index for c
    mov ax, scalar
multiply_scalar_loop:
    mul c[di]
    mov c[di], ax
    inc di ; move to next element in c
    loop multiply_scalar_loop ; continue multiplying until all elements are multiplied
    ; Print the result after scalar multiplication
    mov ah, 2 ; print character function
    mov dl, 13 ; carriage return
    int 21h
    mov dl, 10 ; line feed
    int 21h
    mov cx, 9 ; total elements in c
    mov di, 0 ; index for c
print_scalar_loop:
    mov ax, c[di]
    add ax, 48 ; convert to ASCII
    mov dl, al ; move lower byte to dl
    mov ah, 2 ; print character function
    int 21h
    inc di ; move to next element in c
    loop print_scalar_loop ; continue printing until all elements are printed
    mov ax, 4C00h ; exit program
    int 21h
end
Can someone help me with this code, it's printing some symbols and zeros when I run it. Where is the error?
I tried to multiply 2 matrices and to multiply result matrix with scalar and it's not printing good.
 
     
    
