Assembler language

Started by
4 comments, last by sand_man 19 years, 9 months ago
hi, I am just starting the assembler language, and I have some issues that I wish you could help me with: 1/ firs of all, I can't understand the compatibility issue. it seems that an assembler language depends on the CPU, but then would I have to write a different code for each CPU? and what is the interest of the assembler language when my application could work on just a specific group of computers?? 2/ the second issue is that there are a whole lot of compilers, (there's MASM, FASM, NASM, ......), so I don't know which one to pick nor the difference. so I woush someone could help me on this, I am so confused, and I need a little push. thanks.
Advertisement
Assembly languages are very specific to the processor, because they correspond exactly with that processor's machine code. That's also why you'd usually program in higher level languages. For example, in C++ compilers you can compile the same code for different processors, assuming that you're not using platform specific libraries. That and the fact that Assembly is just plain painful to work with are why you're better off only using Assembly for optimization. If you know what you're doing in Assembly, it can be very fast, but you really, really need to know what you're doing. As to the second question... I don't know from experience, but there shouldn't be much of a difference, excepting perhaps what processor they'll produce an executable for. The term is assembler in this case, not compiler. That's also why there shouldn't be a lot of difference... Assembly code already corresponds exactly with machine code, so as far as I understand it anyway, all an assembler actually does is convert it from ascii text to machine code. Given that, I can't imagine any of those assemblers would be much better to use than any other.
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Addressing your first question: All CPUs that work with PC computers follow the same architecture (x86). This means that anything written for an Pentium 3 will work for a Duron as long as no special features that only a pentium 3 would have are used.
When it comes to compilers: Use what you can get and what you like...Use different things ang choose which you prefer. Good luck [wink]!
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
In answer to you first question, people use it because if used properly and in the right places, it can speed up your program, but it's likely you'll have to write the code several different ways if you use any advanced features that are not generally supported. Also, compilers are generally pretty good, so getting a benefit requires you to really know what you're doing.

tj963
tj963
Quote:
1/ firs of all, I can't understand the compatibility issue. it seems that an assembler language depends on the CPU, but then would I have to write a different code for each CPU? and what is the interest of the assembler language when my application could work on just a specific group of computers??


95% of computer users are using an AMD or Intel processor, which covers pretty much every instruction you're likely to come across. This is 'standard' x86 assembly, though there have been many extensions over the years (SSE, SSE2, MMX, etc.)

Quote:
2/ the second issue is that there are a whole lot of compilers, (there's MASM, FASM, NASM, ......), so I don't know which one to pick nor the difference.


MASM is good, though honestly...writing code PURELY in ASM is usually an exercise in frustration. ASM works best when mixed with other, higher level languages, like C/C++.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

for win32 apps i recommend http://www.masm32.com/
for dos apps i recommend http://eji.com/a86/

This topic is closed to new replies.

Advertisement