Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- INCLUDE DMACRO.ASM
- .data
- arr dw 100 dup(0)
- col dw 0
- row dw 0
- positive_sum dw 10 dup(0)
- negative_sum dw 10 dup(0)
- diagonal dw 10 dup(0)
- diagonal_len dw 0
- is_symmetry dw 0
- new_arr dw 100 dup(0)
- max_neg_elem dw 0
- no_neg_elem_flag dw 0
- text_menu_task1 db "1) Show matrix$"
- text_menu_task2 db "2) Input matrix$"
- text_menu_task3 db "3) Transpose matrix$"
- text_menu_task4 db "4) Task A$"
- text_menu_task5 db "5) Task B$"
- text_menu_task6 db "6) Task C$"
- text_menu_task7 db "7) Exit$"
- text_task2_in_1 db "Enter row count: $"
- text_task2_in_2 db "Enter column count: $"
- text_menu_error db "Please enter a valid item number$"
- text_no_matrix_error db "ERROR: NO MARTRIX$"
- text_task4_num db "Enter number: $"
- text_task4_1 db "in row $"
- text_task4_2 db " number of elements, less than $"
- text_task4_3 db " is $"
- text_task5_num db "Enter index of col: $"
- text_task5_err db "index of col is out of range$"
- text_exit db "$"
- text_any_key db "$"
- endl db 13,10,"$"
- tab db 9,"$"
- from dw 0
- to dw 0
- sign dw 0
- .code
- start:
- mov ax, @data
- mov ds, ax
- jumps
- jmp _menu
- _menu_incorrect_input:
- mCLS
- Print text_menu_error
- Print endl
- jmp _menu_print_task
- _menu:
- mCLS
- _menu_print_task:
- Print text_menu_task1
- Print endl
- Print text_menu_task2
- Print endl
- Print text_menu_task3
- Print endl
- Print text_menu_task4
- Print endl
- Print text_menu_task5
- Print endl
- Print text_menu_task6
- Print endl
- Print text_menu_task7
- Print endl
- input_to_ax
- cmp ax, 1
- je _task1
- cmp ax, 2
- je _task2
- cmp ax, 3
- je _task3
- cmp ax, 4
- je _task4
- cmp ax, 5
- je _task5
- cmp ax, 6
- je _task6
- cmp ax, 7
- je _task7
- jmp _menu_incorrect_input
- _task1:
- mov ax, col
- cmp ax, 0
- jle _task1_err
- mov ax, row
- cmp ax, 0
- jle _task1_err
- mWriteMatrix arr, row, col
- Print text_any_key
- empy_input
- jmp _menu
- _task1_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task2:
- Print text_task2_in_1
- Print endl
- input_to_ax
- mov row, ax
- Print text_task2_in_2
- Print endl
- input_to_ax
- mov col, ax
- mov ax, col
- cmp ax, 0
- jle _task2_err
- mov ax, row
- cmp ax, 0
- jle _task2_err
- mReadMatrix arr, row, col
- jmp _menu
- _task2_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task3:
- mov ax, col
- cmp ax, 0
- jle _task3_err
- mov ax, row
- cmp ax, 0
- jle _task3_err
- mTransposeMatrix arr, row, col, new_arr
- mWriteMatrix new_arr, col, row
- Print text_any_key
- empy_input
- jmp _menu
- _task3_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task4:
- mov ax, col
- cmp ax, 0
- jle _task4_err
- mov ax, row
- cmp ax, 0
- jle _task4_err
- Print text_task4_num
- input_to_ax
- mov cx, ax
- mov di, 0
- jmp _loop_task4_row
- _loop_task4_row_inc:
- inc di
- _loop_task4_row:
- cmp di, row
- jge _loop_task4_row_end
- mov ax, di
- mov bx, col
- mul bx
- shl ax, 1
- mov bx, ax
- ;mov arr[bx], 0
- mov dx, 0
- mov si, 0
- jmp _loop_task4_col
- _loop_task4_col_inc:
- inc si
- add bx, 2
- _loop_task4_col:
- cmp si, col
- jge _loop_task4_col_end
- cmp arr[bx], cx
- jge _task4_skip_inc
- add dx, 1
- _task4_skip_inc:
- jmp _loop_task4_col_inc
- _loop_task4_col_end:
- Print text_task4_1
- mov ax, di
- inc ax
- print_number_word ax
- Print text_task4_2
- mov ax, cx
- print_number_word ax
- Print text_task4_3
- mov ax, dx
- print_number_word ax
- Print endl
- jmp _loop_task4_row_inc
- _loop_task4_row_end:
- empy_input
- jmp _menu
- _task4_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task5:
- mov ax, col
- cmp ax, 0
- jle _task5_err
- mov ax, row
- cmp ax, 0
- jle _task5_err
- Print text_task5_num
- input_to_ax
- cmp ax, 0
- jle _task5_err2
- cmp ax, col
- jg _task5_err2
- dec ax
- shl ax, 1
- mov bp, ax
- mov cx, 0
- jmp _loop_task5_row
- _loop_task5_row_inc:
- inc cx
- _loop_task5_row:
- cmp cx, row
- jge _loop_task5_row_end
- mov ax, col
- shl ax, 1
- mov si, bp
- mov di, bp
- add di, ax
- mov dx, 1
- jmp _loop_task5_col
- _loop_task5_col_inc:
- inc dx
- mov ax, col
- shl ax, 1
- add si, ax
- add di, ax
- _loop_task5_col:
- cmp dx, row
- jge _loop_task5_col_end
- mov ax, arr[si]
- cmp ax, arr[di]
- jle _task5_skip_swap
- mov ax, arr[di]
- push ax
- mov ax, arr[si]
- mov arr[di], ax
- pop ax
- mov arr[si], ax
- _task5_skip_swap:
- jmp _loop_task5_col_inc
- _loop_task5_col_end:
- jmp _loop_task5_row_inc
- _loop_task5_row_end:
- jmp _menu
- _task5_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task5_err2:
- Print text_task5_err
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task6:
- mov ax, col
- cmp ax, 0
- jle _task6_err
- mov ax, row
- cmp ax, 0
- jle _task6_err
- mov ax, row
- mov bx, col
- mul bx
- mov cx, ax
- shl cx, 1
- mov si, 0
- jmp _loop_task6_row
- _loop_task6_row_inc:
- add si, 2
- _loop_task6_row:
- cmp si, cx
- jge _loop_task6_row_end
- mov ax, arr[si]
- cmp ax, 0
- jge _task6_skip
- mov bx, ax
- mul bx
- mov arr[si], ax
- _task6_skip:
- jmp _loop_task6_row_inc
- _loop_task6_row_end:
- jmp _menu
- _task6_err:
- Print text_no_matrix_error
- Print endl
- Print text_any_key
- empy_input
- jmp _menu
- _task7:
- Print text_exit
- Print endl
- nojumps
- mov ax, 4c00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement