Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .data
- prompt db "Please enter your name: ", 10
- length equ $ - prompt
- text times 255 db 0
- buffer times 255 db 0
- Enter your text
- section .text
- global main
- main:
- mov rax, 1
- mov rdi, 1
- mov rsi, prompt
- mov rdx, length
- syscall
- mov rax, 0
- mov rdi, 0
- mov rsi, text
- syscall
- mov rcx, rax ; rcx will be the character counter.
- mov rsi, text ; a pointer to the current character. Start from the beginning.
- add rsi, rcx
- dec rsi ; Remember the 0-index
- mov rdi, buffer
- ;; This subroutine is also SUB-optimal if your teacher demands
- ;; performance, look into the advantages of `lea` and a simple
- ;; rep;scas loop as well.
- process_loop:
- mov bl, [rsi] ; Now copy from back to front
- mov [rdi], bl
- inc rdi
- dec rsi
- dec rax
- jnz process_loop
- mov rax, 1 ; And print the string
- mov rdi, 1
- mov rsi, buffer
- mov rdx, rcx
- syscall
- exit:
- mov rax, 60
- mov rdi, 0
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement