Microprocessors - III: Yashar Hajiyev
Microprocessors - III: Yashar Hajiyev
Microprocessors - III: Yashar Hajiyev
Yashar Hajiyev
Microprocessor Structural Organization
(architecture)
General
OPCODE part of instruction that specifies the operation to be performed is called the
operation code or Opcode;
OPERANDdata on which the operation is to be performed is called as an Operand.
General
The output of each register is connected to two multiplexers (MUX) to form the
two buses A and B.
The selection lines in each multiplexer select one register or the input data for the
particular bus.
The control must provide binary selection variables to the following selector
inputs:
1. MUX A selector (SELA): to place the content of R2 into bus A.
2. MUX B selector (SELB): to place the content of R3 into bus B.
3. ALU operation selector (OPR): to provide the arithmetic addition A + B.
4. Decoder destination selector (SELD): to transfer the content of the output bus
into Rl.
Control Word
There are 14 binary selection inputs in the unit, and their combined value
specifies a control word.
The encoding of the register selections is specified in following Table.
The 3-bit binary code listed in the first column of the table specifies the binary
code for each of the three fields.
The register selected by fields SELA, SELB, and SELD is the one whose
decimal number is equivalent to the binary number
in the code.
The ALU provides arithmetic and logic
operations. In addition, the CPU must
provide shift
operations. The shifter may be placed in
the input of the ALU to provide a preshift
capability,
or at the output of the ALU to provide
postshifting capability.
4 Instruction types
- Data processing → instructions for computational capabilities for processing numeric data
→ performed in MP registers;
- Data instructions → to transfer programs and data into memory and the results to
user;
- Control instructions → to test the value of data word or status of computation storage
→ instructions for moving data between memory and registers;
- Data exchange through I/O ports;
―addition, subtraction, multiplication and division. MPs contain complete floating point
processors to perform operations on large floating point numbers.
3.MPcan make decisions and jump to new set of instructions based on those decisions.
Instruction Format
Memory addressing is simple.
A 16 bit address is either built into the instruction, or taken from the HL Register.
The instruction set is simple and uniform making it easy to learn.
The OPCODES are all 8 bits long and these may contain Register fields and the
OPCODE may be followed by an 8 or 16 bit immediate value or 16 bit address.
OPCODE+REGISTER
<-------------------------- Byte --------------------->
OPCODE+X X X (operand)
<------------------------- Byte --------------------->
<------------ 8 or 16 ----------->
Contents of all Registers including Accumulator and memory location pointed to
by (HL) may be incremented, decremented or loaded with an immediate value.
Instruction Format
All combinations of Register, Accumulator and Memory pointed to by (HL) may
be moved to another Register or Accumulator or Memory pointed to by (HL).
The following arithmetic operations may take place between any Register, Memory
pointed to by (HL) or an immediate value as source and the Accumulator as
destination - ADD, SUB, AND, OR, XOR and Compare.
ADVANTAGE These compromise between code density & instruction of these type
are very easy to decode.
Addressing Modes
Addressing Modes
Segment: Offset scheme in Memory
When largest register in CPU was only 16-bits long → it could address directly only 65,536 bytes (64 KB) of memory.
If combine two registers into high and low pair of 32-bits → to reference up to 4 GB of memory in linear fashion.
Segment: Offset scheme
Addressing Modes
Segment:Offset scheme in Memory
Addressing Modes
Segment: Offset scheme in Memory
Addressing Modes
Segment: Offset scheme in Memory
Addressing Modes
A one byte instruction which will load the accumulator with contents of memory
byte 1F2A would appear as follows
Addressing Modes
Indirect Addressing
This means that Effective Address is calculated by processor and
the contents of address (and one following) is used to form a second address.
The second address is where the data is stored.
Note that this requires several memory accesses; two accesses to retrieve the 16-bit
address and a further access (or accesses).
to retrieve the data which is to be loaded into the register.
Addressing Modes
Register addressing
Data is provided through the registers.
Example: MOV Rd, Rs
Direct addressing
Used to accept data from outside devices to store in accumulator or send the
data stored in accumulator to outside device.
Accept the data from the port 00H and store them into accumulator or
send the data from accumulator to port 01H.
Example: IN 00H or OUT 01H
Indirect Addressing
Effective Address is calculated by processor. And contents of address
(and one following) is used to form a second address.
The second address is where the data is stored.
This requires several memory accesses; → two accesses to retrieve the 16-bit address and a
further access (or accesses) to retrieve data which is to be loaded into the register.
Instruction Set Classification
Instruction is a binary pattern →designed inside a microprocessor
to perform a specific function.
Subtraction
8-bit number, or contents of register, or contents of memory location can
be subtracted from contents of accumulator; and results are stored in
accumulator.
The subtraction is performed in 2's compliment, and the results if negative,
are expressed in 2's complement.
No two other registers can be subtracted directly.
Instructions on Arithmetic Operations
Instructions to perform arithmetic operations
♦addition, ♦subtraction
examples
Mnemoni Opcode Numbe Format /Addressing Symbols Indicators
c r of
bytes
addition
subtractio
n
SUB L 95 h Opcode (A)←(A) – (L) Z, CY
(register)
Rotate
Each bit in accumulator can be shifted either left or right to
next position.
Instructions on Logical Operations
examples ♦AND, ♦ OR, ♦Executive-OR
Mnemonic Opcode Number Format /Addressing Symbols Indicators
of bytes
AND
Rotate
Each bit in accumulator can be shifted either left or right to
the next position.
Compare
Any 8-bit number, or contents of register, or memory location can be
compared for equality, greater than, or less than, → with contents of
accumulator.
Complement
Contents of accumulator can be complemented. All 0-s are replaced
by 1-s and all 1-s are replaced by 0-s;
Instructions on Logical Operations
examples ♦Rotate, ♦ Compare, ♦ Complement
Mnemonic Opcode Number Format /Addressing Symbols Indicators
of bytes
Rotate
RAR 1F h 1-byte Opcode CY
shift right (register)
RA L 17 h 1-byte Opcode CY
shift left (register)
Compare
CPI FE h 2-bytes Opcode + data (A)← 2nd byte Z=1, if
Compare A (immediate) A=2nd byte;
with operand CY=1, if
A2nd byte
CMP L BD h 1-byte Opcode (A) ─ (L) Z=1, if
A or loc(HL) (registry) (A)=(L);
CY=1, if
(A)(L)
Complement
XRA A AF h 1-byte Opcode (A)←(A) (A) Z=1
A exclusive (register) CY
or A
XRI EE h 2-bytes Opcode + data (A)←(A) (2nd bait) Z
A exclusive (register) CY
or A
Instructions for Branching Operations
Instructions to alter the sequence of program execution
either conditionally or unconditionally
Jump
Conditional jumps are an important aspect of the decision-making process in the
programming.
These instructions test for a certain conditions (e.g., Zero or Carry flag) and alter
the program sequence when the condition is met. In addition, the instruction set
includes an instruction called unconditional jump.
1. copying data
Example: ADD R
RregisterA <─Rregister A + Rregister R summation contents of A-register with
content of R-register and result is move to A-register, again.
Instruction Format 2-bytes instructions
Two byte Instructions → 1st byte specifies → operation code;
→ 2nd byte →specifies operand.
Source operand is a data byte immediately following opcode.
LDA addr
A <-- (addr) Addr is a 16-bit address in L H order.
.
Sample programs1
Write an assembly program to add Write an assembly program to
two numbers Program multiply a number by 8 program
► MVI D, 8Bh move data to D-reg ► MVI A, 30H move data to A-reg
► MVI C, 6Fh move data to C-reg ► RRC shift of (A) content to right with carry
► RRC shift of (A) content to right with carry
► MOV A, C move data from C-reg to A-reg
► RRC shift of (A) content to right with carry
► ADD D sum up (A) with (D)
► OUT PORT1
► OUT PORT1 content of (A) to Port 1 ► HLT
► HLT stop MP
.
Sample programs2
Write an assembly program to find greatest between
two numbers.
Program
► MVI B, 30h move data to B-reg;
► MVI C, 40h move data to C-reg;
► MOV A, B move data from B-reg to A-reg;
► CMP C compare content of A-reg with C-req;
► JZ EQU jump if equal (A)=(C) ;
► JC GRT jump if carry;
► OUT PORT1 move content of A-reg to Port 1;
► HLT stop microprocessor;
.
Sample programs 3
Summing up of three summands
Sample programs 3
Summing up of three summands and placing result to 4th cell
Sample programs 4
Compare of two numbers and placing of biggest one to cell 2040 H
Sample programs 4
To place 0-9 numbers to cells 2040 H÷ 2048 H
Registers
Flag register 8-bit register. Five bit positions in register out of eight are used
by programmer to examine these flags or data conditions. Flags is important in
decision-making process of MP.
The bits are set or cleared as a result of an operation performed in the ALU.
1. Bit C (carry) is set to 1 if the end carry C8 is 1. It is cleared to 0 if the carry is O.
2. Bit S (sign) is set to 1 if the highest-order bit F? is 1. It is set to 0 if the bit is 0.
3. Bit Z (zero) is set to 1 if the output of the ALU contains all 0's.
It is cleared to 0 otherwise.
In other words, Z = 1 if the output is zero and Z = 0 if the output is not zero.
4. Bit V (overflow) is set to 1 if the exclusive-OR of the last two carries is equal to 1,
and cleared to 0 otherwise.
This is the condition for an overflow when negative numbers are in 2's complement.
For the 8-bit ALU, V = 1 if the output is greater than +127 or less than -128.
Flag Register
General Definition
General Definition
General Definition
General Definition
General Definition