1

I am relatively new to assembly. I would like to read a string from the command line, store in a variable and then convert it into an integer. Any ideas? The tutorial I was using used some extra assembly code that I didn't want to use in ALL of my assembly applications that I will be doing. I am running Linux Ubuntu with an x86 processor.

1
  • This question cannot be answered without knowing the processor that your are using and the operating system (if any). Commented Dec 1, 2010 at 22:23

1 Answer 1

1

"read" is a syscall. You can set up the registers (Linux) or stack (FreeBSD) yourself and then use a syscall by raising an interrupt or just use NASMX's macros to do so (in a cross-platform way!). stdin, stdout, and stderr are file descriptors 0, 1 and 2 respectively. Or, you could just use scanf in much the same way (which is of course is provided in the standard C library and would call read for you). Then it's easier unless you want to write your own integer parser for no reason!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.