Friday, September 19, 2008

BASIC

So, how many of you out there have actually written program code in BASIC? I know it's pretty much a dead language, but there are many different types of microprocessors out there that actually eat the stuff for lunch. I'm taking an Enterprise Infrastructure course in this, my last semester of college. It's pretty fun so far. Our first assignment involved writing a couple very simple programs in BASIC, compiling them to assembly and then running them through a microprocessor simulation. It's interesting. Here's a code snippet:

image

So, this program very simply creates a counter variable which increments and outputs to a port. The final variable outputs alternating 1's and 0's to a port upon completion of the counter. Obviously, the counter is designed to count up to 9, and then kick to the end of the if statement and loop.

Here's a slightly more complex program:

image

This program starts with a word variable (2 byte variable) which responds to the input from port d. If port d is lit up, meaning it returns a value of 1 from the bit in the zeroth location, it will increment the counter by three and output the high bits to port c and the low bits to port b. Meaning that port c doesn't light up until the value is at least 256, or beyond the storage capacity of one byte.

It's interesting to look at this. It may as well be sudocode. I mean, I barely had to think too much about the complication of the code, and realize that BASIC was a simple program to write in. It is not object oriented like Java or C++ or even VB, however, it is a simple language. As I write more in BASIC, I will have to deal with such things as memory deletion, clean up, and memory buffering. That's the ugly part of simple languages.

I'll post more as I learn more.

/coding

Add: By the way, if you want to play with some BASIC programming, you can check out www.oshonsoft.com for a pic simulator (pic is a microprocessor for many different industrial uses). It's fun!

1 comment:

Amanda P said...

I'm pretty sure that was like reading another language!!! But your enthusiasm made it worth reading.