Advertisement
Shakken

Untitled

Jan 4th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. .model small
  2. .stack 300h
  3. .code
  4. endl macro
  5. push ax dx
  6. mov ah, 02h
  7. mov dl, 0Ah
  8. int 21h
  9. mov dl, 0Dh
  10. int 21h
  11. pop dx ax
  12. endm
  13. outint macro value
  14. local outint_l1, outint_l2
  15. push ax bx cx dx
  16. mov ax, value
  17. mov bx, 10
  18. xor cx, cx
  19. outint_l1:
  20. xor dx, dx
  21. div bx
  22. push dx
  23. inc cx
  24. cmp ax, 0
  25. jne outint_l1
  26. mov ah, 02h
  27. outint_l2:
  28. pop dx
  29. add dl, '0'
  30. int 21h
  31. loop outint_l2
  32. pop dx cx bx ax
  33. endm
  34. proc readint
  35. push cx si bx dx
  36. mov [buf_str], 8
  37. mov ah, 0Ah
  38. lea dx, buf_str
  39. int 21h
  40. xor cx, cx
  41. mov si, 2
  42. xor ax, ax
  43. mov bx, 10
  44. in_loop:
  45. mul bx
  46. mov dl, [buf_str+si]
  47. sub dl, '0'
  48. add ax, dx
  49. inc si
  50. inc cl
  51. cmp cl, [buf_str+1]
  52. jl in_loop
  53. pop dx bx si cx
  54. endl
  55. ret
  56. endp
  57. start:
  58. mov ax, @data
  59. mov ds, ax
  60.  
  61. xor cx, cx
  62. xor dx, dx
  63. xor di, di
  64. input_loop:
  65. push dx
  66. mov ah, 09h
  67. lea dx, str_1
  68. int 21h
  69. outint cx
  70. lea dx, str_2
  71. int 21h
  72. mov si, sp
  73. mov dx, [ss:si]
  74. outint dx
  75. lea dx, str_3
  76. int 21h
  77.  
  78. call readint
  79. mov word ptr matrix[di], ax
  80. add di, 2
  81. pop dx
  82. inc cx
  83. cmp cx, N
  84. jl input_loop
  85. xor cx, cx
  86. inc dx
  87. cmp dx, N
  88. jl input_loop
  89. xor si, si
  90. xor ax, ax
  91. count_sum1:
  92. add ax, word ptr matrix[si]
  93. add si, N*2+2
  94. cmp si, N*N*2
  95. jl count_sum1
  96. mov sum1, ax
  97. mov si, N*2-2
  98. xor ax, ax
  99. count_sum2:
  100. add ax, word ptr matrix[si]
  101. add si, N*2-2
  102. cmp si, N*(N-1)*2+2
  103. jl count_sum2
  104. mov sum2, ax
  105. mov ah, 09h
  106. lea dx, str_4
  107. int 21h
  108. outint sum1
  109. lea dx, str_5
  110. int 21h
  111. outint sum2
  112. lea dx, str_6
  113. int 21h
  114. mov ax, 4C00h
  115. int 21h
  116. .data
  117. N equ 3
  118. matrix db N*N*2 dup(?)
  119. buf_str db 10 dup(?)
  120. str_1 db "Input matrix[$"
  121. str_2 db "][$"
  122. str_3 db "]:",10,13,"$"
  123. str_4 db "Sum1=$"
  124. str_5 db 10,13,"Sum2=$"
  125. str_6 db 10,13,"$"
  126. sum1 dw 0
  127. sum2 dw 0
  128. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement