Advertisement
DushesTV

Zadanie Tri

Jan 17th, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. %macro pushd 0
  2. push eax
  3. push ebx
  4. push ecx
  5. push edx
  6. %endmacro
  7.  
  8. %macro popd 0
  9. pop edx
  10. pop ecx
  11. pop ebx
  12. pop eax
  13. %endmacro
  14.  
  15. %macro print 2
  16. pushd
  17. mov edx, %1
  18. mov ecx, %2
  19. mov ebx, 1
  20. mov eax, 4
  21. int 0x80
  22. popd
  23. %endmacro
  24.  
  25. %macro dprint 0;
  26. pushd
  27. mov ecx, 10
  28. mov bx, 0
  29.  
  30. _divide:
  31. xor edx, edx
  32. div ecx
  33. push dx
  34. inc bx
  35. test eax, eax
  36. jnz _divide
  37.  
  38. _digit:
  39. pop ax
  40. add ax, '0'
  41. mov [reminder], ax
  42. print 1, reminder
  43. dec bx
  44. cmp bx, 0
  45. jg _digit
  46. popd
  47. %endmacro
  48.  
  49. %macro sqrt 1
  50. finit
  51. fild dword [%1]
  52. fsqrt
  53. fist dword [%1]
  54.  
  55. %endmacro
  56.  
  57. section .text
  58.  
  59. global _start
  60.  
  61. _start:
  62. mov ebx, 0
  63. mov ecx, 0
  64. mov eax, 0
  65. _for1:
  66. mov ecx, ebx
  67. add ecx, 4
  68. _for2:
  69. mov al, [x+ecx]
  70. mov dl, [x+ebx]
  71. sub al, dl
  72. imul al
  73. mov [res1], al
  74. mov al, 0
  75. mov dl, 0
  76. mov al, [y+ecx]
  77. mov dl, [y+ebx]
  78. sub al, dl
  79. imul al
  80. add al, [res1]
  81. mov [res1], al
  82. sqrt res1
  83. mov al,[res1]
  84. cmp al, [max]
  85. jg _max
  86. jmp _end
  87. _max:
  88. mov [max], al
  89. _end:
  90. add ecx, 4
  91. mov al, 0
  92. mov dl, 0
  93. cmp ecx, len
  94. jl _for2
  95.  
  96. add ebx,4
  97. cmp ebx, len
  98. jl _for1
  99.  
  100. mov eax, [max]
  101. dprint
  102. print nlen, newline
  103.  
  104. mov eax, 1
  105. int 0x80
  106. section .data
  107.  
  108. res1 dd 0
  109. max dd 0
  110. x dd 10, 1, 3, 4, 5, 5, 1
  111. y dd 2, 3, 5, 7, 10, 3, 2
  112. len equ $ - y
  113. newline db 0xA, 0xD
  114. nlen equ $ - newline
  115.  
  116. section .bss
  117. reminder resb 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement