r/asm • • Apr 19 '19

ASM complier

Is all asm files same? Why some files .asm can't run on Microsoft Visual Studio?

I'm really confused when there are global_start but it won't run in Microsoft visual studio

0 Upvotes

6 comments sorted by

6

u/[deleted] Apr 19 '19

Assembly language isn't like C, you don't compile it, you assemble it into a binary/library.

You can't run the binary/library on every platform like C, the compiler takes care that the compiled binary/library can be run on a certain platform. Every OS and processor has its own instruction set and syntax, you assemble into a binary/library to be run on a certain platform so it does exactly what you want, or maybe you are programming electronic microcontrollers, so maybe it's more logical for you to use assembly language.

There are tons of things I didn't mention about assembly language in general because I don't know that much (but I like it anyway), but I can assure you that if you wanna program a binary/library in assembly language, make sure you read documentation and do a f*ck ton of research.

You don't "simply run" an assembled binary. For that you use C.

2

u/P0werC0rd0fJustice Apr 19 '19 edited Apr 20 '19

Each processor architecture has a different assembly language. You’ll need to determine which architecture your files are written in and use an assembler that is designed for it. By default the visual studio assembler expects files written in intel x86 assembly.

3

u/jedwardsol Apr 19 '19

Is all asm files same?

No. There are lots of different assemblers for x86. The one in Visual Studio is called masm

An assembly file written for a different assembler, even if it is x86, may not be understandable by masm

3

u/skeeto Apr 20 '19

Adding to this: x86 is peculiar in that it has no official assembly language format / syntax. Not everyone even agrees on the specific mnemonics. As a language, x86 assembly is fragmented with different vendors over the years each doing their own thing. Though, at a high level, there are two major flavors: AT&T (Unix) and Intel (Windows). But just because two assemblers are both Intel-flavored doesn't mean they're compatible.

1

u/FUZxxl Apr 20 '19

Assembly is assembled, not compiled. The tool is called an assembler, not a compiler. Please make sure to get these terms right or you are going to confuse people.

1

u/[deleted] Jun 24 '19

No, asm files depend on the assembler that is used. An asm file that works for NASM might not work for YASM, MASM, FASM, etc...