Advertisement
Coriic

Untitled

Jun 27th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. .text
  2. .type capitalize, @function
  3. .global capitalize
  4.  
  5. #%rdi - string
  6.  
  7. capitalize:
  8. MOV %rdi, %rax
  9. XOR %r8, %r8
  10. MOV $1, %r8
  11. loop:
  12. CMPB $0, (%rdi)
  13. JE afterLoop
  14. CMP $1, %r8
  15. JE tryToSwap
  16. JMP checkIfDot
  17. afterSwap:
  18. INC %rdi
  19. JMP loop
  20. afterLoop:
  21. RET
  22.  
  23. tryToSwap:
  24. CMPB $'a', (%rdi)
  25. JL afterSwap
  26. CMPB $'z', (%rdi)
  27. JG afterSwap
  28. XOR %r9, %r9
  29. MOVB (%rdi), %r9b
  30. SUBB $32, %r9b
  31. MOVB %r9b, (%rdi)
  32. MOV $0, %r8
  33. JMP afterSwap
  34.  
  35. checkIfDot:
  36. CMPB $'.', (%rdi)
  37. JE oneToR8
  38. CMPB $'?', (%rdi)
  39. JE oneToR8
  40. CMPB $'!', (%rdi)
  41. JE oneToR8
  42. CMPB $10, (%rdi)
  43. JE oneToR8
  44.  
  45. JMP afterSwap
  46.  
  47. oneToR8:
  48. MOV $1, %r8
  49. JMP afterSwap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement