Advertisement
Coriic

Untitled

May 31st, 2017
96
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. spaceFound:
  3. .byte 0
  4.  
  5. .text
  6. .type transform, @function
  7. .global transform
  8.  
  9. #rdi - string pointer
  10. #rsi - change
  11.  
  12. #0 - no space
  13. #1 - space found
  14.  
  15. transform:
  16. MOV %rdi, %rcx #beginning
  17. MOV %rdi, %rbx #second pointer
  18. loop:
  19. CMP $' ', (%rdi)
  20. JE space
  21. MOVB $0, spaceFound
  22. CMP $1, %rsi
  23. JE transformToUpperCase
  24. MOV (%rdi), %al
  25. MOV %al, (%rbx)
  26. afterSpace:
  27. INC %rdi
  28. CMP $0, (%rdi)
  29. JNE transform
  30. MOV %rcx, %rax
  31. RET
  32.  
  33. space:
  34. CMPB $0, spaceFound
  35. JE moveSpace
  36. JMP afterSpace
  37.  
  38. moveSpace:
  39. MOV (%rdi), %al
  40. MOV %al, (%rbx)
  41. INC %rbx
  42. MOVB $1, spaceFound
  43. JMP afterSpace
  44.  
  45. transformToUpperCase:
  46. CMPB $'a', (%rdi)
  47. JB afterSpace
  48. CMPB $'z', (%rdi)
  49. JA afterSpace
  50. MOV (%rdi), %al
  51. MOV %al, (%rbx)
  52. SUBL $'A', (%rax)
  53. INC %rbx
  54. JMP afterSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement