Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- spaceFound:
- .byte 0
- .text
- .type transform, @function
- .global transform
- #rdi - string pointer
- #rsi - change
- #0 - no space
- #1 - space found
- transform:
- MOV %rdi, %rcx #beginning
- MOV %rdi, %rbx #second pointer
- loop:
- CMP $' ', (%rdi)
- JE space
- MOVB $0, spaceFound
- CMP $1, %rsi
- JE transformToUpperCase
- MOV (%rdi), %al
- MOV %al, (%rbx)
- afterSpace:
- INC %rdi
- CMP $0, (%rdi)
- JNE loop
- MOV %rcx, %rax
- RET
- space:
- CMP $0, spaceFound
- JE moveSpace
- JMP afterSpace
- moveSpace:
- MOV (%rdi), %al
- MOV %al, (%rbx)
- INC %rbx
- MOVB $1, spaceFound
- JMP afterSpace
- transformToUpperCase:
- MOV (%rdi), %al
- MOV %al, (%rbx)
- SUBL $'A', (%rax)
- INC %rbx
- JMP afterSpace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement