Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
.data

greeting: #greeting message
.ascii "Hi! Please enter your name!\n"
length_greeting: #greeting length
.int 28

nameinput: #output message
.ascii "Welcome to the computer science world,\n"
length_nameinput: #output length
.int 39

answer: #user input buffer
.space 30
answer_length: #user input length
.int 30

.text
.global _start

_start:
mov $4, %eax #print greeting
mov $1, %ebx
mov $greeting, %ecx
mov length_greeting, %edx
int $0x80


AskName:
mov $3, %eax #Save input answer
mov $0, %ebx
mov answer, %ecx
mov answer_length, %edx
int $0x80

mov $4, %eax #Print Nameinput
mov $1, %ebx
mov $nameinput, %ecx
mov length_nameinput, %edx
int $0x80


mov $1, %eax #exit program
int $0x80

>#expected output
>The output suppose to be:
>Hello! what's your name!
>(User input)
>Welcome to the computer science world, (user input)


>But my output is
>Hello! what's your name!
>(User input)
>Welcome to the computer science world,
>oan: Command not found.
Posted
Comments
Member 11197004 6-Nov-14 14:47pm    
Thanks for the help. It stills give me an error but hopefully I can figure it out later on.

1 solution

Im not sure why you're getting the error - not that I know which assembler variant you're running

one thing I did see, was that perhaps this ..

ASM
mov $4, %eax #Print Nameinput
mov $1, %ebx
mov $nameinput, %ecx
mov length_nameinput, %edx
int $0x80


mov $1, %eax #exit program
int $0x80


should be this (ie, get and save the answer, then print the Nameinput fixed text, then print the answer)

ASM
mov $4, %eax #Print Nameinput
mov $1, %ebx
mov $nameinput, %ecx
mov length_nameinput, %edx
int $0x80

mov $4, %eax #Print answer (name)
mov $1, %ebx
mov $answer, %ecx
mov answer_length, %edx
int $0x80

mov $1, %eax #exit program
int $0x80



btw, consistency is good - you have length_greeting, length_nameinput, but answer_length
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900