tags:

views:

757

answers:

12

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.

A: 

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.

PP
+3  A: 

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.

Nils Pipenbrinck
+3  A: 

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.

chustar
Also, if you're not really good at optimization of the code, chances are that the compiler will generate faster code anyway.
Mikael Auno
Speed matters, but fortunately you don't need to write in assembly language to get great speed for your apps. Also, you pretty much need to be a assembly guru, to beat a modern compiler at optimizations.
Pop Catalin
A: 

http://www.projecteuler.net

Dustin Fineout
+3  A: 

This may seem very cliche, but you could try and answer some of the questions over at projectueler using assembly.

Jonno_FTW
+3  A: 

Today, assembler is used in these areas:

  • Kernel/OS development. Ask the Linux guys or check out the other OS projects out there.
  • Compiler development (someone's got to translate the higher level languages to the CPU)
  • Driver development
  • Embedded devices (but more and more are moving to higher level languages here, too ... my set top box runs Python)
  • Game development for special effects (but this is mostly in specific assembler dialects for the graphics card)
Aaron Digulla
A: 

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.

Domus
+10  A: 

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

Bastien Léonard
+1 for the links
jldupont
Nice one, Thanks.
Colour Blend
I wish I could pick multiple answers.
claws
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/
Simucal
+4  A: 

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.

+1  A: 

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.

DigitalRoss
+2  A: 

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.

srini.venigalla
+21  A: 

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): alt text

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:

  1. Minefield Height is located in 0x1005338
  2. Minefield Width is located in 0x1005334
  3. Minefield Baseaddress is located at 0x1005340

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:

  1. Reverse hidden API's in libraries
  2. Write advanced game hacks using DLL Injection, Code Caves, Function Hooking and more!
  3. Understand the limitations of various protection schemes employed by software
  4. Reverse a fileformat that isn't published or known and write code to read this format for interoperability purposes.
  5. Write emulators for various systems (including older game systems!)
  6. Understand how a well-known program does a particular task.
  7. Reverse malware and viruses to see how and what they do.

And more!

If you are interested, I highly suggest the book: Reversing: Secrets of Reverse Engineering

Simucal
Damn, that sounds cool. You just made me want to relearn assembly. +1
Cybis
Excellent and clear explanation!
Dustin Fineout