Advertisement
Shakken

Untitled

Jan 4th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 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. call readint
  78. mov word ptr matrix[di], ax
  79. add di, 2
  80. pop dx
  81. inc cx
  82. cmp cx, N
  83. jl input_loop
  84. xor cx, cx
  85. inc dx
  86. cmp dx, N
  87. jl input_loop
  88. xor ax, ax
  89. cont_summ:
  90. mov si, ax
  91. shl si, 1
  92. xor dx, dx
  93. cont_summ_2:
  94. add dx, word ptr matrix[si]
  95. add si, N*2
  96. cmp si, N*N*2
  97. jl cont_summ_2
  98. outint dx
  99. endl
  100.  
  101. inc ax
  102. cmp ax, N
  103. jl cont_summ
  104.  
  105. mov ax, 4C00h
  106. int 21h
  107. .data
  108. N equ 3
  109. matrix db N*N*2 dup(?)
  110. buf_str db 10 dup(?)
  111. str_1 db "Input matrix[$"
  112. str_2 db "][$"
  113. str_3 db "]:",10,13,"$"
  114. sum1 dw 0
  115. sum2 dw 0
  116. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement