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 Answer
"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!