Saturday, May 19, 2012

Computer Software




Nowadays, most of us are familiar enough with computers to know that they do their magic through something called software. But what is software? And how does it control the computer?
In this article I'll try to answer these question. Actually software consists of one or more stored programs. The reason they are called stored programs is that they reside in some electronic storage device such as RAM, a hard disk, a CD or DVD, a diskette, and so forth. (I explained these devices in last months article, Personal Computer Basics.)

Like everything else in a computer, a stored program is made up of binary numbers, i.e. one and zeros. In a magnetic storage device, such as a hard disk, a one is represented by a tiny spot on the disk magnetized in one direction, a zero by a spot magnetized in the other direction. In RAM, binary bits (numbers) are represented by a flip-flop being in a one state or a zero state. These binary numbers, in addition to representing data such as numbers and letters, can stand for codes  that tell the computer what actions to take. Whether a particular series of binary bits is considered data or an instruction by the computer is determined by a particular time in its cycle. For example, hypothetically let us say that the binary number, 0000 0001, tells the computer to add two numbers together. If the computer is in a data cycle, this byte represents the number one. If the computer is in an instruction cycle, it means add.

I should also mention that the processing (doing the actions coded in the program) always takes place between the CPU and RAM. A computer program must be in RAM before it can be executed (tell the computer what to do). For this reason, programs that are stored on another device such as the hard drive must be transferred into RAM before they can run (a synonym for executed).

When the computer is in its instruction cycle, it normally takes the next instruction in sequence. As you noticed, I did not specify in my hypothetical add instruction what numbers to add or what to do with the result. Usually instruction are more than one byte long. The other bytes associated with this add instruction would contain addresses in RAM where the data to be added is located and where to put the result.

As I noted in the last paragraph, usually instructions in a program are executed in sequence. However, there are numerous exception to this. There are instructions that are called either branch or jump instructions. When the computer executes one of these instructions, it know that it may take the next instruction from a RAM address designated by the branch or jump instruction. Notice that I wrote "may" rather than "will." This is because these type of instructions may test for some condition such as a certain bit in a byte at a certain address being a one. If it is a one, the computer will go to designated address. If not, it will simply take the next instruction. In this manner, the computer can make decisions depending on outcomes, for example, whether you clicked with your mouse or whether a subtraction result in a positive or negative number.

What I have described so far is simply the way that computer instructions work in a general way. If you wish to delve deeper into the subject, I would advise buying a book on computers and programming, because there are a lot of complications to this subject which I cannot get into in this post.

Now you may be feeling sorry for the poor software engineer or programmer who must learn all the binary codes for the instructions in the program he or she writes. Don't worry. Programming is difficult and takes a lot of education to even get started, but at least the programmer does not have to write program instructions using binary codes that a computer understands. There are programs called assemblers and compilers that allow the software engineer to write instructions in what are called computer languages, which resemble human languages slightly, and translates these instructions into the binary instructions that the computer understands. There are several different computer languages. The choice of which to use depends upon such factors as which one the programmer was trained in, the type of software to be produced, the choice of the company that he or she works for and the particular computer and operating system being used.

I used a term in the last paragraph that I did not explain and that is operating system. In general, software can be categorized as either a system program or an application. A system program is software that is part of the operating system of a computer. The operating system in most PCs (unless you're a Mac or Linux user) is Windows. The operating system handles such things as multitasking, input/output operations, presenting a standard interface for applications and so forth. An application is the software that a computer user calls up to do the computing work to be done. For example, the word processor that I'm using to write this article is an application. Usually, we speak of applications running under the operating system.  This is because the operating system decides when to execute instructions in a particular application and does tasks for the application such as retrieving data or other programs from the hard disk.

I hope you found this article informative, accurate and enlightening. The whole subject of software design and coding can be quite interesting, and there are a multitude of books available plus online tutorials that cover this material.

No comments: