Advertisement
Coriic

Untitled

Jun 2nd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. .data
  2. count:
  3. .long 0
  4.  
  5. pos:
  6. .long 0
  7.  
  8. .text
  9. .type fun, @function
  10. .global fun
  11.  
  12.  
  13. #rdi - a
  14. #rsi - b
  15. #rdx - pcs
  16. #rcx - count
  17. fun:
  18. MOVB $0, %r10 #licznik petli
  19. CMPB $1, %rsi
  20. JE sum
  21. CMPB $2, %rsi
  22. JE mul
  23. loop2:
  24. JMP podst
  25. after_podst:
  26. CMPB $1, %rsi
  27. JE sum_op
  28. CMPB $2, %rsi
  29. JE mul_op
  30. after_op
  31. INC %r10
  32. CMPB $64, %r10
  33. JNE loop2
  34. CMPB $2, %rsi
  35. JE mul_op_2
  36. MOV %r9, %rsi
  37. RET
  38. MOV %rdi, %rbx
  39.  
  40. sum:
  41. MOVB $0, %r9 #suma
  42. mul:
  43. MOV $1, %eax #mnozenie
  44.  
  45. #mul_op:
  46. #MOV %r10, %r12
  47. #INC %r12
  48. #IMUL %r12
  49.  
  50. sum_op:
  51. ADD (%rbx), %r9
  52. INC %rbx
  53. JMP after_op
  54.  
  55. mul_op_2:
  56. MOV %eax, %r9
  57.  
  58. not_zero_bit
  59. MOV count, %r11
  60. INC %r11
  61. MOV %r11, count
  62. MOV %r10, pos
  63. JMP after_podst
  64.  
  65. podst:
  66. CMPB $1, (%rbx)
  67. JE not_zero_bit
  68. JMP after_podst
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement