Coos Unit-1
Coos Unit-1
Laptop computer
LOC A, R1
ADD R1,R0
STEP 3: add
* Data
- Numeric Data
Numbers( Integer, real)
- Non-numeric Data
Letters, Symbols
* Program(Instruction)
Data
Numeric data - numbers(integer, real)
Non-numeric data - symbols, letters
Number System
Nonpositional number system
- Roman number system
Positional number system
- Each digit position has a value called a weight
associated with it
- Decimal, Octal, Hexadecimal, Binary
Base (or radix) R number
- Uses R distinct symbols for each digit
- Example AR = an-1 an-2 ... a1 a0 .a-1…a-m
▣ Binary numbers(0’s and 1’s)
▣ Decimal numbers(base or radix as 10)(0-9)
▣ Octal decimal numbers(base or radix as 8)(0-8)
▣ Hexa decimal number(base or radix as 16)(0-16)
1 1 0 0 1
23 22
21 20
1* 20=1
▣ 0* 2 =0 1+0+0+8+16=25
1
▣ 0*2 =0
2
▣ 1*2 =8
3
▣ 1*2 =16
4
Separate the number into its integer and
fraction parts and convert each part
separately.
- Convert integer part into the base R number
→ successive divisions by R and accumulation
of the remainders.
- Convert fraction part into the base R number
→ successive multiplications by R and
accumulation of integer digits
Convert 41.687510 to base 2. Fraction = 0.6875
Integer = 41 0.6875
x 2
2 41 1.3750
20 1 x 2
10 0 0.7500
5 0 x 2
2 1 1.5000
1 0 x 2
1.0000
Hexa to decimal
(F3)16 = 3*𝟏𝟔𝟎 +15*𝟏𝟔𝟏=3+240= (243)10
Two types of complements for base R number system:
Example
- 9's complement of 83510 is 16410
- 1's complement of 10102 is 01012(bit by bit complement operation)
Example
- 10's complement of 83510 is 16410 + 1 = 16510
- 2's complement of 10102 is 01012 + 1 = 01102
Numbers: Fixed Point Numbers and Floating Point Numbers
Binary Fixed-Point Representation
- Following 3 representations
-9 1 0110 9 0 1001
+) -9 1 0110 +) 9 0 1001
1 (1)0010
(1)0 1100
+) 1
0 1101
overflow
39
Arithmetic Subtraction in 2’s complement
EXPONENT MANTISSA
SIGN
=== Example: +6132. 786= 0.6132786*104
M *𝑟 𝑒
Fraction Exponent
+0.6132786 +04
EXAMPLE: floating point binary representation:
Fraction Exponent
01001110 000100
Shift
An elementary operation performed on data stored in on
Load
Clear
Increment
Count
▣ A register transfer language is system of expressing
in symbolic form which can perform micro operation
among registers of digital computers
7 6 5 4 3 2 1 0
Fig (d): partitioning of register where (7-4) are higher bits and (0-3) are lower bits
Information transfer from one register to other is represented in symbolic form
shown below
R2 R1
R2 R1
P: R2 R1
It is assumed that all the transfer occurs during clock edge transition . The
actual
Transition occurs only when register is triggered by the positive transition of
the
clock
Basic symbol of register transfer is shown in below box
Control input C
Output of four buffers are connected to form a single bus line
Control input to the buffer which of the four normal inputs will communicate
with bus line
At time one buffer can produce the output rest all will be in high
impedance state( open circuit)
If s0s1=00 data of register A will be transfer to bus line
If s0s1=01 data of register B will be transfer to bus line
S0s1=10 register C data is transferred, s0s1=11 register D data will transfer
Most of the standard notations used for specifying operations on memory
transfer are stated below.
The transfer of information from a memory unit to the user end is called a
Read operation.
The transfer of new information to be stored in the memory is called a
Write operation.
A memory word is designated by the letter M.
We must specify the address of memory word while writing the
memory transfer operations.
The address register is designated by AR and the data register by DR.
read operation can be stated as:
Read: DR ← M [AR]
The Read statement causes a transfer of information into the data register (DR)
from the memory word (M) selected by the address register (AR).
Write: M [AR] ← R1
The Write statement causes a transfer of information from register R1 into the
memory word (M) selected by address register (AR).
Computer system micro operations are of four types:
A3 A2 A1 A0
1 1 1 1
1 0 1 1
+
1 1 0 1 B0
1 0 0 0
S3 S2 S1 S0
The bits (A) and (B) are inputs and designated by subscript numbers from right
to left, with subscript '0' denoting the low-order bit.
The carry inputs starts from C0 to C3 connected in a chain through the full-adders
and given as an input to next full adder.
C4 is the resultant output carry generated by the last full-adder circuit.
The output carry from each full-adder is connected to the input carry of the
next- high-order full-adder.
The sum outputs (S0 to S3) generates the required arithmetic sum
4 –bit binary adder - subtractor
A-B= A+(B’+1)
B XOR 0 = B
B XOR 1= B’
The circuit consists of 4 full adders since we are performing operation on 4-bit
numbers. There is a control line K that holds a binary value of either 0 or 1 which
determines that the operation being carried out is addition or subtraction.
4-bit Binary incrementer:
R2 1 0 1 0
1 0 1 1
Equivalent to OR operation
example 2 R1 1 1 0 0
R2 1 0 1 0
1 1 1 0
SELECTIVE COMPLEMENT
1100 At
1010 B
0100 At+1 (A A B’)
1100 At
1010 B
1000 At+1 (A A B)
1 1 0 0 At
1010 B
0 1 1 0 At+1 (A A B)
INSERT OPERATION(MASKING +OR)
An insert operation is used to introduce a specific
bit pattern into A register, leaving the other bit
positions unchanged
This is done as
A mask operation to clear the desired
bit positions, followed by
An OR operation to introduce the new
bits into the desired positions
Example
Suppose you wanted to introduce 1010 into the low
order four bits of A: 1101 1000 1011 0001 A (Original)
1101 1000 1011 1010 A (Desired)
LEFT SHIFT
A right logical shift operation:
In a Register
Transfer Language,
the following
notation is used
shl - for a
logical shift left
Shr-for a
A left logical shift operation logical shift
right
Examples:
R2 shr R2
R2 shl R2
Left circular shift
Right circular shift
ARITHMETIC SHIFT
ARITHMETIC RIGHT SHIFT
Computer Registers
Computer Instructions
Instruction Cycle
15 0
4095
INSTRUCTIONS
Program:
A sequence of (machine) instructions
(Machine) Instruction:
A group of bits that tell the computer to perform a specific
operation (a sequence of micro-operation)
15 14 12 11 0
I OPCODE ADDRESS
S2 S1 S0 Register
0 0 0x
0 0 1 AR
0 1 0 PC
0 1 1 DR
1 0 0 AC
1 0 1 IR
1 1 0 TR
1 1 1 Memory
BASIC COMPUTER INSTRUCTIONS
Symbol I=0 I=1 Description
- D7 = 1, I = 0
- Register Ref. Instr. is specified in b0 ~ b11 of IR
- Execution starts with timing signal T3
r = D7 IT3 => Register Reference Instruction
Bi = IR(i) , i=0,1,2,...,11
r: SC 0
CLA rB11: AC 0
CLE rB10: E0
CMA rB9: AC AC’
CME rB8: E E’
CIR rB7: AC shr AC, AC(15) E, E AC(0)
CIL rB6: AC shl AC, AC(0) E, E AC(15)
INC rB5: AC AC + 1
SPA rB4: if (AC(15) = 0) then (PC PC+1)
SNA rB3: if (AC(15) = 1) then (PC PC+1)
SZA rB2: if (AC = 0) then (PC PC+1)
SZE rB1: if (E = 0) then (PC PC+1)
HLT rB0: S 0 (S is a start-stop flip-flop
MEMORY REFERENCE INSTRUCTIONS
Operation
Symbol Decoder Symbolic Description
AND D0 AC AC M[AR]
ADD D1 AC AC + M[AR], E Cout
LDA D2 AC M[AR]
STA D3 M[AR] AC
BUN D4 PC AR
BSA D5 M[AR] PC, PC AR + 1
ISZ D6 M[AR] M[AR] + 1, if M[AR] + 1 = 0 then PC PC+1
RECEIVER
PRINTER INTERFACE OUTR
AC
D7IT3 = p
IR(i) = Bi, i = 6, …, 11
p: SC 0 Clear SC
INP pB11: AC(0-7) INPR, FGI 0 Input char. to AC
OUT pB10: OUTR AC(0-7), FGO 0 Output char. from
SKI pB9: if(FGI = 1) then (PC PC + 1) AC Skip on input
SKO pB8: if(FGO = 1) then (PC PC + 1) flag Skip on output
ION pB7: IEN 1 flag Interrupt enable
IOF pB6: IEN 0 on Interrupt enable
off
Open communication only when some data has to be passed -->
interrupt.
The I/O interface, instead of the CPU, monitors the I/O device.
When the interface founds that the I/O device is ready for data
transfer, it generates an interrupt request to the CPU
Stack start
REVERSE POLISH NOTATION
It is like post fix notations that all the operators are moving
towards right
For example: A + B
P+Q -RS/
PQ+ - RS/==== PQ+RS/-
EXAMPLE: (A+B)*(C-D)
AB+ * CD-
AB+CD-*
INSTRUCTION FORMAT
OP-code field - specifies the operation to be performed
Address field - designates memory address(es) or a processor register(s)
Mode field - specifies the way the operand or the
effective address is determined
The number of address fields in the instruction format
depends on the internal organization of CPU
-The three most common CPU organizations:
Instruction Format
Single accumulator organization:
ADD X /* AC ← AC + M[X] */
General register organization:
ADD R1, R2, R3 /* R1 ← R2 + R3 */
ADD R1, R2 /* R1 ← R1 + R2 */
MOV R1, R2 /* R1 ← R2 */
ADD R1, X /* R1 ← R1 + M[X] */
Stack organization:
PUSH X /* TOS ← M[X] */
ADD
Instruction Fields
THREE, AND TWO-ADDRESS INSTRUCTIONS
Three-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
Zero-Address Instructions
- Can be found in a stack-organized computer
- Program to evaluate X = (A + B) * (C + D) :
PUSH A /* TOS ←A */
PUSH B /* TOS ←B */
ADD /* TOS ← (A + B) */
PUSH C /* TOS ←C */
PUSH D /* TOS ←D */
ADD /* TOS ← (C + D) */
MUL /* TOS ← (C + D) * (A + B)
*/
POP X /* M[X] ← TOS */
ADDRESSING MODES
The operation field of an instruction specifies the operation to be performed.
This operation must be executed on some data stored in computer registers or
memory words. The way the operands are chosen during program execution
in dependent on the addressing mode of the instruction.
The addressing mode specifies a rule for interpreting or modifying the address
field of the instruction before the operand is actually referenced.
Examples-
note-
This addressing mode is similar
to indirect addressing mode.
The only difference is address
field of the instruction refers to a
CPU register. Example: AC ← AC +
[R]
note-
This addressing mode is similar to
indirect addressing mode.
The only difference is address field of
the instruction refers to a CPU
register. Example: AC ← AC + [[R]]
7. Relative Addressing Mode-
NOTE-
• Program counter (PC) always contains the address of the next instruction to be executed.
• After fetching the address of the instruction, the value of program counter immediately
increases.
• The value increases irrespective of whether the fetched instruction has completely executed or
not.
8. Indexed Addressing Mode-
In this addressing mode,
•Effective address of the operand is obtained by adding the content of index register with the
address part of the instruction.
Effective Address
= Content of Index Register + Address part of the
instruction
9. Base Register Addressing Mode-
In this addressing mode,
•Effective address of the operand is obtained by adding the content of base register with the
address part of the instruction.
Effective Address
= Content of Base Register + Address part of the instruction
10. Auto-Increment Addressing Mode-
•This addressing mode is a special case of Register Indirect Addressing Mode where-
In this addressing mode,
•After accessing the operand, the content of the register is automatically incremented by step
size ‘d’.
•Step size ‘d’ depends on the size of operand accessed.
•Only one reference to memory is required to fetch the operand.
Examples: I/O Device -> Data transfer request or Data transfer complete
- Timing Device -> Timeout
- Power Failure
- Operator
For any given level of general performance, a RISC chip will typically have far fewer
transistors dedicated to the core logic which originally allowed designers to increase
the size of the register set and increase internal parallelism
RISC designs are also more likely to feature a Harvard memory model, where the
instruction stream and the data stream are conceptually separated; this means that
modifying the memory where code is held might not have any effect on the
instructions executed by the processor (because the CPU has a separate instruction
and data cache