Introduction to Writing Code by N.D. Pearson

Software programs are used to move data from one location to another with the option of modifying the data during the moving process.

So what is data? Data is information represented by the electronics of the computer. Data is built up from BITs. A BIT can be on/off, true/false, 1/0. On=True=1 and Off=False=0.

Bits are grouped by 4 to make a NIBBLE, by 8 to make a BYTE, and by larger groups to make other data types. The most common grouping is the BYTE.

A string of bits represents a base 2 number.
(i.e. An*2^n + ... + A0*2^0)
So in base 10, 0001 = 1 and 0100 = 4 and 1001 = 9 (1*2^3 + 0 + 0 + 1*2^0)

Strings of 4 bits can be represented a HEX which is a base 16 number system. Hex counts 0 - 9 and then uses A,B,C,D,E, & F for the extra 6 symbols.

Hence

Binary Decimal Hex
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F

Moving between binary and hex is just a matter of grouping bits into sets of 4. So a byte (8 bits) can be represented by two hex symbols.

So where is data? Data is stored in a location identified by an ADDRESS. The address is a unique location. Bits can be used by the computer to define an address or to define data.

Then how is data accessed? Each computer CPU has a list of instructions that are used to Load, Store, and manipulate data. Some CPUs have internal address locations called REGISTERS. Data normally resides in MEMORY. Most instructions move data between a memory location and a register or between registers. Some systems can move data from memory to memory.

The final piece is the Instruction Fetch operation. The CPU has a register that is used as a PROGRAM COUNTER. This counter normally increments for each instruction and is used to generate an address to access the program memory (i.e. where the program is stored).

The data at the address is read into an instruction register and decoded to cause the CPU to EXECUTE the data as an instruction. The next address could contain the next instruction or data that is associated with the current instruction.

So, the process is to put instructions and data in sequence in program memory and start the program counter at the first address of program memory. The computer then executes the program.

The trick, then, is to find the right sequence of instructions to perform the operations on the data to do the task required.