First let me say I am thankful I found these forums for assembly, and that I am a complete newbie.

I've been reading documentation, and even bought a book on learning assembly, however, there is still one question I have that baffles me. I would appreciate it if someone could shed a little light on this for me. Thanks.

I've read that for example x86 utitlizes a certain instruction set, but when it comes to Linux or Windows, they both use different syntax. This I don't understand. If assembly is assembly for a certain processor, how can two different operating systems utilize different syntax for the same instruction set or assembly code? Secondly, the book I have, and forgive me if this is wrong; states that the Assembler converts to .obj and .exe on Windows, and something else on Linux (although still a form of executible file). Well, what do you do if you don't have an Operating System to run the assembled executible? Just an empty computer with nothing on it? Say from perhaps a CD? I find it hard to believe that the computer would read a .exe file straight from disk. Could someone help straighten out this mass confusion I'm in. Thanks a lot.

Recommended Answers

All 4 Replies

First let me say I am thankful I found these forums for assembly, and that I am a complete newbie.

I've been reading documentation, and even bought a book on learning assembly, however, there is still one question I have that baffles me. I would appreciate it if someone could shed a little light on this for me. Thanks.

I've read that for example x86 utitlizes a certain instruction set, but when it comes to Linux or Windows, they both use different syntax. This I don't understand. If assembly is assembly for a certain processor, how can two different operating systems utilize different syntax for the same instruction set or assembly code? Secondly, the book I have, and forgive me if this is wrong; states that the Assembler converts to .obj and .exe on Windows, and something else on Linux (although still a form of executible file). Well, what do you do if you don't have an Operating System to run the assembled executible? Just an empty computer with nothing on it? Say from perhaps a CD? I find it hard to believe that the computer would read a .exe file straight from disk. Could someone help straighten out this mass confusion I'm in. Thanks a lot.

When your programming assembler for Windows or Linux you can expect different syntax for different compilers. MASM has its syntax, NASM has its own and GAS has a very different syntax. The product or machine instructions are the same(assuming your talking about the same machine).
One more point, operating systems have different ABI's(application binary interfaces) meaning you can't expect to take code developed on a Windows machine and expect it to work on a Linux machine. One example - system call procedures are operating system unique.
One More very important point - exes. A windows executable binary format is completely different then say ELF(executable and linking format - Linux) format.

How do you get an 'empty' computer to recognize a bootable program? It depends on the machine, if your talking an IBM compatible then check this link..

http://linuxgazette.net/77/krishnakumar.html

I think I answered your 'one' question.

When your programming assembler for Windows or Linux you can expect different syntax for different compilers. MASM has its syntax, NASM has its own and GAS has a very different syntax. The product or machine instructions are the same(assuming your talking about the same machine).
One more point, operating systems have different ABI's(application binary interfaces) meaning you can't expect to take code developed on a Windows machine and expect it to work on a Linux machine. One example - system call procedures are operating system unique.
One More very important point - exes. A windows executable binary format is completely different then say ELF(executable and linking format - Linux) format.

How do you get an 'empty' computer to recognize a bootable program? It depends on the machine, if your talking an IBM compatible then check this link..

http://linuxgazette.net/77/krishnakumar.html

I think I answered your 'one' question.

Thanks! That makes it a little easier. So the syntax is basically just the construction of the assembly code, although the code is the same? But if there are two identical computers with the same hardware and microprocessor, is there portable code that can be applied to both OS's and still function properly?

Thanks! That makes it a little easier. So the syntax is basically just the construction of the assembly code, although the code is the same? But if there are two identical computers with the same hardware and microprocessor, is there portable code that can be applied to both OS's and still function properly?

If you don't require any operating system services then 'maybe' yes. This discussion doesn't take into account all the emulators that are available out there to simulate different environments.

Each assembler's syntax is different, some follow something
close to Intel Syntax, as DOS and Windows assemblers do,
and UNIX assemblers use AT&T syntax because UNIX was developed
at bell labs.
The syntax doesn't matter as long as it assembles into the
same machine instructions, it doesn't matter how opcodes
are indicated by mnemonic or what names are used for registers,
for they are all merely indicated by values in machine instructions.
MOV DWORD [ES:EDI], 22
MOVL 22, (%EDI) ; I think (%EDI) is indirect addr mode
An assembled language is one that merely corresponds to how
certain values are to be constructed, the language is 'assembled'
into values and the statements tell the assembler how.
Programming in machine language involves assembler because
the CPU only understands machine language which is a
series of binary encoded values that tell the processor what
to do and are called instructions.
Assembler instructions mere machine instructions symbolically
with mnemonics, due to this one-to-one correspondence machine
instructions can be turned back into assembly instructions,
back into their symbolic form.
Remember the assembler source also mirrors the machine
implementation of the program, the exact form of the executable
portion is determined by the assembler statements.
Assembly instructions are rather primitive and perform very
simple operations, hence an assembly language source
file is typically longer than its C equivalent, but assembly
language programs tend to produce smaller executables
than C or any other high or medium level language.
Assembly language programs are small and efficient,
due to the fact that their machine code was hand coded.
Assembly language is very flexible.
You can learn a lot about how computers really work on the
inside, at the machine level, if you are really into computers
, you should know assembler and system architecture.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.