CPU Lecture from the November 1, 1996 main meeting
Computer Basics - The C.P.U.
- 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
- Central Processing Unit
- Contains the CIRCUITS for arithmetic and logical operations
and for controlling other parts of the system.
- Random Access Memory
- Millions of flip-flops (devices that are either ON or
- Data is usually lost whenever the computer is turned
- 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.
- 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
- 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
- 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
C Language - Factorial 6
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
- CPU.cpp (to be discussed at the November CSIG meeting,
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
- Intel Books and Manuals
- Other Vendors Manuals
- General Computer Books
- ACGNJ SIG's
- C/C++ Users Group
Back to top of Home Page