Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'emu8086.inc'
- org 100h
- main:
- call pthis
- db 'enter the first matrix row by row, and the second matrix column by column: ', 10, 13, 0
- lea si, l1
- call print_string
- lea si, l2
- call print_string
- lea si, l3
- call print_string
- lea si, l4
- call print_string
- lea si, l5
- call print_string
- lea si, l6
- call print_string
- lea si, l7
- call print_string
- lea di, arrayA
- ; first matrix first row
- gotoxy 1, 2
- call scan_num
- mov [di], cl
- inc di
- gotoxy 8, 2
- call scan_num
- mov [di], cl
- inc di
- gotoxy 16, 2
- call scan_num
- mov [di], cl
- inc di
- ; first matrix second row
- gotoxy 1, 4
- call scan_num
- mov [di], cl
- inc di
- gotoxy 8, 4
- call scan_num
- mov [di], cl
- inc di
- gotoxy 16, 4
- call scan_num
- mov [di], cl
- inc di
- ; first matrix third row
- gotoxy 1, 6
- call scan_num
- mov [di], cl
- inc di
- gotoxy 8, 6
- call scan_num
- mov [di], cl
- inc di
- gotoxy 16, 6
- call scan_num
- mov [di], cl
- inc di
- ; second matrix first column
- gotoxy 26, 2
- call scan_num
- mov [di], cl
- inc di
- gotoxy 26, 4
- call scan_num
- mov [di], cl
- inc di
- gotoxy 26, 6
- call scan_num
- mov [di], cl
- inc di
- ; second matrix second column
- gotoxy 32, 2
- call scan_num
- mov [di], cl
- inc di
- gotoxy 32, 4
- call scan_num
- mov [di], cl
- inc di
- gotoxy 32, 6
- call scan_num
- mov [di], cl
- inc di
- ; second matrix third column
- gotoxy 40, 2
- call scan_num
- mov [di], cl
- inc di
- gotoxy 40, 4
- call scan_num
- mov [di], cl
- inc di
- gotoxy 40, 6
- call scan_num
- mov [di], cl
- inc di
- pause
- menu:
- call clear_screen
- call pthis
- db 'Select one option from below: ', 10, 13, 0
- call pthis
- db 9, '1- Dot Product.', 10, 13, 0
- call pthis
- db 9, '2- Transpose Matrix A.', 10, 13, 0
- call pthis
- db 9, '3- Transpose Matrix B.', 0
- inf:
- call pthis
- db 10, 13, 'What is your selection: ', 0
- call scan_num
- ; mov ax, cx
- ; cmp ax, 1
- ; jne nxt1
- ; call CrossProduct
- pause
- ;nxt1:
- cmp ax, 1
- jne nxt2
- call DotProduct
- lea si, DotArray
- call put_num
- pause
- nxt2: cmp ax, 2
- jne nxt3
- lea si, ArrayA
- lea bx, PosA
- lea di, TransposeA
- call Transpose
- lea si, TransposeA
- call put_num
- pause
- nxt3: cmp ax, 3
- jne nxt4
- lea si, ArrayB
- lea bx, PosB
- lea di, TransposeB
- call Transpose
- lea si, TransposeB
- call put_num
- pause
- nxt4: jne menu
- crossProduct proc
- call clear_screen
- ; implement crossProduct
- crossProduct endp
- DotProduct proc
- call clear_screen
- ; start Dot product
- push ax
- push bx
- push cx
- push si
- push di
- lea si, ArrayA
- lea bx, ArrayB
- lea di, DotArray
- mov cx, 3
- col:
- push bx
- push cx
- mov cx, 3
- row:
- push cx
- push si
- mov cx, 3
- rowxcol:
- mov al, [si]
- imul [bx]
- add [di], al
- inc si
- inc bx
- loop rowxcol
- pop si
- pop cx
- inc di
- loop row
- add si, 3
- pop cx
- pop bx
- loop col
- pop di
- pop si
- pop cx
- pop bx
- pop ax
- call put_num
- DotProduct endp
- Transpose proc
- ; load into si array
- ; load into bx pos
- ; load into di trans
- push si
- push bx
- push di
- lea si , arraya
- lea di, aux
- nextt:
- mov al, b.[si]
- mov [di], al
- add di, 2
- inc si
- loop nextt
- mov cx, 9
- rot:
- push di
- add di, [bx]
- mov al, [si]
- mov [di], al
- pop di
- add si, 2
- add bx, 2
- loop rot
- Transpose endp
- ret
- PUT_NUM proc
- ; load the desierd matrix into si
- call pthis
- db 218, 9, 9, 9, 191, 13, 10, 179, 0
- printRow
- call pthis
- db 179, 13, 10, 0
- call pthis
- db 179, 9, 9, 9, 179, 10, 13, 179, 0
- printRow
- call pthis
- db 179, 13, 10, 0
- call pthis
- db 179, 9, 9, 9, 179, 10, 13, 179, 0
- printRow
- call pthis
- db 10, 13, 192, 9, 9, 9, 217, 10, 13 ,0
- PUT_NUM endp
- pause macro
- push ax
- gotoxy 0, 9
- call pthis
- db 'Press any key to continue . . . ', 0
- mov ax, 0800h
- int 21h
- call clear_screen
- pop ax
- endm
- printRow macro
- local row
- mov cx, 3
- row:
- mov al, b.[si]
- call print_num
- putc 9
- inc si
- loop row
- endm
- ret
- arrayA db 9 dup(?)
- arrayB db 9 dup(?)
- DotArray db 9 dup(?)
- CrossArray db 9 dup(?)
- TransposeA db 9 dup(?)
- TransposeB db 9 dup(?)
- AUX dw 9 dup(?)
- POSA dw 0, 6, 12, 2, 8, 14, 4, 10, 16
- POSB dw 0, 2, 4, 6, 8, 10, 12, 14, 16
- l1 db 218, 9, 9, 9, 191,218, 9, 9, 9, 191, 13, 10, 0
- l2 db 179, 177, 9, 177, 9, 177, 9, 179, 179, 177, 9, 177, 9, 177, 9, 179, 13, 10, 0
- l3 db 179, 9, 9, 9, 179, 179, 9, 9, 9, 179, 13, 10, 0
- l4 db 179, 177, 9, 177, 9, 177, 9, 179, 179, 177, 9, 177, 9, 177, 9, 179, 13, 10, 0
- l5 db 179, 9, 9, 9, 179, 179, 9, 9, 9, 179, 13, 10, 0
- l6 db 179, 177, 9, 177, 9, 177, 9, 179, 179, 177, 9, 177, 9, 177, 9, 179, 13, 10, 0
- l7 db 192, 9, 9, 9, 217, 192, 9, 9, 9, 217, 13, 10, 0
- define_print_string
- define_pthis
- define_print_num
- define_print_num_uns
- define_scan_num
- define_get_string
- define_clear_screen
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement