CSC 150 UNGRADED QUIZ - Concordia University Wisconsin
Download
Report
Transcript CSC 150 UNGRADED QUIZ - Concordia University Wisconsin
PROCESSOR UNIT I
(1) Job of the processor unit.
(2) How can it do this?
(3) Binary translation schemes
[base 2, ASCII, machine code].
1. Job of the processor unit.
A. Review the diagram of the processor
unit’s CPU and memory.
B. The job of the CPU is to fetch and
execute program instructions from RAM.
The control unit does the fetch and execute.
The ALU does arithmetic and logic.
As the instructions are executed, data is
turned into information.
2. How can the processor unit
do this?
A. In order to run a program:
All program instructions and data must be
loaded into RAM.
BUT
1) The CPU only “understands” binary
Therefore?
2) All data and instructions must be in
binary form.
3. Binary translation schemes.
There are 3 main things which need to be
translated:
1) NUMBERS
2) CHARACTERS
3) PROGRAM INSTRUCTIONS.
Each has its own binary translation scheme.
Binary schemes.
ITEM
1) NUMBERS
2) CHARACTERS
3) INSTRUCTIONS
TRANSLATION
SCHEME
1) BASE 2 BINARY
FORM.
2) ASCII BINARY
FORM
3) MACHINE
LANGUAGE
BINARY FORM
3.1 Base 2 binary form.
Numbers are represented in Base 2.
What is the idea of base 2?
Compare base 10.
Base 10:
1) 10 digits (0-9)
2) Place values are powers of 10
e.g. 3
4
5
100 10 1 <---- place values.
Base 2 binary form continued.
Base 2:
1) 2 digits (0-1)
2) Place values are powers of 2
e.g. 1
0 1 1 0 1
32 16
8
4
2
1 <--- place values.
Base 2 binary form continued.
Example:
What is the following binary number
equivalent to in base 10?
1 0 1 0 1 1
0
Base 2 binary form continued.
Recall 1 byte = 8 bits.
Largest number in 1 byte
1111 1111 = 255
[can store 256 numbers 0-255].
In 2 bytes?
1111 1111 1111 1111
Hint: the 16th place value = 32,768.
Base 2 binary form continued.
Counting in binary.
0
1
10
11
100
101
3.2. ASCII binary form.
For characters, a coding scheme is used,
such as as ASCII.
Character
Code.
Binary
‘0’
48
110000
‘9’
57
111001
‘A’
65
1000001
‘Z’
90
1100001
ASCII binary form continued.
Every character has a code, whether
printing or not.
Character
Code Binary
E.g. “Return”
10
1010
“Line feed” 13
1101
“Escape”
27
11011
ASCII binary form continued.
But now there is a problem. Binary strings
are now ambiguous. E.g. What is
100001
A number?
Or
A character
65 in Base 2
ASCII 65 = “A”
How does the H/W know?
ASCII binary form continued.
By itself, the H/W does not know!
The S/W has to tell the H/W how the data is
to be interpreted. E.G. in C++,
descriptors are used to specify the data type.
char Name[20]
float Amount;
[character string]
[number]
3.3 Instructions.
A. Each instruction in the S/W is translated
into 1 or more binary instructions, e.g.
ADD = 01001100.
B. Problem. How does CPU distinguish
instructions and data?
By position.
Instructions continued.
INSTRUCTION:
(Add what is in the variable located in 0100
to what is in the variable located in 0101)
Operator
Operands
01001100
0100 0101
[memory locations]
See diagram.
Instructions continued.
How does the compiler translate source
code into binary code?
It uses a dictionary, which translates
HIGH-LEVEL instructions in a
programming language (e.g. ADD, PRINT)
into LOW-LEVEL binary instructions.