NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: Fl0wless on July 15, 2021, 06:34:33 PM
-
Hello! I'm generating assembly and want to pass it to nasm. (How) Can I pass the source via stdin? (I tried the standard - but it didn't work.) Couldn't find anything on the web or in the forums. Or do I have to create a temp file?
Many thanks!
-
Hi Fl0wless
Welcome to the forum.
Nasm takes multiple passes over the file you present to it, so I don't think stdin is going to work.
Best,
Frank
-
Hi! Thanks for the answer, that is a bit unfortunate. Although that makes me a bit curious. Why does Nasm need to read the file multiple times? Does the preprocessor not work on a token basis? Do you try to generate the result on the fly without having the file fully in-memory (like old c compilers did out of space constraints)? Or is it some other reason? Much appreciated!
-
jmp foo
How far away is "foo"? Can it be a short jump or does it have to be a near jump?
If you want a single pass assembler. try spasm/rosasm. (that's not a serious suggestion)
There may be other single pass assemblers... I don't know...
Nasm started off as two pass and went to multi pass after 0.98.
Best,
Frank
-
But why re-parse the asm file? Why not store the token stream in-memory? Do you then not have to re-apply the macros?
-
Nasm is Nasm.
If you prefer some other assembler. go for it.
Best,
Frank
-
No, no, that's not meant as criticism! Just purely out of interest.
-
I really don't know. That's just the way it was done. I believe it does reprocess macros, yes.
Let me try a question for you... Why in the world would you want to produce a file the source for which has vanished forever?
Best,
Frank
-
Well, I could generate assembly, spawn Nasm as a subprocess, pipe the assembly in, and not worry about creating files / deleting files / worrying about old code fragments. Like I said, not really important, was just my initial approach.
Best regards,
Janis