
Untitled
By: a guest on
Jun 25th, 2012 | syntax:
None | size: 1.33 KB | hits: 9 | expires: Never
NASM segmentation fault problem
%include "macros.inc"
section .data
prompt1 db "Enter string: ",0
prompt1len equ $-prompt1
prompt2 db "The size of string is: ",0
prompt2len equ $-prompt2
section .bss
string resb 20
section .text
global _start
_start: str_output prompt1len,prompt1
str_input string
mov ebx,string
call func
str_output prompt2len,prompt2
output eax
exit 0
func:
xor eax,eax
et **cmp byte [ebx],0h**
je end
inc eax
inc ebx
jmp et
end dec eax
ret
%macro exit 1
mov eax,1
mov ebx,%1
int 80h
%endmacro
%macro int_input 1
mov eax,3
mov ebx,0
mov ecx,%1
mov edx,1
int 80h
and eax,0Fh
mov %1,eax
%endmacro
%macro str_input 1
mov eax,3
mov ebx,1
mov ecx,%1
mov edx,20
int 80h
% endmacro
%macro output 1
mov eax,%1
or eax,30h
mov %1,eax
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,1
int 80h
%endmacro
%macro str_output 2+
mov eax,4
mov ebx,1
mov ecx,%2
mov edx,%1
int 80h
%endmacro
mov ebx, offset string