Hi,
I just finished learning assembly language. But I couldn't understand what could I implement (for practice/like small project). Would be great if its something useful for anyone.
Hi,
I just finished learning assembly language. But I couldn't understand what could I implement (for practice/like small project). Would be great if its something useful for anyone.
At the very least you can now output assembler from gcc like this:
gcc -c -S test.c -o test.asm
Then you can inspect the output of generated C code for educational purposes.
You could take a look at the liboil project:
http://liboil.freedesktop.org/wiki/
Its a library for highly optimized innerloops.
Most of the loops already have a x86 assembler implementation, but there are still some loops left to be rewritten.
Depending on how well you learned assembly, you could try writing firmware for small microprocessors or even for small devices hooked up to your computer. You could also try writing full software applications in assembly and give them a nice looking GUI.
Generally speaking, from my experience, assembly isn't as useful in programming massive software projects because for a lot of applications, speed doesn't really matter (at least, not in the days of multi-core processors) so what you can do is somewhat limited.
This may seem very cliche, but you could try and answer some of the questions over at projectueler using assembly.
Today, assembler is used in these areas:
If you're already a developer in a higher-level programming language, assembly language allows you to create optimized routines/functions. I don't know about the others, but Delphi, for instance, allows you to perfectly integrate assembly code into any unit, and takes care of the function parameters etc.
You can learn how OS work at low level (interrupts, virtual memory and so on). First write a bootloader which will give you full access to the hardware, then you can start playing with protected mode, VGA programming and so on.
Two good resources:
http://wiki.osdev.org/Main%5FPage
http://www.osdever.net/FreeVGA/home.htm
[Edit]
If you want to learn about optimizations, check out Agner Fog's website: http://agner.org/optimize/.
[Edit]
Copied from Simucal's comment:
You might want to add a link to MikeOS also. It is a small operating system written in Assembly that is designed as a learning tool to see how simple operating systems work. It has well commented code and documentation: http://mikeos.berlios.de
Optimization. Learn how to use Intel's VTune if you program on Windows. Here you can see where your bottlenecks are. Then rewrite those routines in assembler.
As most modern software changes all the time this is more an intellectual exercise and self satisfaction in getting something to run faster then of benifit in the real world.
There are one or two people who have re-written many of the core C primatives, memcpy, memset etc. in assembler tailored to the runtime CPU. So the code is bigger as it has extra routines to take advantage of CPU extensions, SSE etc but faster. These C primatives often end up in many packages .dlls as most programs do memory stuff all the time.
I suppose you could try code-golf
There is also at least one O.S. written for the PC in assembly: MenuetOS. (I have no idea why.) They may want contributions.
I understand that prior to the invention of C in the early 1970's, most operating systems were actually written in straight assembly. I wouldn't recommend doing that, but you could write a stand-alone program, just for fun. Note that the CPU will start up in 16-bit mode and it's quite difficult to get it to switch to 32-bits. It's probably best to just write the stand-alone program in 16-bit x86. You might use a simulator for development.
You can look for a robot or a controller that can hookup to your Parallel port and write some cool key handlers to control them. You can also intercept the BIOS calls like Int13 for Disk and write some disk mirroring tools, RAID drivers etc. You can hookup some transducers like Temp/vibration/pressure etc and do some data acquisition.
One of my favorite hobbies is Reverse Engineering.
It requires a solid knowledge of assembly and the use of disassemblers/debuggers to walk through compiled code. This allows you to alter, understand and reverse compiled programs. Each new program is like a puzzle waiting to be solved!
For example, a lot of people reverse games like Minesweeper when they are first starting out.
Here is a screenshot of a key section of code in Minesweeper I reversed awhile back (comments on right-hand side):
This was located by placing a breakpoint on calls to the rand()
function and stepping backwards in the callstack. After some digging it becomes obvious that:
With this knowledge it becomes easy to determine the location of any given mine in the minefield by:
cellAddress = mapBaseAddress + (32 * (y+1)) + (x+1);
Then, with a simple loop and some calls to ReadProcessMemory()
you've got the ultimate Minesweeper hack!
Reading hand-written assembly is far easier than reading machine generated assembly. Modern compilers do some magical and crazy things to the code for optimization that can sometimes be difficult to follow. So, this will definitely push your assembly knowledge!
There are tons of activities that can branch off from this:
And more!
If you are interested, I highly suggest the book: Reversing: Secrets of Reverse Engineering