Advertisement
qberik

Untitled

Feb 21st, 2023
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. .model small
  2. .stack 100h
  3.  
  4. INCLUDE DMACRO.ASM
  5.  
  6.  
  7.  
  8. .data
  9. arr dw 100 dup(0)
  10. col dw 0
  11. row dw 0
  12. positive_sum dw 10 dup(0)
  13. negative_sum dw 10 dup(0)
  14. diagonal dw 10 dup(0)
  15. diagonal_len dw 0
  16. is_symmetry dw 0
  17. new_arr dw 100 dup(0)
  18. max_neg_elem dw 0
  19. no_neg_elem_flag dw 0
  20. text_menu_task1 db "1) Show matrix$"
  21. text_menu_task2 db "2) Input matrix$"
  22. text_menu_task3 db "3) Transpose matrix$"
  23. text_menu_task4 db "4) Task A$"
  24. text_menu_task5 db "5) Task B$"
  25. text_menu_task6 db "6) Task C$"
  26. text_menu_task7 db "7) Exit$"
  27. text_task2_in_1 db "Enter row count: $"
  28. text_task2_in_2 db "Enter column count: $"
  29. text_menu_error db "Please enter a valid item number$"
  30. text_no_matrix_error db "ERROR: NO MARTRIX$"
  31.  
  32. text_task4_num db "Enter number: $"
  33.  
  34. text_task4_1 db "in row $"
  35. text_task4_2 db " number of elements, less than $"
  36. text_task4_3 db " is $"
  37.  
  38.  
  39. text_task5_num db "Enter index of col: $"
  40. text_task5_err db "index of col is out of range$"
  41.  
  42. text_exit db "$"
  43. text_any_key db "$"
  44. endl db 13,10,"$"
  45. tab db 9,"$"
  46. from dw 0
  47. to dw 0
  48. sign dw 0
  49. .code
  50. start:
  51. mov ax, @data
  52. mov ds, ax
  53. jumps
  54. jmp _menu
  55. _menu_incorrect_input:
  56. mCLS
  57. Print text_menu_error
  58. Print endl
  59. jmp _menu_print_task
  60. _menu:
  61. mCLS
  62. _menu_print_task:
  63. Print text_menu_task1
  64. Print endl
  65. Print text_menu_task2
  66. Print endl
  67. Print text_menu_task3
  68. Print endl
  69. Print text_menu_task4
  70. Print endl
  71. Print text_menu_task5
  72. Print endl
  73. Print text_menu_task6
  74. Print endl
  75. Print text_menu_task7
  76. Print endl
  77. input_to_ax
  78. cmp ax, 1
  79. je _task1
  80. cmp ax, 2
  81. je _task2
  82. cmp ax, 3
  83. je _task3
  84. cmp ax, 4
  85. je _task4
  86. cmp ax, 5
  87. je _task5
  88. cmp ax, 6
  89. je _task6
  90. cmp ax, 7
  91. je _task7
  92. jmp _menu_incorrect_input
  93. _task1:
  94. mov ax, col
  95. cmp ax, 0
  96. jle _task1_err
  97. mov ax, row
  98. cmp ax, 0
  99. jle _task1_err
  100. mWriteMatrix arr, row, col
  101. Print text_any_key
  102. empy_input
  103. jmp _menu
  104. _task1_err:
  105. Print text_no_matrix_error
  106. Print endl
  107. Print text_any_key
  108. empy_input
  109. jmp _menu
  110. _task2:
  111. Print text_task2_in_1
  112. Print endl
  113. input_to_ax
  114. mov row, ax
  115. Print text_task2_in_2
  116. Print endl
  117. input_to_ax
  118. mov col, ax
  119. mov ax, col
  120. cmp ax, 0
  121. jle _task2_err
  122. mov ax, row
  123. cmp ax, 0
  124. jle _task2_err
  125. mReadMatrix arr, row, col
  126. jmp _menu
  127. _task2_err:
  128. Print text_no_matrix_error
  129. Print endl
  130. Print text_any_key
  131. empy_input
  132. jmp _menu
  133. _task3:
  134. mov ax, col
  135. cmp ax, 0
  136. jle _task3_err
  137. mov ax, row
  138. cmp ax, 0
  139. jle _task3_err
  140. mTransposeMatrix arr, row, col, new_arr
  141. mWriteMatrix new_arr, col, row
  142. Print text_any_key
  143. empy_input
  144. jmp _menu
  145. _task3_err:
  146. Print text_no_matrix_error
  147. Print endl
  148. Print text_any_key
  149. empy_input
  150. jmp _menu
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. _task4:
  159. mov ax, col
  160. cmp ax, 0
  161. jle _task4_err
  162. mov ax, row
  163. cmp ax, 0
  164. jle _task4_err
  165.  
  166.  
  167. Print text_task4_num
  168. input_to_ax
  169. mov cx, ax
  170.  
  171. mov di, 0
  172. jmp _loop_task4_row
  173. _loop_task4_row_inc:
  174. inc di
  175. _loop_task4_row:
  176. cmp di, row
  177. jge _loop_task4_row_end
  178.  
  179. mov ax, di
  180. mov bx, col
  181. mul bx
  182. shl ax, 1
  183. mov bx, ax
  184. ;mov arr[bx], 0
  185. mov dx, 0
  186. mov si, 0
  187. jmp _loop_task4_col
  188. _loop_task4_col_inc:
  189. inc si
  190. add bx, 2
  191. _loop_task4_col:
  192. cmp si, col
  193. jge _loop_task4_col_end
  194.  
  195. cmp arr[bx], cx
  196. jge _task4_skip_inc
  197. add dx, 1
  198. _task4_skip_inc:
  199.  
  200. jmp _loop_task4_col_inc
  201. _loop_task4_col_end:
  202.  
  203.  
  204. Print text_task4_1
  205. mov ax, di
  206. inc ax
  207. print_number_word ax
  208. Print text_task4_2
  209. mov ax, cx
  210. print_number_word ax
  211. Print text_task4_3
  212. mov ax, dx
  213. print_number_word ax
  214. Print endl
  215.  
  216.  
  217. jmp _loop_task4_row_inc
  218. _loop_task4_row_end:
  219.  
  220.  
  221.  
  222.  
  223.  
  224. empy_input
  225. jmp _menu
  226. _task4_err:
  227. Print text_no_matrix_error
  228. Print endl
  229. Print text_any_key
  230. empy_input
  231. jmp _menu
  232.  
  233. _task5:
  234. mov ax, col
  235. cmp ax, 0
  236. jle _task5_err
  237. mov ax, row
  238. cmp ax, 0
  239. jle _task5_err
  240.  
  241. Print text_task5_num
  242. input_to_ax
  243. cmp ax, 0
  244. jle _task5_err2
  245. cmp ax, col
  246. jg _task5_err2
  247. dec ax
  248. shl ax, 1
  249. mov bp, ax
  250.  
  251.  
  252.  
  253. mov cx, 0
  254. jmp _loop_task5_row
  255. _loop_task5_row_inc:
  256. inc cx
  257. _loop_task5_row:
  258. cmp cx, row
  259. jge _loop_task5_row_end
  260.  
  261.  
  262. mov ax, col
  263. shl ax, 1
  264. mov si, bp
  265. mov di, bp
  266. add di, ax
  267.  
  268. mov dx, 1
  269. jmp _loop_task5_col
  270. _loop_task5_col_inc:
  271. inc dx
  272. mov ax, col
  273. shl ax, 1
  274. add si, ax
  275. add di, ax
  276. _loop_task5_col:
  277. cmp dx, row
  278. jge _loop_task5_col_end
  279.  
  280. mov ax, arr[si]
  281. cmp ax, arr[di]
  282. jle _task5_skip_swap
  283. mov ax, arr[di]
  284. push ax
  285. mov ax, arr[si]
  286. mov arr[di], ax
  287. pop ax
  288. mov arr[si], ax
  289. _task5_skip_swap:
  290.  
  291. jmp _loop_task5_col_inc
  292. _loop_task5_col_end:
  293.  
  294. jmp _loop_task5_row_inc
  295. _loop_task5_row_end:
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. jmp _menu
  306. _task5_err:
  307. Print text_no_matrix_error
  308. Print endl
  309. Print text_any_key
  310. empy_input
  311. jmp _menu
  312.  
  313. _task5_err2:
  314. Print text_task5_err
  315. Print endl
  316. Print text_any_key
  317. empy_input
  318. jmp _menu
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. _task6:
  330. mov ax, col
  331. cmp ax, 0
  332. jle _task6_err
  333. mov ax, row
  334. cmp ax, 0
  335. jle _task6_err
  336.  
  337.  
  338. mov ax, row
  339. mov bx, col
  340. mul bx
  341.  
  342.  
  343. mov cx, ax
  344. shl cx, 1
  345. mov si, 0
  346. jmp _loop_task6_row
  347. _loop_task6_row_inc:
  348. add si, 2
  349. _loop_task6_row:
  350. cmp si, cx
  351. jge _loop_task6_row_end
  352.  
  353. mov ax, arr[si]
  354. cmp ax, 0
  355. jge _task6_skip
  356. mov bx, ax
  357. mul bx
  358. mov arr[si], ax
  359. _task6_skip:
  360. jmp _loop_task6_row_inc
  361. _loop_task6_row_end:
  362.  
  363.  
  364. jmp _menu
  365. _task6_err:
  366. Print text_no_matrix_error
  367. Print endl
  368. Print text_any_key
  369. empy_input
  370. jmp _menu
  371.  
  372.  
  373.  
  374. _task7:
  375. Print text_exit
  376. Print endl
  377. nojumps
  378. mov ax, 4c00h
  379. int 21h
  380. end start
  381.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement