Advertisement
pasholnahuy

Untitled

Oct 7th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.12 KB | None | 0 0
  1. 1 .global supersum
  2. 2
  3. 3 supersum:
  4. 4 xor %edx, %edx // буфер для промежуточной суммы
  5. 5 cmp %esi, %edi
  6. 6 jle swap
  7. 7 push %ebx
  8. 8 mov $-1, %ebx
  9. 9 jmp put
  10. 10
  11. 11 put:
  12. 12 xor %edx, %edx
  13. 13 inc %ebx
  14. 14 cmp %ebx, %esi
  15. 15 jle loop
  16. 16 movb (%eax, %ebx, 1), %dl
  17. 17 movb %dl, (%ecx, %ebx, 1)
  18. 18 jmp loop
  19. 19
  20. 20 loop:
  21. 21 inc %eax
  22. 22 cmp %eax, %edi
  23. 23 jg add_remain
  24. 24 addw (%ecx, %eax, 1), %dx
  25. 25 addw (%ebx, %eax, 1), %dx
  26. 26 mov %dl, (%ecx, %eax, 1)
  27. 27 mov %dh, %dl
  28. 28 xor %dh, %dh
  29. 29 jmp loop
  30. 30
  31. 31 swap:
  32. 32 xchg %eax, %ebx
  33. 33 xchg %esi, %edi
  34. 34 jmp supersum
  35. 35
  36. 36 add_remain:
  37. 37 addw (%ecx, %eax, 1), %dx
  38. 38 mov %dl, (%ecx, %eax, 1)
  39. 39 mov %dh, %dl
  40. 40 xor %dh, %dh
  41. 41 cmp $0, %dl
  42. 42 jnz loop
  43. 43
  44. 44 call_ret:
  45. 45 mov (%esp), %ebx
  46. 46 ret
  47. 47
  48.  
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement