-------Mantissa------- Exponent
Note: Precision
ASCII
ASCII is a standard that assigns numeric codes to printable characters
so we can store text in a computer.
ASCII use 8 bits = 1 byte per character.
1 Borland C++ word = 4 bytes => each word can hold 4 characters.
Computer Architecture
Note: Picture
Central Processing Unit (CPU)
Controls the operation of the entire system.
Performs arithmetic and logical operations
Stores and retrieves data and instructions
The CPU is the thing that actually executes instructions.
A CPU has:
Registers
Program counter
Control unit
Stack pointer
ALU
Cache memory, small (usually < 1 meg) but extremely fast
...
Main memory
Stores instructions and data
Adressable
Much larger than cache (16-128 Meg), but slower
Volatile storage
Secondary storage
Much larger than main memory, but much slower
Randomly accessable or sequential
Floppy disk, hard drive, CD-ROM, magnetic tape, paper tape, punchcards
Non-volatile storage
Input/Output devices (I/O)
Transmit information to and from the computer
How we interact with the computer
Accessed through special hardware registers
Monitor, keyboard, mouse, joystick, light pen, printer, speakers, etc.
Coding, Compiling, Executing
-
High-level languages
- Provide high-level abstractions for data and algorithms
- Facilitate creation of complex programs
- Examples: C++, Lisp, Basic, Fortran, Pascal, etc.
- Example: x = ((x * y) + z);
-
Assembly language
- Low-level abstractions for data and algorithms
- Often just mnemonics for actual machine instructions
- Close to machine representation -> efficient
- Example:
- LOAD a,$x
- MULT a,$y
- ADD a,$z
- STORE a,$x
-
Machine instructions
- This is the representation that the CPU understands.
- 1's and 0's, including instruction and data
- Opcodes and operands
- Example:
- Data:
- 4 = 100b
- 5 = 101b
- 6 = 110b
Opcodes:
- LOAD = 16 = 00010000b
- STORE = 17 = 00010001b
- ADD = 35 = 00100011b
- MULTIPLY = 36 = 00100100b
- Instructions:
- 0001000000000100 ----- Load the value in memory location 4 into the accumulator
- 0010010000000101 ----- Multiply the value in the accumulator by the value in memory location 5
- 0010001100000110 ----- Add the value in memory location 6 to the value in the accumulator
- 0001000100000111 ----- Store the value in the accumulator into memory location 7
-
Executing an instruction
- Fetch instruction
- Fetch operands
- Decode instruction
- Execute operation
- Store result
A Compiler
Converts a high-level program into a list of machine instructions
The list of machine instructions is called an executable file
All of the variable and function names are converted to addresses
When we execute a file
The contents of the executable file are placed in memory
The operating system begins executing instructions at a pre-specified place in memory.
The CPU executes instructions, one after the other, until the program is finished.
Each instruction
Has an opcode and zero or more operands
The instructions can:
Load values from memory into registers
Operate on the registers
Store values into memory
Special instructions modify PC to jump, branch, etc.
Review