Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Name split test
- global _main
- extern _printf
- extern _gets
- extern _system
- section .data
- pause_str db 'pause', 0
- cls_str db 'cls', 0
- out_firstname db 'Your first name is: %s', 10, 0
- out_lastname db 'Your last name is: %s', 10, 0
- prompt db 'What is your first and last name?', 10, '> ', 0
- section .bss
- input_buffer resb 50 ; char input_buffer[50];
- firstname resd 1 ; char *firstname;
- lastname resd 1 ; char *lastname;
- section .text
- _splitNames:
- mov ebx, [esp + 4];
- loopstart:
- cmp byte [ebx], 0
- je loopend
- cmp byte [ebx], ' '
- jne notspace
- mov byte [ebx], 0
- inc ebx
- mov eax, ebx
- mov ebx, dword [esp + 12]
- mov dword [ebx], eax
- jmp loopend
- notspace:
- inc ebx
- jmp loopstart
- loopend:
- mov eax, dword [esp + 4]
- mov ebx, dword [esp + 8]
- mov dword [ebx], eax
- ret
- _main:
- push prompt
- call _printf
- add esp, 4
- push input_buffer
- call _gets
- add esp, 4
- push lastname
- push firstname
- push input_buffer
- call _splitNames
- add esp, 12
- push dword [firstname]
- push out_firstname
- call _printf
- add esp, 8
- push dword [lastname]
- push out_lastname
- call _printf
- add esp, 8
- push pause_str
- call _system
- add esp, 4
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement