Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .data
- msg1 db 'cong'
- msg1Len equ $-msg1
- section .bss
- buff resb 50
- section .text
- global _start
- _start:
- mov eax, 3
- mov ebx, 0
- mov ecx, buff
- mov edx, 50
- int 80h
- mov eax, buff
- mov ecx, -1
- .loop:
- inc ecx
- cmp byte [eax + ecx], 0
- jne .loop
- ;mov ecx, 4
- dec ecx
- mov eax, buff
- mov esi, eax ; esi points to start of string
- add eax, ecx
- mov edi, eax
- dec edi ; edi points to end of string
- shr ecx, 1 ; ecx is count (length/2)
- jz _done ; if string is 0 or 1 characters long, done
- reverseLoop:
- mov al, [esi] ; load characters
- mov bl, [edi]
- mov [esi], bl ; and swap
- mov [edi], al
- inc esi ; adjust pointers
- dec edi
- dec ecx ; and loop
- jnz reverseLoop
- mov eax, 4
- mov ebx, 1
- mov ecx, buff
- mov edx, 4
- int 80h
- _done:
- mov eax, 1
- mov ebx, 0
- int 80h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement