st
1 class :
Microprocessor and CPU Relation:
It is a multipurpose, programmable device that
accepts digital data(0,1binary data) as input,
processes it according to instructions stored in its
memory, and provides results as output.
Microprocessors operate on numbers(binary number)
and symbols(register :AX,BX,CX,DX) represented in the
binary numeral system.
Transistor:
In the analog world of continuously varying signals, a
transistor is a device used to amplify its electrical input.
In the digital world, a transistor is a binary switch and the
fundamental building block of computer circuitry. Like a
light switch on the wall, the transistor either prevents or
allows current to flow through.
A single modern CPU can have hundreds of millions or even
billions of transistors.
Transistor, semiconductor device for amplifying,
controlling, and generating electrical signals.
A transistor is a type of a semiconductor device that can
be used to both conduct and insulate electric current or
voltage.
A transistor basically acts as a switch and an amplifier.
In simple words, we can say that a transistor is a miniature
device that is used to control or regulate the flow of
electronic signals.
[Link]
a-cpu-a-microprocessor
[Link]
sh/s01/[Link]
The central processing unit (CPU) is a chip that functions as the
brains of the computer.
The CPU has a control unit, a logic and arithmetic unit and
registers, plus a small bit of memory called cache.
The CPU is a microprocessor. The microprocessor is an
integrated circuit that is made up of millions of transistors.
However, not all microprocessors are CPUs.
Microprocessor consists of ALU, array register and a control
unit.
CPU = ALU + CU
ALU Arithmetic Logic Unit (+,-,*,/) arithmetic
AND, OR, XOR Logic
CU Central Processing Unit
CPU 1 chip or more than one chip
Microprocessors 1 chip Single chip CPU
Every microprocessor is CPU but not every CPU are
microprocessor.
Microprocessor ALU(Microprocessor has one ALU)
8086 Microprocessor 16 bits
X bit microprocessor x bit data can process at a time [ x =
4,8,16]
ALU in Microprocessor can process x bit data at a time.
Register: AX, BX, CX, DX symbol
MOV AX,0003h
Symbol Number
AX = 0003H hex
1 hexadecimal = 4 bits 4 hex = 16 bits
AX is a 16 bits microprocessor.
Microprocessor and register are the same sizes in a specific
Microprocessor.
BUS = Communication Path Way.
Each microprocessor task may take a number of clock
cycles.
So a Microprocessor zxthat can do more clock cycles in
a particular time can achieve any task faster.
That’s why a 3.6 GHz microprocessor (which does
3.6x109 clock cycles per second) is faster than a 2.4 GHz
microprocessor.
nd
2 class
BUS = communication path way
There are three types of bus:
[Link] bus
[Link] bus
[Link] bus
Tarak borrow some money form Anirba. He(tarak) didn’t pay
back. So, Anirban goes tarak’s place which is address bus. He
take his money from Tarak, Which is data bus. Tarak take a
acknowledgement from Anirban, Which is Control bus.
Memory System and Microprocessors are connected by bus.
In computer architecture, a bus is a transmission path that
transfers data (actual data, address data or control data)
between components inside a computer, or between
computers.
When CPU will find data, it will return acknowledgement
signal to RAM. This signal will pass by control bus.
Peripheral = I/O device
rd
3 class
Flag register:
ZOSCAP
Z – Zero flag
If we do any kind of arithmetic operation and
Result is 0, then ZERO FLAG = 1( active) A = 1111 and B = 1111
Else ZERO FLAG = 0 ( de active) A – B = 0
O - Overflow flag
Register Size, AX = 16 bit but data is 20bit. So, data will be
over flow. OF = 1
AX = 16 bit but data is 8 bits. So, data will not over flow.
OF = 0
S – sign flag
MSB (Most Significant bit)<--1111 LSB(Least significant
bits)
In arithmetic operation, if MSB = 1 then SF = 1;
Else SF = 0
A = 1111 and B = 0000 A + B = 1111 SF = 1
A = 0111 and B = 0000 A + B = 0111 SF = 0
C – carry flag
In arithmetic operation, MSB has a carry then CF = 1
Else CF = 0
A = 1111 and B = 1000 A + B = 10111 CF = 1
A = 1111 and B = 0000 A + B = 1000 CF = 0
A – Auxiliary flag
A = D7 D6 D5 D4 D3 D2 D1 D0
A = 11111000 and B = 00011000
A + B = 100010000
AF = 1 (Carry from D3 to D4)
A = 11111000 and B = 00000000
A + B = 11111000
AF = 0(There is no carry)
P – parity flag
PF = Parity flag;
PF = 1 ( even parity) = Even
Number of 1’s in lower byte = 4(even)
PF = 0 (Odd parity) = odd
Number of 1’s in Lower Byte = 5 (odd)
8086
AX = AH + AL
AX = 11110000 00001111 ---(1) even parity PF = 1
Ax = 11110000 10001111---(1)
General perpose register:
ALU operation +,-,*,/ , or, and, Not
AX = ALU Operation + I/O Operation (temporarily)
DX = multiplication, Divided operation, I/O operation
We can see that AX and DX register work same. But in real they
don’t work same.
EXP:
2)4(2
4
0
Result = AX = 2
Remainder DX = 0
CX = COUNT
MOV CX,80; CX = 80
shanto: -- user define label
J…….
……….
LOOP shanto ; machine language for loop
BX = BASE REGISTER
XLATE(TRANSLATE) INSTRUCTION
We use base register for translate instruction and offset
address.
Physical Address = Segment Register * 10H + Offset address/
effective address
PA = CS * 10H + IP
Segment register = base address = Code Segment
IP = Offset Address/Effective address
IP = Instruction Pointer register
I will go Chittagong to Dhaka. Here Chittagong is base address
and Dhaka is Physical Address.
Distance is IP or offset address
IP = offset address = effective address
Segment register = Code segment(CS) or base register
CS = Code segment
8086 Microprocessor are 16 bits Microprocessor and also
register is also 16 bits And 20 bits address bus
CS = 0004H Ip = 0000 H
PA = CS * 10H + IP
PA = 0004 * 10H + 0000
= 00040(20 bits address)
P.A = CS * 10H +IP// This equation use for code segment’s
physical address
PA = DS * 10H + SI/DI // Data segment
PA = ES * 10H +DI // Extra segment er physical add
PA = SS * 10H + SP/BP // stack segment er
Th
4 class
MOV operational code/ opcode
AX, BX Operand
MOV AX, BX
AX Destination Operand
BX Source Operand
Before
AX = 0004H
BX = 0003H
MOV AX, BX
After
AX = 0003H
BX = 0003H
Addressing mode: The way operand are specified in an
instruction is known as addressing mode.
Types of addressing mode:
8086 addressing mode:
1. Register operand addressing mode
2. Immediate operand addressing mode
3. Direct memory operand addressing mode
4. Indirect memory operand addressing mode
5. Based memory operand addressing mode
6. Indexed memory operand addressing mode
7. Based indexed memory operand addressing mode
8. String memory operand addressing mode
9. Direct (I/O port) operand addressing mode
[Link] (I/o) Operand addressing mode
[Link] operand addressing mode
[Link] operand addressing mode
[Link] Operand mode:
In register Operand Mode ,8 bit or 16 bits data source
register is transfer to destination register. In this case
Both registers should be of same size. Thus, MOV AX, BX
instruction is invalid.
[Link] data addressing mode:
8 bit or 16 bits data is transferred directly to destination
register or memory location.
th
5 Class
Physical Address = Segment Register * 10H + Offset address/
effective address
PA = CS * 10H + IP
Segment register = base address = Code Segment
IP = Offset Address/Effective address
Physical Address is always 20 bit. That’s why we use [Link]
that Physical Address can be 20 bit.
Register operand addressing mode:
Before Execution:
CS = 0100
IP = 0000
PA = CS * 10H + IP
PA = 0100*10H + 0000
PA = 01000
MOV AX,BX .This instruction has address in 01000
Memory content = 8BC3H = 16 bit = 2 byte
IP value increase by memory content byte
After Execution
Immediate operand addressing mode
Before Execution:
IP = 0000
CS = 0100
PA = CS * 10 + IP
PA = 0100*10 + 0000
PA = 01000
MOV AL,03, address is 01000
Memory content = BO03 = 16 bit = 2 byte
After Execution
Direct memory operand addressing mode:
MOV CX,[1234] MOV CX,[Effective address]
Before Execution:
PA = CS*10H + IP
PA = 0100*10H + 0000
PA = 01000
After Execution:
PA = DS *10H + EA
PA = 0200 *10H + 1234
PA = 03234
CH CX
ED BE
ED = 03235
BE = 03234
6TH CLASS
Based indexed memory operand addressing mode:
MOV AH, [BX],[SI] + 1234H
MOV AH, [BX][AX] ,[SI] + 1234H
Before execution:
PA = CS* 10 H +IP
After execution
PA = DS * 10H + E.A
Ip will increment based on instruction size
After execution next instruction:
P.A = CS + 10H + IP
8086 Microprocessor has an instruction size of 1 byte to 6
bytes. Each byte of microprocessor instruction has different
information. first byte of 8086MP contains 3 information:
[Link](6bit)
2. D bit/ register direction bit (1 bit)
3.W bit / data size bit (1 bit 2 byte,)
Opcode: Operational code operand
Ex: MOV,ADD,Sub
D Bit
D = 1 when register operand is used as destination operand
D = 0 when register operand is used as source operand
W bit:
When W = 0, 8 bits data is use
When W = 1, 16 bits data is used
MOD: 2 bit is used to select different addressing mode
(register mode or memory mode)
Code Explanation
00 Memory mode, No Displacement follows
01 Memory mode,8 bits Displacement follows
10 Memory mode,16 bits Displacement follows
11 Register Mode (No Displacement)
REG: REG field is of 3 bits which uses register as operand. It
may be of 8 bit (w = 0) or 16 bits (W = 1)
Last class:
R/M : (register/memory) :
R/M field is used with MOD field for detecting the second
operand of the instruction.
Fig: Encoding table
If 16 bits displacement and 16 bits immediate operand are
used both in the same instruction, byte 3,4,5 and 6 are
decoded.
Pipelining:
In first clock cycle(t1) I1 instruction is fetched and stored in
instruction queue. In second clock cycle (t2) I1 instruction is
decoded and executed.
Instruction fetch , decond and execution cycle
SP = stack pointer
ALU = arithmetic logic unit
CU = Control Unit
IR = Instruction Register
BR =Buffer register
CS 0 = chip is selected
1 = chip is not selected
R/W 0 = data is read
1 = data is written
PC = program counter = points to the next instruction to be
executed
MAR = Memory address register
FINAL SEMESTER
st
1 class : 09/10/21
Embedded system:
Firmware = hardware + software
2nd class: 17/10/2021
Microcontroler
microprocessor microcontroller
USART: Universal synchronous asynchronous
receiver transmitter
Serial com port: works with 1 bit data at a time
LAB Class:
\AH = all functions move here
Function 1h:
1h = takes single character as input
2h = displays single character as output (from dl
register)
Int 21h calls different functions and execution.
Mov AH,1h
Int 21H
Interrupt 21H call function 1h. Function 1H takes
input from keyboard
Mov AH,2H
Mov DL,’?’
Int 21H
Interrupt 21H call function 2H. Function 2H displays
value inside DL. After display DL, AL = ‘?’
Mov AH,4ch
Int 21H
Int 21h call function 4ch an 4ch function is used to
exit
Input: AH; AH takes inputs;
When we get input in AH, at the same time input
value goes to the AL
Output: AL; AL output the value
To go to new line, we have to execute 2 functions:
0DH = carriage return (start of current line)
Cursor will go in front of line.
0ah = line feed (new line)
Cursor will go next line.
Mov AH,2H
Mov DL,0DHcarriage return = 0DH
Int 21H
Interrupt 21h call function 2h and function 2h
displays value inside dl; AL = 0DH that means cursor
in front of the line
Mov AH,2h
Mov DL, 0DH
Int 21h
Interrupt 21h call function 2h and function 2h
displays value inside DL; AL = 0AH that means
cursor in the next line.
Mov DL, BL
Int 21H
Interrupt 21h call function 2h and function 21 h
displays value inside of DL.
Data-defining pseudo
DB = define byte
DW = define word
DD = define doubleword (two consecutive words)
DQ = define quadword (four consecutive words)
DT = define ten bytes (ten consecutive bytes)
Int 21h, function 9;
DX = offset address of string
The string must end with a ‘s’ character
LEA DX, MSG
Puts the offset address of the variable MSG into DX
LEA = Load Effective Address
LEA DX, MSG //get message
MOV AH,9H //display string function
Int 21H //display string
Interrupt 21h call function 9H. Function 9H has a
condition that MSG or string’s offset address into
DX
LEA puts the offset address from MSG to DX.
When a program is loaded in memory, DOS prefaces
it with a 256-byte program segment prefix (PSP).
The PSP contains information about the [Link]
that programs may access this area, DOS places its
segment number in both DS and ES before
executing the program.
Initialize data segment (DS)
Mov AX, @DATA
Mov AH, AX
@DATA is the name of the data segment defined by
.DATA.
THE assembler translates the name @DATA into a
segment number.
TWO instructions are needed because a number
(the data segment number) may not be moved
directly into a segment register.
dd C
JNE = Compare jam