Professional Documents
Culture Documents
1:
For example:
assume a 4-bit op-code + two 6-bit operands
= one 16 bit instruction
COMP 4—Power Tools for the Mind What’s in the box? 7
E.G.: An ADD instruction in a 16-bit machine language:
0101 110011 111100
Op-code: Operands: (RAM or Register addresses)
0101 110011 111100
• Before it can process a M.L. instruction, the CPU
must fetch it from main memory.
• The CPU must keep track of its position in the
instruction code. It uses a bookmark of sorts.
• The offset at which the next instruction starts is stored
in a special register, called the Program Counter or
Instruction Pointer. Important digression…
– who knows if bits in memory are data or program … ?
– increments to memory address of next instruction ...
COMP 4—Power Tools for the Mind What’s in the box? 8
Putting it all together
Processor: simple minded! repeats same steps over & over...
MACHINE CYCLE: “Instruction-Execution cycle”
Processing of a single machine-level instruction (one
Op Code) in a basic machine.
Input Transistor
Voltage (Switch)
Steady
current
(high)
Ground
(low) Output
Voltage
COMP 4—Power Tools for the Mind What’s in the box? 20
NOR gate (NOT
If both inputs are Low, thenOR)
neither switch is closed, and
Steady current
output is High. (high)
If either input is High, a switch
opens, and output is Low.
Output
Voltage
Input Input
Voltage 1 Voltage 2
1 OR 1 AND 1
Output
Bit
+ 0 AND 0 NOT 1
0
0 1
Carry
You will not have to reconstruct diagrams! Bit
But you should know how to evaluate Boolean ops.
16
How can binary circuits ADD?
1 OR 1 AND 0
Output
Bit
+ 1 AND 1 NOT 0
1
1 0
Carry
Bit
17
What about other operations?
• Subtraction
– Addition using two’s complement representation
• Multiplication
– Repeated addition (with bit shifting)
• Division
– Repeated subtraction (with bit shifting)
e.g.:
Turing
Translat
or
COMP 4—Power Tools for the Mind(Compile What’s in the box? 26
An Analogy
Carbon-based unit
JOHNNY, age 4 (obeys orders to
transform raw material into tasty sandwiches.)
Basic Instruction Set:
Simple commands he can do: Go, Bring, Unwrap, …
Child brain, hands, skills he uses.
Grandpa’s commands:
“Please make 2 p&j sandw’s on rye!”