Advertisement
Guest User

ping22

a guest
Aug 9th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data
  2. msg times 64 db 0
  3. max equ 64
  4.  
  5. section .text
  6. global _start
  7.  
  8. _start:
  9.     Read
  10.     mov rdx,max
  11.     mov rsi,msg
  12.     mov rdi,0
  13.     mov rax,0
  14.     syscall
  15.  
  16.     mov rcx,rax     ; Copy the string for later
  17.     mov rdi,msg     ; Set RDI and RSI to point at message
  18.     mov rsi,msg     ;
  19.     add rdi,rax     ; RDI should point at last character in message
  20.     dec rdi         ;
  21.     shr rax,1       ; Divide length by 2
  22.  
  23.     .loop           ; Begin loop:
  24.     mov bl,[rsi]    ; Swap the characters using 8 bit registers
  25.     mov bh,[rdi]    ;
  26.     mov [rsi],bh    ;
  27.     mov [rdi],bl    ;
  28.     inc rsi         ; Increment rsi (which is a pointer)
  29.     dec rdi         ; Decrement rdi (also a pointer)
  30.     dec rax         ; Decrement our counter
  31.     jnz .loop       ; If our counter isn't zero, keep looping
  32.  
  33.     ; Write
  34.     .write
  35.     mov rdx,rcx ; nbytes
  36.     mov rsi,msg ; *msg
  37.     mov rdi,1 ; stream
  38.     mov rax,1 ; syscall
  39.     syscall
  40.  
  41.     mov rdi, 0
  42.     mov rax, 60
  43.     syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement