Pitacalc on Projects Section

October 8th, 2007

Pitacalc has its own section under the Projects at coobird.net!

Additional updates may or may not be posted on this blog.

Past Programs – Cannons for Windows 1.5

September 29th, 2007

Past Programs - Cannons for Windows 1.5

Cannons for Windows is one of those classic “tank firing a cannon ball at a target” game. This is one of the older versions of the game which was based off of code handed to students attending a after-school computer club when I was 5th grade. We were told to follow a series of directions on paper and copy down the source code into a form in Microsoft Visual Basic. Most of the code dealt with the projectile motion and the target hit detection, something that you wouldn’t expect an elementary school student to come up with on his or her own.

My version added a few “features” such as wind which would push the shell back toward the cannon. The wind was adjusted by sliding the scroll bar to the desired wind strength. Also, a picture box was added next to the wind scroll bar which would show a drawing of wind blowing on a house. The problem with that feature was that it only changed the drawing when the user clicked on the box and had a floppy disk with the drawings of the house in various wind levels. Of course, all these were a result of not really knowing much about events, properties of controls, etc. (But then again, can you expect too much out of a 11 year old kid?)

  • Language: Microsoft Visual Basic 3.0
  • Date: March 1995
  • Platform: Microsoft Windows 3.1

Past Programs – Luckfinder 2

September 28th, 2007

Past program thumbnail 1

Luckfinder 2 was a text adventure game where the player goes through a pretty much pre-determined route with very little deviations from the one-dimensional game play. (Basically one had to just remember not to go back the same direction, i.e. if you went south in the last move, just don’t go back north.)

At the time, I was playing a text adventure game called Wishbringer by Infocom, and was influenced into writing a game that was similar.

The game was written in QBasic around 1994. I remember writing this on my father’s 386 Toshiba laptop, back in the days when 486 desktops were prominent. Pentium-based computers were available, but those computers were top-of-the-line and were very expensive. If memory serves right, the fastest x86 processor at the time was a 66 MHz Pentium.

(If it weren’t for the horribly broken English, I would show the introduction, but as I said, it’s horribly broken English, so I’m too embarrassed to show the introduction screen. End of story.)

  • Language: Microsoft QBasic
  • Date: 1994?

Past Programs Gallery

September 28th, 2007

Past program thumbnail 1Programming has been my hobby since I was in elementary school. I started out watching my friends who were writing programs by pecking at the keyboard of the 386 machines at school. This is back in the days of DOS, where most programs were still being written in text mode and graphics were primative. (In retrospect, graphics in DOS was really awesome. The ability to directly manipulate the graphics adapter is not possible with modern operating systems.)

Past program thumbnail 3I haven’t had much formal education in computer programming except for a semester here and few quarters here, but it has been an activity that I’ve enjoyed for a long time. Most of my programming knowledge has been self-taught, but I really think I’ve benefitted from the few classes I’ve taken.

I’ll be posting some of the programs I’ve worked on over the years, along with some thoughts that come up.

Pitacalc (Part 3)

September 28th, 2007

As mentioned in the previous post, Pitacalc is able to adjust the number of registers the calculator uses. This register bank resizing feature can be performed by using the rrb instruction.

Pitacalc - Resizing the registers

As one can see above, using the reg command, there are ten registers by default. By typing in rrb 5 to perform a register resize, the subsequent reg command shows there are five registers. The rrb 12 and the following reg shows 12 registers. It is possible have anywhere from 1 to 100 registers with Pitacalc.

More features have been added since the last post. The current build, 309, contains new features such as color mode for the console and output in HTML format.

Pitacalc is not a particularly useful tool that has many uses, but it does demonstrate how a computer performs calculations at the low level. Using Pitacalc is similar to programming a computer to do calculations in assembly language. Although actual computers don’t work exactly like Pitacalc, having to enter instructions to perform calculations are similar.

Pitacalc (Part 2)

September 27th, 2007

There are certain aspects that regular calculators do not have that Pitacalc does. For example, Pitacalc has multiple registers which can be used to store values. These values can be set by using an appropriately named set instruction.

Pitacalc - Setting registersBy typing specifying the register when performing the set instruction, one can set a value of the register. For example, to set the register r0 to the value 10, type set r0 10 and press enter. As can be seen on the right, the line after the set instruction is a 0. This zero is the value stored in the accumilator. After executing any instruction, the value stored in the accumilator is returned. This is unaffected by the setting of register r0, hence the accumilator stays zero.

To check that register r0 was set to 10, we can use the reg instruction to show all the registers and their stored values. We can see that r0 is indeed set to 10. Another way to check the value of a specific register, just type in the name of the register. Here, typing in r0 gives us the value 10.

Pitacalc also allows renaming of registers. Any practical reasons? Perhaps the following image may illustrate one use:

Pitacalc - 42

Here, the registers which had the default name of r0 through r6 were renamed to words. In this aspect, the registers work a little bit like variables in computer programming.

Renaming a register is performed by the ren instruction. By typing the register name to change followed by a new name, a register can be renamed. For example, in the above example, register r6 was renamed to Everything. The instruction executed to perform the rename was ren r6 Everything.

Are ten registers not enough? No need to worry. Unlike a real world calculator, it’s possible to increase the number of registers with Pitacalc, up to 100. (Even this is an artificial limit that can be changed with minor changes in the program.) We’ll get into resizing the register bank next time.

Pitacalc – a command line interface calculator

September 27th, 2007

Pitacalc is a command line interface calculator program. It’s works like a regular calculator by performing arithmetic operations and having an accumilator that keeps the running total. It also has several registers that can be used to temporarily store values.

For those who are interested, the calculator is a Win32 console application, so it should run on Windows 95 and higher. Maybe even NT 4; not that I’ve tried.

Pitacalc Image 1Arithmetic operations are performed by typing in instructions. For example, to set the accumilator to 100, one would type in set 100. To add 200 to that value, one would type in add 200. The result of 300 shows up on the line following the add 200 line.

Although the example only shows adding one value to the accumilator, it is possible to add more than one value at a time to the accumilator. For example, by typing sub 100 200, the result of 0 will be returned.

Basically I was writing this calculator as practice programming in C. After programming in Java fairly exclusively for the past year or so, I thought it was time to brush up on some good ol’ C. Having to juggle around pointers between functions and calling malloc at every corner was loads of fun. (Please note the sarcasm in the previous sentence.)

Just to add useless features, the program accepts “scripts” of instructions to execute. Conversely, the output of the program can be dumped into an external file. I can’t think of any real use for this feature. Pitacalc has many features that really don’t have any real purpose.

Over the next few posts, I will introduce the great features (yes, that’s an overstatement) of Pitacalc. The current version 0.0.1 build 257. I’ll be adding more features (yes!) so the current version in the future will probably not be build 257.

Why I use OpenOffice.org

May 20th, 2007

I don’t have Microsoft Office installed on my computer. Almost every time I mention that to someone, I am greeted by a surprised look. “You don’t have Word? No Excel?” Yes, I have neither Word nor Excel installed on my computer. However, I do have OpenOffice.org.

For the past few years, I’ve been using the OpenOffice.org application suite on my PC. During my high school years, I recall using Microsoft Works, which was adequate for my school work. When I read about OpenOffice.org back around 2002, I went ahead and downloaded it and have been sticking to it ever since.

Why do I insist in using OpenOffice.org? First and foremost, Microsoft Office costs money. This was the primary factor that lead me to choose OpenOffice.org over Microsoft Office. Being a college freshman without a job, I couldn’t afford to go spend hundreds of dollars on an application suite. I’m more than aware that I don’t need to look far to find a pirated copy of Office, like many people I know, but I would rather not go that route. Fast forward a few years, now I could afford to buy Office, but I would rather not spend it when I have an acceptable alternative like OpenOffice.org.

The main gripe I’ve had lately with Microsoft Office is its pricing. I’m aware that the Home and Student edition of Office is available in the neighborhood of $150, but that is still a little bit steep for a piece of software that I don’t really actually want. However, if Word and Excel were available for $30 a piece, I would probably be willing to shell out the cash to avoid dealing with the annoyances of incompatibilities in importing and exporting Office documents. (Those incompatibilities of course stem from the fact that Microsoft keeps its file formats a close secret, preventing interoperability with other applications. Don’t get me started on this one!)

OpenOffice.org has been my office application suite for the past few years. I’ve written countless reports on it and haven’t had much problem except for some lack of features in the spreadsheet application. The cost of Microsoft Office isn’t as a big issue as the past, but I’m not very willing to spend a large amount of money on a piece of software that I don’t actually want to use in the first place. That’s what keeps me an OpenOffice.org user.

Internet Explorer .NET?

December 26th, 2006

Over the past few years, Microsoft’s Internet Explorer has had a series of security vulnerabilities that made users susceptible to, at worst, remote code executions, which could allows malicious programs to run on the user’s computer without user intervention.

A buffer overflow is one of the ways to allow remote code executions to occur. In a nutshell, a buffer overflow occurs when program allocates some space in memory to store data, but the amount of data received is larger than the allocated memory, causing an “overflow” of data onto other parts of the memory, which may end up being a portion that the operating system has marked for executable data.

When programs are properly written, buffer overflows shouldn’t happen. The program should be validating the incoming data and only accept enough data that it won’t cause a buffer overflow. However, it’s easy to overlook security issues when the objective is to write a piece of software that runs and does its job.

Internet Explorer has has its share of buffer overflow problems. It is a large piece of software that has been developed over a long period of time, small security problems are likely to exist all over the browser.

One way to eliminate a buffer overflow type error is to use a platform that doesn’t allow buffer overflows to occur. Microsoft’s .NET Framework Common Language Runtime (CLR) is one such platform. Like Java which uses bytecode and a Java Virtual Machine to execute programs, the CLR runs as a virtual machine, which runs applications written and compiled for the .NET platform. The virtual machine performs checks on data that is being processed, and if it finds a problem, an exception will be thrown which in turn must be dealt with in some way.

Microsoft may want to consider start rewriting Internet Explorer with .NET. Running the browser on a virtual machine itself may already take a lot of the security risks that arise from exploits that use buffer overflows. There are of course other security issues that Internet Explorer have due to the features it support, such as ActiveX controls which can execute code directly on the user’s computer.

It may be interesting to note writing services in Windows with .NET and running it on the CLR was one of the original plans for Windows Vista, but eventually that was tossed out as it approached release.

Rewriting Internet Explorer may be a radical step to take, but considering that it is the browser with the top market share means that it should be taking the security of its software seriously. Writing Internet Explorer for the .NET Framework may be one way that Microsoft can be a responsible citizen and provide a product that is a little bit safer than it is today.

Dolphin saved, goes extinct, and sleepless

December 14th, 2006

According to the BBC, the world’s tallest man, Bao Xishun, saved a dolphin by extracting a piece of plastic that it had ingested. Officials at the aquarium in Fushun, Liaoning Province, China said that the plastic in the dolphin’s stomach was causing it to lose appetite and suffer from depression. Bao, with his long arm, spanning over a meter, was able to extract most of the plastic and according to officials, the dolphin is in good condition now.

In another dolphin news out of China today, it appears that the world has lost another threatened specie, the Yangtze River dolphin has been declared “functionally extinct” after a six week search for the freshwater mammal turned up no sightings. For more information on the Yangtze River dolphin, baiji, take a look at the Wikipedia article.

Finally, did you know that unlike most mammals, dolphins do not undergo REM sleep? As it turns out, dolphins actually need to consciously breathe, unlike others such as humans which breath involuntarily. As it turns out, dolphins will actually put one hemisphere of their brain to sleep while the other hemisphere continues to “stay awake,” possibly to continue vital functions such as breathing.