So... I'm looking into learning Assembly. I downloaded the FASM assembler and I want to know how useful is assembly? I want the opinion from Cpp programmers because assembly programmers always tell me it's the best language -__-
Also quick question: How do I know which register to put stuff in? No tutorial says it. It just says eax ebx, etc.. Never explains how to tell what goes where.
Yes, ASM can be very useful. If you need to rewrite a function because its too slow, ASM can make it quite a bit faster. If you need to interface with a module of some kind and C++ is too clumsy to do the interface, ASM to the rescue. Drivers can easily be written in ASM.
How do I know which register to put stuff in?
If you are calling a function, interrupt, or something already written, that info is in the documentation of the function. Otherwise, general registers are used as variables so it doesn't matter. Some registers have specific definitions, so only specific type of data will do into them. You learn what's what as you learn ASM.
How useful is assembly? That's hard to say. Nowadays, it would be madness to write a large / complete application in assembly.
As far as I know, when it comes to writing assembly code, the only areas of application are in high-performance, low-level, and/or resource-restricted environments. I'm talking things like small micro-controllers (e.g., PICs) where assembly is the only option, and possibly in larger micro-controllers that usually support C (or BASIC) but assembly will be faster given the very limited resources. Then, there are things like hardware drivers and other low-level components (e.g., bus controllers, etc.). And finally, core functions that need to be highly optimized, usually small functions that get called an enormous amount of time like some kernel functions in an operating systems. I've also heard that there can be quite a bit of assembly programming in computer game programming, mostly in squeezing every clock cycle out of rendering code and programming shaders and other GPU processes.
All of these applications are highly specialized and you would probably end up having to learn assembly if you end up doing one of these things, but it is not worth learning to be proficient in assembly if you don't see a need for it in the very near future. Writing assembly is not fun, it's just very tedious to do. And it's not particularly difficult either (it's a very simple language after all!), it doesn't take very long to learn it, but don't do it for fun, only by necessity.
What I said above applies to being proficient at assembly programming. Many programmers know quite a bit of assembly, but are not proficient. This is my case. I know enough assembly to read it, to write simple functions (inlined assembly), and to deal with disassembly dumps from debuggers. Of course, assembly is very cryptic, so I don't know how easily it can be read or written even by a proficient assembly programmer. The main reason for me to know assembly is initially because of debugging, and later because of optimization. I initially got exposed to assembly through the disassembly dumps from the debuggers, I sucked as a programmer back then (and my programs were way too ambitious) and I spent a lot of time tracking down stupid bugs by plowing through the disassembler dumps. Later, the need to read assembly came out of wanting to know what assembly code was produced by certain chunks of C/C++ code (by different compilers and options). Assembly code has the advantage that each instruction (except fetches) is basically a single clock cycle, so optimization is a bit more straight forward (i.e., count the lines of assembly code needed to do the operation). You also need some reading capabilities to be able to see how functions get put together by the compiler (e.g., inlined or not, if tail-calls are correctly optimized, and other standard optimizations). That's basically the extent of my needs to assembly programming knowledge.
How do I know which register to put stuff in?
edx for storing anything you like (general-purpose), and
eax usually stores the return value when returning from a function, and
ecx is usually used for loop-counters (I don't know why). Then, you have
ebp, the former being the stack-pointer and the latter being the base-pointer (usually the previous stack-pointer), these are the pointers you manipulate when you expand or shrink the stack for local variables, and offsetting with respect to
esp is how you access local variables. Of course, all the registers I mentioned start with
e which is for "extended" which only applies to 32-bit registers on x86 architectures (for 16bit registers remove the
e, and for 64-bit registers, replace it with
r). This might seem complicated and all, but you'll get it eventually.
Here are a few guides to help you out.
http://www.cs.virginia.edu/~evans/cs216/guides/x86.html - Look at the table on the first page. Then jump to the next link. Jump back when the register functions make sense.
http://www.eecg.toronto.edu/~amza/www.mindsec.com/files/x86regs.html - This gives an overview of which registers do what.
I have an assignment to output contents from a .txt file to html. I'm able to output the information from the .txt to the console but how would I output ...
hi all , i search for motion detector documents and code source with systemC programming language, any help pls
Hello, am working on a program for the U.S. Department of Labor. I am working on two programs for the state of Oregon, and the program that reads data and ...