Low-level Programming
Navigation links:
Since everything inside a computer is represented
as numbers, it should come as no suprise that
computer programs are represented as a sequence of
numbers, too. Furthermore, since everything inside
of a computer is a number, all a computer program
really does is move numbers around and do arithmetic
operations them.
Our first program will compute the average of two
numbers. First, let's go through the steps on
a hand-held calculator:
A computer program goes through the exact same steps.
Before we can write our first program we introduce
the concepts of registers, the program counter, and
computer instructions; these topics are discussed in
the sections that follow.
Almost all computers have special memory cells called
registers. For our computer, the first 10 memory
cells in memory are the registers. The registers are
given the uninspiring names of register 0 through
register 9. In addition, the first three registers
in our computer are special and are given the names
`Program Counter', `Stack Pointer', and `Carry'.
Thus, register 0 and the program counter both refer
to the same memory cell.