CPU Lecture from the November 1, 1996 main meeting
Computer Basics - The C.P.U.
Bruce Arnold
COMPUTER:
- A device capable of performing a series of arithmetic
or logical operations and controlled by a written program.
The four major physical components:
- Central Processing Unit (CPU)
- Main storage - RAM
- Auxiliary storage - ROM, CDROM, DISK, and TAPE
- Input/Output devices - Keyboard, Screen and Printer
CPU
- Central Processing Unit
- Contains the CIRCUITS for arithmetic and logical operations
and for controlling other parts of the system.
RAM
- Random Access Memory
- Millions of flip-flops (devices that are either ON or
OFF.)
- Data is usually lost whenever the computer is turned
off.
- Also called "Read & Write Memory".
ROM & CDROM
- Read Only Memory
- Compact Disk Read Only Memory
- Memory is fixed and cannot change.
DISK & TAPE
- Magnetic disk drives, floppies, and tape drives.
- Data remains permanent even if power is removed.
- Data may be written any number of times.
Keyboard
- An input device consisting of many switches.
Screen & Printer
- Output devices
- Logic and hardware
- Capable of making alpha-numeric characters and graphics
appear on a video screen or on paper copy.
Understanding the CPU
- Basic parts
- Let's make one!
- A sample program
Basic parts
- BUS UNIT - Reads program and data.
- INSTRUCTION UNIT - Decodes instructions.
- EXECUTION UNIT - Acts on instructions using Registers,
Control Logic, and A.L.U.
- A.L.U. - Arithmetic Logic Unit
Let's make one! - A sample CPU
- Five (5) Registers -
- Seven (7) Instructions -
- ADD, MUL, MOV, DEC, JZ, JNZ, PRT
- Data - 16 bit information
- Numeric Range - 0 to 65535
Instruction Set
- ADD reg, reg ..........; Add 2 registers
- MUL reg, reg ..........; Multiply
- MOV reg, reg ..........; Move
- MOV reg, immediate ....; Assign value
- DEC reg ...............; Decrement by 1
- JZ step ...............; Jump if zero
- JNZ step ..............; Jump if not zero
- PRT reg ...............; Mystery Print
A sample program - "Factorial 6"
- MOV AX,1
- MOV CX,6
- MUL AX,CX
- PRT AX
- DEC CX
- JNZ -4
- PRT CX
Machine Language - Factorial 6
- :0100 B80100
- :0103 B90600
- :0106 F7E0
- :0108 40
- :0109 49
- :010A 75F3
- :010C 41
Quick Basic - Factorial 6
- LET AX = 1
- FOR CX = 6 TO 1 STEP -1
- AX = AX * CX
- PRINT AX
- NEXT CX
- PRINT CX
- END
C Language - Factorial 6
void main()
{
unsigned int AX = 1, CX;
for ( CX=6; CX > 0; CX-- )
{
AX = AX * CX; printf ("%d \n", AX);
}
printf ("%d \n", CX);
}
The C++ CPU Emulator Program
- An IBM compatible software program which will "run"
the "Factorial 6" program code.
- Based on the Instruction Pointer (IP), the emulator steps
through each line of the program, decodes the instruction and executes
it.
- CPU.cpp (to be discussed at the November CSIG meeting,
3rd Tuesday.)
CPU Emulator Program - FLOW
- READ the instruction where the IP points.
- DECODE or INTERPRET the instruction.
- EXECUTE the instruction.
- MODIFY registers (IP, etc.) as required.
- Repeat forever
More information
- Intel Books and Manuals
- Other Vendors Manuals
- General Computer Books
- ACGNJ SIG's
- C/C++ Users Group
Back to top of Home Page