Re: newbie: I/O with nasm



James Daughtry wrote:
Actually, I'm kinda hoping Thomas wants it in "pure asm"! :)


*I* want it in "pure asm". Gimme gimme. ;-)

You can't have it until you say "what OS"! :)

Then, the question arises, "How pure do you want it?" If you want *really* pure, I suppose "no OS". No bios ints, either! And I suppose you want it to be 32-bit code... Oh, and "redirectable" like stdio, which means a filesystem of some kind... All possible, but more like "OS development" than a "newbie project"!

For more practical purposes, if we're allowed to call availabe OS services, dos and Linux are easy. For Windows, I think we're going to have to call GetStdHandle with -10 for stdin, and -11 for stdout (that seems too insane to be true!). Then, ReadFile and WriteFile might take a parameter to say whether it's unicode or not, and I think ReadFile wants a parameter telling it where to put "status" - number of characters read or errno - rather than returning it in eax... Otherwise not too much different than the read()/write() example.

I'd post a Linux example, in case that's what you want, but I suppose the odds are against it :( TK originally asked for "from the command line", so we may be on the wrong track entirely with these "stdin" examples. If he wants to read "command line parameters", well "they're on the stack", except for dos, where they're at offset 80h into the PSP... and I guess Windows has a "GetCommandLine" API...

So, if you want I/O examples that don't use libc, you gotta "say what OS". :)

Best,
Frank
.



Relevant Pages

  • Re: More on Function Purity
    ... the command line to main does not violate purity. ... import Top (realmain) ... Apart from program startup time one could not distinguish such a ... either all of them are pure or all of them are not pure. ...
    (comp.lang.functional)
  • Help Installing DBI on Sun solaris
    ... the Makefile.PL script seems to run fine when I do the make command it errors out ... `pure' attribute directive ignored ... 3500 Telecommunications & Networking ...
    (perl.dbi.users)