Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .type capitalize, @function
- .global capitalize
- #%rdi - string
- capitalize:
- MOV %rdi, %rax
- XOR %r8, %r8
- MOV $1, %r8
- loop:
- CMPB $0, (%rdi)
- JE afterLoop
- CMP $1, %r8
- JE tryToSwap
- JMP checkIfDot
- afterSwap:
- INC %rdi
- JMP loop
- afterLoop:
- RET
- tryToSwap:
- CMPB $'a', (%rdi)
- JL afterSwap
- CMPB $'z', (%rdi)
- JG afterSwap
- XOR %r9, %r9
- MOVB (%rdi), %r9b
- SUBB $32, %r9b
- MOVB %r9b, (%rdi)
- MOV $0, %r8
- JMP afterSwap
- checkIfDot:
- CMPB $'.', (%rdi)
- JE oneToR8
- CMPB $'?', (%rdi)
- JE oneToR8
- CMPB $'!', (%rdi)
- JE oneToR8
- CMPB $10, (%rdi)
- JE oneToR8
- JMP afterSwap
- oneToR8:
- MOV $1, %r8
- JMP afterSwap
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement