Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .data
- msg times 64 db 0
- max equ 64
- section .text
- global _start
- _start:
- Read
- mov rdx,max
- mov rsi,msg
- mov rdi,0
- mov rax,0
- syscall
- mov rcx,rax ; Copy the string for later
- mov rdi,msg ; Set RDI and RSI to point at message
- mov rsi,msg ;
- add rdi,rax ; RDI should point at last character in message
- dec rdi ;
- shr rax,1 ; Divide length by 2
- .loop ; Begin loop:
- mov bl,[rsi] ; Swap the characters using 8 bit registers
- mov bh,[rdi] ;
- mov [rsi],bh ;
- mov [rdi],bl ;
- inc rsi ; Increment rsi (which is a pointer)
- dec rdi ; Decrement rdi (also a pointer)
- dec rax ; Decrement our counter
- jnz .loop ; If our counter isn't zero, keep looping
- ; Write
- .write
- mov rdx,rcx ; nbytes
- mov rsi,msg ; *msg
- mov rdi,1 ; stream
- mov rax,1 ; syscall
- syscall
- mov rdi, 0
- mov rax, 60
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement