View Single Post
Old 01-06-10, 08:32 AM   #4
Registered User
FlakMagnet's Avatar
Join Date: Mar 2005
Location: Farnborough, UK
Posts: 335
Default Re: Driver writing and assemblyish things. The old fashion way?!

I think most drivers are now written in C/C++. There might be some areas of a driver that needs to be written in assembly, but I imagine developers avoid it if possible - it' just so much easier developing and debugging in C/C++. And because Windows 3.1 is very old, I don't think you'll find many developers still writing drivers for it.

One reason why assembly is not as popular any more is that computers are so much faster than they used to be. In 'the good old days' developers had no choice but to write device drivers in assembly to make them as quick as possible, but now, languages such as C and C++ as sufficient. Modern CPUs run C++ compiled code very well, and is actually very difficult to write assembly that will be quicker than the compiled C++ equivalent. Modern compilers optimise very well.

I wrote a driver for a high speed capture card entirely in assembly language for Windows 3.11 quite a few years back, but things were a lot easier back then. Windows was nowhere near as 'secure' as recent versions, and it was fairly simple to allocate yourself a DMA channel and blat data into memory without having to worry too much about what the OS might think of you doing that.

On modern OSes, I imagine there are tools and driver 'templates' that start you off in the right direction and you just have to fill the gaps with your device's specific features and requirements. If you look at some of the documents on the MS site I linked to, you will see that writing a device driver has been made significantly easier because MS has supplied the WDK. I think one of the quotes in the documentation said that there are over 100 power states in recent Windows OSes, and until the WDK became available, you had to code for each of them in your driver! Eek!

If you want to write software in assembly language as a learning exercise, I wouldn't write a device driver because:

1. They can be difficult to debug.
2. You can crash the OS if you get it wrong.
3. Unless you are going to get a job writing assembly language, you won't ever need to use it. I've been developing now for over 25 years and started in C and Assembly language on a Z80 machine running CPM, but I can't remember the last time I had to write assembly language.

If it is just a learning exercise, I would seriously look at C++ instead. You will find free tools both on Windows and Linux to help you develop in C++ and I think you'll have a much more enjoyable experience doing it. If you want to look at higher level languages, I suggest either Java or C#. Again, tools are freely available for development in Java and C# (although C# is limited to Microsoft OSes, Java is cross platform).

If you are still determined to develop device drivers in assembly language, then I wish you all the best (being serious). I loved developing in assembly language - I think it's still my favourite part of my career so far, but I wouldn't like to develop the kinds of application I am now developing in assembly language - that would be torture
ASUS P6T Deluxe V2 | i7 920 @ 3.6GHz
POV GTX480 | 6GB Patriot DDR3 @1443
X-Fi Fatal1ty Pro | 120GB OCZ Vertex SSD
2xSamsung 7200 750GB RAID 0| Akasa Eclipse 62
FlakMagnet is offline   Reply With Quote