Jump to content

Doubt with nasm and assembly

- - - - -

  • Please log in to reply
4 replies to this topic

#1
IlikeProgramming

IlikeProgramming

    Newbie

  • Members
  • PipPip
  • 11 posts
Well, I have a doubt about nasm and assembly. Surely it will be a stupid thing, and I fell embarrassed to post it. But i need to know.

If I am programming in assembly, why do I need a compiler like nasm?? In theory, a compiler translates a source code in a high level language (like C), into assembly instructions, doesn't it? So why do I need a compiler to programming assembly?

Many thanks to all. And sorry for the stupid question!!

#2
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Actually, it is called an assembler. When you use a C compiler, it translates C into assembly, then an assembler translates the assembly into machine code. So you are not using a compiler for assembly.
Latinamne loqueris?

#3
IlikeProgramming

IlikeProgramming

    Newbie

  • Members
  • PipPip
  • 11 posts
Many thanks mebob, I have understood you. But one other issue. I'have just begin to program in assembly in Linux, with nasm. But you said "When you use a C compiler, it translates C into assembly, then an assembler translates the assembly into machine code". So, before install nasm, I had an assembler, when I programmed in C. Why do I have to download an assembler, like nasm, when I've just installed another assembler?

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200

IlikeProgramming said:

Many thanks mebob, I have understood you. But one other issue. I'have just begin to program in assembly in Linux, with nasm. But you said "When you use a C compiler, it translates C into assembly, then an assembler translates the assembly into machine code". So, before install nasm, I had an assembler, when I programmed in C. Why do I have to download an assembler, like nasm, when I've just installed another assembler?

The compiler you have is most likely GCC ,which stands for GNU Compiler Collections. GNU includes a assembler named "as", which you should be able to use, but it is in a much different format than NASM. So you may want to just stick with NASM instead of learning a less documented syntax.

Edited by Alexander, 07 November 2010 - 08:36 PM.

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
IlikeProgramming

IlikeProgramming

    Newbie

  • Members
  • PipPip
  • 11 posts
Ok, Many thanks to all, and sorry for my stupids questions. I want to learn!!! see you!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users