Advertisement
Guest User

ping21

a guest
Aug 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .data
  2.     msg1 db 'cong'
  3.     msg1Len equ $-msg1
  4.  
  5. section .bss
  6.     buff resb 50
  7.  
  8. section .text
  9.     global _start
  10.  
  11. _start:
  12.     mov eax, 3
  13.     mov ebx, 0
  14.     mov ecx, buff
  15.     mov edx, 50
  16.     int 80h
  17.  
  18.     mov eax, buff
  19.     mov ecx, -1
  20.  
  21.     .loop:
  22.         inc ecx
  23.         cmp byte [eax + ecx], 0
  24.         jne .loop
  25.  
  26.     ;mov ecx, 4
  27.     dec ecx
  28.     mov eax, buff
  29.     mov esi, eax  ; esi points to start of string
  30.     add eax, ecx
  31.     mov edi, eax
  32.     dec edi       ; edi points to end of string
  33.     shr ecx, 1    ; ecx is count (length/2)
  34.     jz _done       ; if string is 0 or 1 characters long, done
  35.     reverseLoop:
  36.     mov al, [esi] ; load characters
  37.     mov bl, [edi]
  38.     mov [esi], bl ; and swap
  39.     mov [edi], al
  40.     inc esi       ; adjust pointers
  41.     dec edi
  42.     dec ecx       ; and loop
  43.     jnz reverseLoop
  44.  
  45.     mov eax, 4
  46.     mov ebx, 1
  47.     mov ecx, buff
  48.     mov edx, 4
  49.     int 80h
  50. _done:
  51.     mov eax, 1
  52.     mov ebx, 0
  53.     int 80h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement