assembly - NASM segmentation fault problem -


Greetings, I'm writing on the NASM under Linux, and I have the following problem: I have to write a simple program in which the user must enter the string, pass it to work, which gives its shape:

The code is:

 % include "macros.inc" section .data prompt1 db "Enter the string:", 0 prompt1len equ $ -prompt1 prompt2 db "is the string size : "Global _start _start .text 20 section resb 0 prompt2len equ $ -prompt2 section .bss string: str_output prompt1len, prompt1 str_input str Ing mov EBX, string phone function str_output prompt2len, prompt2 output eax exit 0 function: xor eax, eax et ** cmp byte [ebx], 0 hours ** je end ink eax Inc. ebx jmp et end dec eax retired   

And here is the macro file: macro exit 1 mov eax, 1 mov ebx,% 1 integer 80h% endmacro% macro int_input 1 mov eax, 3 mov EBX, 0 mov ECX% 1 mov EDX, 1 integer 80h and eax, 0Fh mov% 1, eax% endmacro% macro str_input 1 mov eax, 3 mov EBX, 1 mov ECX,% 1 mov EDX, 20 round 80h% Endmacro% m ACRO output 1 mov eax,% 1 or eax, 30h mov% 1, eax mov eax, 4 mov EBX, 1 mov ECX,% 1 mov EDX, 1 integer 80h% endmacro% macro str_output 2+ mov eax, 4 mov EBX, 1 mov ECX,% 2 mov EDX,% 1 integer 80h% endmacro

I have debug and problem in this program, the instruction is in CMP byte [EBX] 0 hours, because when I start the program, after the Stringwin input, the partition's fault prints, I do not see anything wrong, but maybe I have a mistake at this address. Try this before calling

func

< Pre> mov ebx, offset string

It seems that you are using the Intel syntax AT & T Syntax mov $ string,% ebx It will be right because the constant is always instantaneous, but it does not happen in Intel's

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -