Ask coding questions

← Back to all posts
how can I compile C to nasm? all tools i find (objconv, c2nasm) are for windows
mkcodes

how can I compile C to nasm? all tools i find (objconv, c2nasm) are for windows and
WINE or dos2unix need sudo to install which i don't have

Voters
mkcodes
Comments
hotnewtop
SixBeeps

Ummm, nasm isn't a language. It's a compiler for x86 (and other types, but that's not important) Assembly.

If you want to create assembly code from a C or C++ file, you can feed the -S flag to gcc and it'll do that. https://stackoverflow.com/questions/8021874/how-can-i-compile-to-assembly-with-gcc

mkcodes

@SixBeeps but that can only create AT&T by default or intel, not NASM assembly (intel via --masm=intel)

SixBeeps

@mkcodes Huh, that's interesting. I've just now taken a look at both objconf and c2nasm, I never knew there was actually a nasm flavor of assembly. Something about that seems strange to me, but /shrug.

Anyway, c2nasm doesn't look like it's specifically for Windows. In fact, it doesn't even natively support Bash scripts. Is it not working for you? It seems to run just fine for me.

mkcodes

@SixBeeps but it requires objconv, and when i unzipped it it just shows EXE file meaning its probably a windows terminal tool. (tester/objconv/objconv.exe) BUT it says u can run it on unix in help file ("The latter three platforms are all based on the UNIX heritage. I will use "Unix" as a common
name for Linux, BSD and Mac on x86 an x86-64 platforms in this manual. [..] The source code for objconv can be compiled and run under any of these platforms.")

mkcodes

@mkcodes ALSO i ran ./c2nasm.sh ../main.c for somsething like int main(){return 0;} and it doesn't pass any test, so it works but raises errors

SixBeeps

@mkcodes From the objconv documentation:

You need to build it. build.sh is located in /src/

mkcodes

@SixBeeps WAIT IKNOW WHAT TO DO!! we have to make it from source (stackoverflow)