<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Binary Karma &#187; Programming</title>
	<atom:link href="http://binarykarma.org/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://binarykarma.org</link>
	<description>There is karma in the bits</description>
	<lastBuildDate>Sun, 25 Apr 2010 12:41:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nokia 6610, 3530(3510i) Color LCDs and the AVR</title>
		<link>http://binarykarma.org/2007/06/09/nokia-6610-35303510i-color-lcds-and-the-avr/</link>
		<comments>http://binarykarma.org/2007/06/09/nokia-6610-35303510i-color-lcds-and-the-avr/#comments</comments>
		<pubDate>Sat, 09 Jun 2007 02:38:03 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/64</guid>
		<description><![CDATA[After successfully testing out the monochromatic 3310 LCD with the AVR, it was time to testÂ  out the color LCDs that I had purchased. Scouring the Internet I figured out that the easiest ones to interface would be the ones from the Nokia 6610 and the 3530. The 3530 and 3510i are supposed to be [...]]]></description>
			<content:encoded><![CDATA[<p>After successfully testing out the monochromatic 3310 LCD with the AVR, it was time to testÂ  out the color LCDs that I had purchased. Scouring the Internet I figured out that the easiest ones to interface would be the ones from the Nokia 6610 and the 3530. The 3530 and 3510i are supposed to be the same LCDs.</p>
<p>The 6610 LCD comes with 2 different controllers. The Epson S1D15G10 and the Philips PCF8833. You can find some images <a href="http://thomaspfeifer.net/">here</a>. If you got one with an Philips controller, you are lucky. The Philips controller is supposed to be pretty robust, while the Epson is supposed to be very tricky to get right due to its over sensitive nature to voltages and settings. I was not lucky enough to get a display with a Philips controller. Damn it. Nevertheless, I tried to get the display right. After working on it for days, all I got was an orangish display. No true colors. I was able to display whatever I wanted, but in just one color, Orange. This problem was widely reported on the Net.</p>
<p>The good thing about the 6610 LCD is that it has backlight LEDs already mounted. The 3530 LCD does not have backlight and this can be tricky to set up and color LCDs. You need really powerful, tiny white LEDs to evenly light the LCD from the back. Unless you have a support board, this can be tricky to get right.</p>
<p>After having spent at least 16-20 hours trying to get the 6610 display right, I moved on to the 3530 display that has a lesser resolution of about 97&#215;66, but is good enough for most tasks. I got a display within few hours of work. But when I try to execute the PASET command, the one that sets the cursor on a row you specify, it skips a row! For example, if you are trying to draw a rectangle using a line fill algorithm, the alternate rows would be skipped.Â  I tried various workarounds, but to no relief. So, I have to sadly let go of my experiments with color. I am wasting too much time and soldering lead on this.
</p>
</p>
<p><!-- ~ --><!-- ~ --></p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2007/06/09/nokia-6610-35303510i-color-lcds-and-the-avr/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nokia 3310 LCD and the AVR</title>
		<link>http://binarykarma.org/2007/05/05/nokia-3310-lcd-and-the-avr/</link>
		<comments>http://binarykarma.org/2007/05/05/nokia-3310-lcd-and-the-avr/#comments</comments>
		<pubDate>Sat, 05 May 2007 05:32:05 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/62</guid>
		<description><![CDATA[What is a computer without an user interface? And which user interface is better than just LEDs? Well, LCD! Man, it can talk and show pictures.
I have been reading since long about interfacing a Nokia 3310 LCD to many different microcontrollers. There are many libraries available for these different microcontrollers that make programming these devices [...]]]></description>
			<content:encoded><![CDATA[<p>What is a computer without an user interface? And which user interface is better than just LEDs? Well, LCD! Man, it can talk and show pictures.</p>
<p>I have been reading since long about interfacing a Nokia 3310 LCD to many different microcontrollers. There are many libraries available for these different microcontrollers that make programming these devices trivial. But where to get these devices? Luckily for us Indians, it is ridiculously easy to procure one of them. I just went to Chennai&#8217;s Ritchie street and got myself one. Not only did I get a monochrome 3310 LCD, I also got a 4K colour LCD that comes with the Nokia 6610!</p>
<p>The shop was in the dingiest of places. You could never suspect that civilization could exist there. But there it was, teaming with activity. Here you could get virtually any replacement for cell phone spares. What&#8217;s more, I saw cell phone repair manuals, with complete schematics! I wonder if these came from China, there was markings in a foreign tongue resembling the Chinese language. Every major Indian city must have one of these shops.</p>
<p>I first asked for a Nokia 3310 display. The shopkeeper promptly asked me if I wanted &#8220;O.G&#8221; or duplicate. The &#8220;O.G&#8221; meant original. Beware, these are really not the original spares themselves, just two different qualities of the counterfeit spares available in the market, as I later found out. The 6610 colour display came as a separate package, just the LCD, but the 3310 LCD came with a frame, it also had the ear piece. For some wierd reason, the shopkeeper warned me not to remove the earpiece. I ignored him since I needed space to shove in a capacitor. Things are fine. The &#8220;original&#8221; and the &#8220;duplicate&#8221; items had a difference of Rs. 25 among them. The &#8220;originals&#8221; for the 3310 and the 6610 cost me 150 and 350 respectively.</p>
<p>The 3310 is very simple to interface. It can talk to the SPI port of the AVR or any other microcontroller. It uses a Philips PCD 8455 controller that is simple to understand. But why reinvent the wheel for regular tasks? There is a wonderful library written by our friend, Louis Frigon. You can see that <a href="http://www.microsyl.com/nokialcd/nokialcd.html">here</a>. So I went about making myself a simple AVR programmer as described by Pramode in his wonderful article <a href="http://pramode.net/articles/lfy/atmega8/pramode.html">here</a>. I was previously running off a breadboard. This time around I bought a ZIF socket for easy installation and removal of the chip being programmed. This can save a lot of time and it is also gentle on the chip.</p>
<p>Then came the part of soldering the 8 wires on the Nokia LCD. Well you don&#8217;t need 8, but 7, since pin number 7 is connected to a capacitor that is grounded. I normally use a 10W soldering iron that is available usually for Rs. 20, but this time I knew the old guy was not a match for the precision required for the job. So I got myself a relatively expensive one from <a href="http://www.goot.co.jp/E_index.html">Goot</a> that came with a sharp tip.</p>
<p>With this iron, it was easy to solder the wires. I also managed to solder the 4.7 uF electrolytic capacitor on the pad itself. But I guess I pulled the wires a little bit, some pads then became loosely connected, internally, as I would later find out. If your soldering is bad, don&#8217;t even try it! Get someone who can do it for you. If you are too used to the breadboard, you may find this a tad difficult. Connecting these many flimsy wires to a breadboard can be a pain. So, I decided to use a general purpose PCB.</p>
<p>The LCD requires a 3.3 V power supply. I&#8217;m sure that a 3V power supply will work. Some sites also hint this. But I wanted to try out 3.3V, since I have never used components for that before. I called up my hardware wizard friend, Selva, my ex-colleague from  Novatium. He suggested either LM317 or LM1086.  There are fixed and adjustable versions of these useful chips. I suggest that using the 317 with 2 resistors is a simple way to avoid using the pricey LM1086 that costs Rs. 250. The LM317 costs a mere Rs. 15.<br />
<a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/484579230/"><img width="240" height="180" alt="AVR controlling a Nokia 3310 LCD display" src="http://farm1.static.flickr.com/169/484579230_edecd4be95_m.jpg" /></a></p>
<p>When I connected power and switched on, nothing! Well I rechecked and powered on, nothing again. I got this very familiar feeling of frustration. On closely examining the LCD soldering I saw that I had pulled the wires hard and the pads were not in their natural shape. I pressed the pads down with one finger and then powered on. And there I saw the words &#8220;God is Great&#8221;. With a line I had drawn from (1,1) to (30,30) just to check out the line routine.</p>
<pre>main() {</pre>
<pre>LcdInit();</pre>
<pre>LcdStr(FONT_1X,"God is Great");</pre>
<pre>LcdLine(1,1,30,30,PIXEL_ON);</pre>
<pre>LcdUpdate();</pre>
<pre>}</pre>
<p>Now is time for something more interesting.</p>
<p><strong> The Colour LCD</strong></p>
<p>Well, working with the monochromatic 3310 LCD was easy and just a few hours work. The colour LCD will be challenging both in terms of hardware(the pads are microscopic) and software. There is no library available.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2007/05/05/nokia-3310-lcd-and-the-avr/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>LGPL and the OpenVZ tools</title>
		<link>http://binarykarma.org/2007/05/02/lgpl-and-the-openvz-tools/</link>
		<comments>http://binarykarma.org/2007/05/02/lgpl-and-the-openvz-tools/#comments</comments>
		<pubDate>Wed, 02 May 2007 17:47:15 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Linux / FOSS]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/61</guid>
		<description><![CDATA[A few weeks ago, I had posted here regarding OpenVZ tools being GPL. Trouble is, some projects that are LGPL are creating wonderful tools to manage virtualization, but are unable to use the OpenVZ userland management tools code to support OpenVZ along with other virtualization technologies like Xen, QEMU and KVM. In FOSS, you just [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I had <a href="http://binarykarma.org/archives/57">posted</a> here regarding OpenVZ tools being GPL. Trouble is, some projects that are LGPL are creating wonderful tools to manage virtualization, but are unable to use the OpenVZ userland management tools code to support OpenVZ along with other virtualization technologies like Xen, QEMU and KVM. In FOSS, you just need to ask. Here is an excerpt of what I wrote on the list:</p>
<blockquote><p>&#8221;<br />
Virtualization is going mainstream and there are several tools being<br />
developed by many 3rd parties that deal with various virtual machine<br />
technologies. Several of these tools are licensed under the GPL. One<br />
promising library, LibVirt (http://libvirt.org) is licensed under the<br />
LGPL. As of today, Libvirt supports KVM, Xen and QEMU. If it needs to<br />
support OpenVZ quickly, it would be great if the userland control code<br />
is available in a library format under the LGPL, whereas the utilities<br />
can still be GPL. Re-inventing the wheel is a waste of time for<br />
everyone involved since it will take considerable time to include<br />
freshly writen code to control OpenVZ based VMs into LibVirt.</p>
<p>Will OpenVZ(SWSoft) be willing to release the userland control code<br />
(most of it in the &#8220;lib&#8221; directory of the vzctl distribution) under<br />
the LGPL so that other tools can use it efficiently?<br />
&#8220;</p></blockquote>
<p>There was one user, who came forward to do the work, by properly splitting the tools and core functions into and library proper and programs that link to it, if it was agreed that the code be released under the LGPL.</p>
<p>After many days, there seems to have been some consideration on those lines. One SWSoft(the company behind OpenVZ) employee,Â  has replied to a user who is having problems with the current library thus:</p>
<blockquote><p>&#8221;<br />
current libvzctl imho is brain damaged as it was never actually been designed properly. after the licensing question will be resolved I think it will be greately reworked.<br />
&#8220;</p></blockquote>
<p>If the tools are reworked on, and a LGPL version of the tools is available, then integration into LibVirt will be a breeze and it will save a lot of &#8220;reinventing the wheel&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2007/05/02/lgpl-and-the-openvz-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intel printed manuals</title>
		<link>http://binarykarma.org/2007/04/06/intel-printed-manuals/</link>
		<comments>http://binarykarma.org/2007/04/06/intel-printed-manuals/#comments</comments>
		<pubDate>Fri, 06 Apr 2007 15:45:22 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/59</guid>
		<description><![CDATA[Intel has introduced signigicant changes in its architecture this time, moving from the NetBurst to the Core architecture. There are also other features like Vanderpool or Intel VT-X that supports unmodified operating systems to run on a host operating system by hooking into a Virtual Machine Monitor(VMM) running on the host.

There is a lot to [...]]]></description>
			<content:encoded><![CDATA[<p>Intel has introduced signigicant changes in its architecture this time, moving from the NetBurst to the Core architecture. There are also other features like Vanderpool or Intel VT-X that supports unmodified operating systems to run on a host operating system by hooking into a Virtual Machine Monitor(VMM) running on the host.</p>
<p><a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/445183734/"><img width="240" height="180" alt="Intel manuals" src="http://farm1.static.flickr.com/197/445183734_73171d0955_m.jpg" /></a></p>
<p>There is a lot to catch up with, but the PDFs are a pain to read while sitting on the system. So, I ordered printed manuals from Intel. They sincerely sent it by international priority delivery. All for free. Thanks Intel!</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2007/04/06/intel-printed-manuals/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>EZVZ: An OpenVZ management GUI released under the GPL</title>
		<link>http://binarykarma.org/2007/02/07/ezvz-an-openvz-management-gui-released-under-the-gpl/</link>
		<comments>http://binarykarma.org/2007/02/07/ezvz-an-openvz-management-gui-released-under-the-gpl/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 06:37:01 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Linux / FOSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/53</guid>
		<description><![CDATA[Ah, feels good. I many times feel like writing software that other people can use to get something useful done. This has happened after years. I wrote a simple Python + GTK application that manages virtual machines under the OpenVZ kernel.
OpenVZ is a operating system level virtualization solution that lets users run many instances of [...]]]></description>
			<content:encoded><![CDATA[<p>Ah, feels good. I many times feel like writing software that other people can use to get something useful done. This has happened after years. I wrote a simple Python + GTK application that manages virtual machines under the OpenVZ kernel.</p>
<p><a target="_blank" href="http://openvz.org">OpenVZ</a> is a operating system level virtualization solution that lets users run many instances of virtual servers(each can be a different distro) on the same hardware. Whats more, the overhead is almost negligible.</p>
<p>EasyVZ is currently alpha quality software and definitely contains bugs and incomplete features and is released in the spirit of &#8220;releasing early&#8221;.</p>
<p>The project page is <a target="_blank" href="http://easyvz.sourceforge.net">here</a>.</p>
<p><img align="middle" title="EasyVZ main window" alt="EasyVZ main window" src="http://binarykarma.com/imgs/main.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2007/02/07/ezvz-an-openvz-management-gui-released-under-the-gpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny Computers</title>
		<link>http://binarykarma.org/2006/12/20/tiny-computers/</link>
		<comments>http://binarykarma.org/2006/12/20/tiny-computers/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 18:41:29 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/50</guid>
		<description><![CDATA[Microcontrolles are very powerful devices. They are different from Microprocesors in the aspect that they have things like RAM and code ROM included within the chip, whats more, they come enabled with a host of on-chip peripherals. I had some time to kill after a very busy official and personal schedule and went back, dusted [...]]]></description>
			<content:encoded><![CDATA[<p>Microcontrolles are very powerful devices. They are different from Microprocesors in the aspect that they have things like RAM and code ROM included within the chip, whats more, they come enabled with a host of on-chip peripherals. I had some time to kill after a very busy official and personal schedule and went back, dusted my 10W (Rs. 30) Tony soldering iron.<br />
My interest in embedded systems started when I first progammed the 8051 microcontroller. I got this 40-pin beauty manufactured by Atmel and was easily guided by the electronics shop guy to a person who could &#8220;program&#8221; this chip for me. By program I mean burn code into its Flash memory. I decided that to master the 8051 programming(this time I mean coding) and I needed a development board that would let me try out silly programs. I searched the Internet and quickly came out with the <a href="http://www.pjrc.com/tech/8051/board5/index.html">PJRC board</a>. This board allows one to write programs, download them to an external, off-chip RAM and execute it from there. A simple monitor program is provided for this purpose. I remember building the first revision of this hardware on a general purpose PCB. At that point in time, I never understood the importance of Bread boards. A friend of mine who was a VB-programer turned Linux programmer borrowed my board to try his hands at microcontroller programming and never returned it. <img src='http://binarykarma.org/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  I used to say &#8220;Dont trust VB programmers&#8221;. From then on, I have improved the scope of the meaning of my statement by changing it to &#8220;Don&#8217;t trust VB or Ex-VB programmers&#8221;. They can run away with your hardware, because that is the last thing they deal with and they are curious about it.<br />
I quickly realized that for permanent projects the development board was too much and I needed a 8051 device programmer. I made one and it worked well. And with it, I helped out several college students do interesting projects related to microcontrollers. Soon enough it was evident that the 8051 was too large for most of my projects. The Atmel 20-pin 2051 was a better choice. A few years ago, I built a programmer for that and it survives till this day. I followed a schematic provided <a href="http://www.kmitl.ac.th/~kswichit%20/easy1/easy.htm">here</a>. You can also find Windows based software to go with it. But you don&#8217;t need Windows to run it. It works great on <a href="http://winehq.com">Wine</a>. I uses a simple serial protocol, these days I am planning to write a simple Python program to replace the Windows program.<br />
<a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/328309725/"><img width="240" height="180" alt="Atmel 89C2051 Programmer" src="http://static.flickr.com/128/328309725_f3b4fa1852_m.jpg" /></a>  <a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/328309729/"><img width="240" height="180" alt="Atmel 89C2051 Programmer" src="http://static.flickr.com/140/328309729_0239667f0d_m.jpg" /></a></p>
<p>When I had once been to Thrissur, <a href="http://www.livejournal.com/users/pramode_ce">Pramode</a> gave me an ATMega8, AVR architecture based microcontroller. This is a very interesting chip. It features in-system programming, thus the higher voltage needed to burn the on-chip Flash memory is generated internally and the device programmer becomes drastically simple. It also has a GCC port and can be programmed in C! The AVR series can also work without an external crysal oscillator circuit, which is optional, if you want to operate in higher frequencies. So for a blinking LED circuit, you only need a couple of resistors and a capacitor apart from the chip and the LED itself. Of course, you need power supply.<br />
<a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/328309731/"><img width="240" height="180" alt="00011" src="http://static.flickr.com/142/328309731_342e200623_m.jpg" /></a> <a title="Photo Sharing" href="http://www.flickr.com/photos/52474473@N00/328309734/"><img width="240" height="180" alt="Tiny computers" src="http://static.flickr.com/140/328309734_1a9dad36af_m.jpg" /></a></p>
<p>Since then, I have also bought myself some ATTiny15L microcontrollers that are tiny 8 pin ones and can clock up tp 1.6MHz. Since most instructions are single cycle, they can execute 1.6 million instructions per second. Just look at the 2051 programmer and at the breadboard, which is an ATMega8 programming circuit, the sheer lack of additional components is striking. That board also serves as a blinking LED test circuit. A blinking LED in microcontroller programming is the usual &#8220;Hello world!&#8221; equivalent.</p>
<p>One microcontroller family I haven&#8217;t touched is the PIC family, need to pic&#8217; it up <img src='http://binarykarma.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2006/12/20/tiny-computers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why I like DOS</title>
		<link>http://binarykarma.org/2006/09/06/why-i-like-dos/</link>
		<comments>http://binarykarma.org/2006/09/06/why-i-like-dos/#comments</comments>
		<pubDate>Wed, 06 Sep 2006 18:19:28 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/19</guid>
		<description><![CDATA[MS DOS is an amazing piece of software. Not because it is a feat of technical achievement, but because it was the most widely used stupid operating system. Is that not difficult to achieve! There have been several instances in history where a particular technology won due to many different factors other than technical excellence. [...]]]></description>
			<content:encoded><![CDATA[<p>MS DOS is an amazing piece of software. Not because it is a feat of technical achievement, but because it was the most widely used stupid operating system. Is that not difficult to achieve! There have been several instances in history where a particular technology won due to many different factors other than technical excellence. Some examples would be the PC Vs Mac, IE Vs Netscape, VHS Vs Betamax, among others. So my dear friends, technical excellence alone, it seems is not enough to see it through the day. DOS itself was bought by Paul Allen from Tim Patterson of Seattle Computer Products from a mere $50,000. It was later &#8220;licensed&#8221; to IBM and eventually to other PC cloners. Microsoft was on its way to global dominance.</p>
<p>I used DOS on my 386 PC to learn C and assembly. DOS can&#8217;t run many programs at once, although there are multi-tasking shells available for it. There are however clever ways of running small programs by hooking on to some interrupt routines. These programs are called TSRs, Terminate, but Stay Resident programs. For example to display a small text clock on a corner of the screen, I once hooked to the timer interrupt, and displayed the time by writing the time string directly into video memory. By hooking what I mean is that you replace the ISR with your own routine, and then you call the old ISR routime, which you before replacing. The timer interrupt is called 18.2 times a second, thus I get a chance to run several times a second without being explicitly executed by any user. The IVT or the Interrupt Vector Table (a table containing the addresses of each Interrupt Service Routine), is located at address 0000:0000 in the x86 architecture, and contains the address of the all the ISRs.<br />
Many &#8220;resident&#8221; viruses use the TSR methodology to do interesting things. The main DOS interrupt is int 0&#215;21. They would hook to it and thus got control every time a system call was made. They then check the syscall number in the AH register. If it was something like the &#8220;exec&#8221; call, they would open the file to be executed and infect it!</p>
<p>When you are learning about programming hardware at a low level, it helps to have an operating system for several reasons. But robust operating systems like Linux or UNIX come in the way of low level programming if you use user level processes. I see DOS more like a monitor, rather than an Operating System. It provides very primitive services of a file system and rudimentary memory management. When your program is running on the CPU, you are on your own and you were free to do anything. This allows for great freedom while you are learning about PC hardware. You can poke around ports, play around with interrupts, write directly to video memory, etc. It was a stage in my learning process that greatly enhanced my knowledge of PC programming.</p>
<p>Although PCs came equiped with the 80386 processor since 1986, DOS never used its full services. The full power of 32 bit processors was used only after Windows &#8216;95 was released. Almost a full decade after the hardware was out! There were some utilities like DPMI that allowed the use of protected mode under DOS, not many programs used it. But DOS applications remained so popular that Intel was forced to design in a feature into its CPUs that allowed DOS to be run within a full protected mode operating system. This feature is the vm86 feature of x86 CPUs, that lets you emulate multiple 8086 processors with a single 80386 or better processor. When you start a DOS box in Windows 3.11/95/98/ME, you are using this feature.</p>
<p>I really wonder if people who learn programming now-a-days are exposed to DOS at all. Since it is really stupid, it forces to budding programmer to be intelligent.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2006/09/06/why-i-like-dos/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Programming Viruses!</title>
		<link>http://binarykarma.org/2006/08/24/programming-viruses/</link>
		<comments>http://binarykarma.org/2006/08/24/programming-viruses/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 17:02:00 +0000</pubDate>
		<dc:creator>Shuveb Hussain</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://binarykarma.org/archives/16</guid>
		<description><![CDATA[My first computer was one based on a 80386 processor clocking 33Mhz. And It had a 80MB hard disk and came with 8MB of RAM. My mother bought me this relic for about Rs.3,500, wondering if this &#8220;computer&#8221; was worth it. Those were days when a desktop cost Rs. 50,000. It was a very old [...]]]></description>
			<content:encoded><![CDATA[<p>My first computer was one based on a 80386 processor clocking 33Mhz. And It had a 80MB hard disk and came with 8MB of RAM. My mother bought me this relic for about Rs.3,500, wondering if this &#8220;computer&#8221; was worth it. Those were days when a desktop cost Rs. 50,000. It was a very old piece, but I was sure that was all I needed. It came with a keyboard with a phone like winding cable and no mouse. It had a strange display called a <a title="CGA" target="_blank" href="http://en.wikipedia.org/wiki/Color_Graphics_Adapter">CGA</a>. This fits somewhere between the MDA and the EGA cards. VGA came later on. Inspite of the powerful, 16 color capable CGA graphics adaptor, the monitor was monochrome. <img src='http://binarykarma.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>The operating system installed was MS DOS 6.22 and I happily played Prince of Persia on it for hours. I was pretty clear what I wanted to do with this PC. I wanted to learn the C programming language beacuse someone had told me that I could write a &#8220;virus&#8221; with it! Man, I was determined. Being a student of B.A English Language and Literature, I had no clue which book to choose, so I went to a bookshop and bought &#8220;C For Dummies&#8221; by Dan Gookin. Well, file I/O wasn&#8217;t there in that book. For that I had to buy the second volume!! That book sure screwed my understanding of C. I guess if someone wants to learn C, why the hell does he have to be a dummy? And if he were a dummy, why on earth does he want to learn C? But anyways, the dummy there was me. Now, having spent years in the industry, I don&#8217;t dare tell anyone how I first learnt C. This is the first time I&#8217;m confessing.</p>
<p>As I spent time with C, I realized that it was not a good language to write viruses with. Parallely I was learning digital electronics, since I wanted to upgrade fro being an analog electronics hobbyist. During this phase, I got interested in Microprocessors and thus assembly language. My favorite assembler was <a title="A86" target="_blank" href="http://eji.com/a86/">A86</a>, due to the lesser red tape it had when compared to TASM and MASM.</p>
<p>I hit the Internet and started downloading source code for DOS viruses. It was a very interesting phase in my learning indeed. I even bought a book on the subject. &#8220;A date with Computer Viruses&#8221; by Nitin Chandra. It was a funky book with source code in assembly for a DOS .COM file virus and a cleaner for that virus writen in C. Both worked as advertised.</p>
<p>The viruses I liked most were Dribble, Ambulance and Casino. Dribble would make characters on the DOS display dribble down and they would get stuck if other characters were encountered during the &#8220;fall&#8221;. Ambulance would send a small ASCII ambulance wailing across the screen at random times. The sound effect simply amazed me. This was from the PC&#8217;s internal speaker, which is literally unused today. Casino was a dreaded and destructive virus. It would basically encrypt the MBR or Master boot record or the Partition Table. This would render the data on the disk unusable. But that is not all. It would get activated on the author&#8217;s birthday, If I recall correctly, and would challenge user to play a slot machine game which it would display. If the user won, the partition table would be restored, or else, the virus displayed a vulgar message and quit! The source code for all these viruses and more is available from <a target="_blank" href="http://www.totallygeek.com/vscdb/">here</a>. Be careful what you do with this stuff.</p>
<p>I did manage to write a DOS .COM virus and I was very proud of myself. However, I never managed to write a .EXE virus, which is bit more difficult to write. Dissecting and playing around with Viruses has taught me a lot &#8211; this was my first look at programs that others had writen and I had learnt a lot from these wierd programmers. In a sense, these viruses were the first &#8220;open source&#8221; programs I saw.</p>
<p>I eventually sold off my 386 based PC and bought a 486 for Rs. 6000. It came with SCO UNIX installed on it. It had no compiler and I complained to the guy who sold it to me. Eventually I installed Linux on to it. It was the beginning of a new story. In the honour of my first computer, my cell phone number ends with &#8220;80386&#8243;.</p>
]]></content:encoded>
			<wfw:commentRss>http://binarykarma.org/2006/08/24/programming-viruses/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

