Microprocessors and Assembly Language: Instructor: Mubashra Manzoor Contact Email

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Microprocessors and Assembly

Language

Instructor: Mubashra Manzoor

Contact email: mubashra.manzoor@usa.edu.pk


Registers

 The Register is a collection of two or more


Flip-flops with a common CLOCK input.
 Flipflop – One unit memory cell
 Register – group of flipflops
 n-bit register – n number of flipflops and
capable of storing n-bits (multibit data)
Recall

Triggering methods: Control Input


• Level Triggering
• Edge Triggering
Clock
 Clock is a digital signal
 decides the time of the input
signal edge is a transition of a digital signal from low
to high (0 to 1) or from high to low (1 to 0)
Rising edge
Falling edge
clock period
 Frequency
 Duty cycle
𝑡𝑖𝑚𝑒 𝑓𝑜𝑟 𝑤ℎ𝑖𝑐ℎ 𝑠𝑖𝑔𝑛𝑎𝑙 𝑖𝑠 ℎ𝑖𝑔ℎ 𝑃𝑊
𝐷𝑢𝑡𝑦 𝐶𝑦𝑐𝑙𝑒 = =
𝑇𝑜𝑡𝑎𝑙 𝑡𝑖𝑚𝑒 𝑇
 Speed of the circuit depends on the frequency of the clock
Latch vs Flip-flop
Latch – Level Sensitive
Flip-flop – Edge Triggered

Flip-flop
Registers Cont…
 A register is a set of flip-flops with
combinational logic to implement state
transitions that allow information to be stored
and retrieved from them. In the simplest form,
a flip-flop is a one-bit register.
Basic Computer Architecture
Registers
are Built
in
memory
locations
in the
processor
Registers Cont..
 Data formats in Registers
 Data can be entered in serial or in parallel form
Parallel out
1 0 0 1
1001 1001
FF3 FF2 FF1 FF0
Serial in Serial out

D3 = 1 D2 = 0 D1= 0 D0= 1

Parallel in
Registers Cont…
 Classifications of Registers (based on input/output)
 Serial Input Serial Output (SISO)
 Serial Input Serial Output (SIPO)
 Parallel Input Serial Output (PISO)
 Parallel Input Parallel Output (PIPO)
 Classification of Registers (Based on applications)
 Shift Registers
 Storage Registers
Registers and Processor types
 In computing, 16-bit, 32-bit and 64-bit are different
types of processors. The bit number (usually 8, 16,
32, or 64) refers to how much memory a processor
can access from the CPU register.
 The 16-bits generally refers to the size of the data
registers inside the CPU, and the internal data bus. So the
arithmetic logic unit (ALU) would be able to do 16-bit
math, either signed (-32768 to +32767) or unsigned (0 to
65535).
Recall: Compilation Process

Source Code • High Level Language


Compiler

. • Assembly Code
Assembler

Object
code
• Object File
Linker
• Machine Code
• Hardware
• Assembly Language helps reducing compilation time
• Registers also help in optimization of processing time during the hardware
and software interaction
Registers Con…

Accessibility Time for CPU

Hard
Registers Cache RAM
disk

Register =
Record collection
of Information

• Concept of registers is there since the inception of first Intel Microprocessor 4004
in 1971 by Federico Faggin
AX
Types of Registers
 There are 14 types
 Accumulator Register
8-bit a
ax
16-bits ah al

Eax ah al
32- bits
Rax Eax ah al
• X – Extended to 16 bits
• E – Extended to 32 bits
• R – Rich register to 64 bits CPU
1. Accumulator Register
An accumulator is a register for short-term,
intermediate storage of arithmetic and logic data in a
computer's CPU
 General Purpose Registers
They accumulate the results of
instructions
Used for input and output
 Used while performing operations
 a register or registers that are dedicated to take the result
of operations
In modern computers, any register can function as
an accumulator.
AX
2. Base Register
BX

8-bit b
bx
16-bits bh bl

Ebx bh bl
32- bits
Rbx Ebx bh bl
64- bits

CPU
2. Base Register
 Holds addresses of data
In computing, a base address is an address serving as a reference
point ("base") for other addresses.
In computers using relative addressing scheme, to obtain an absolute
address, the relevant base address is taken and offset ( displacement)
is added to it.
 It is used to store the value of the offset
AX
3. Counter Register
BX
CX

8-bit c
cx
16-bits ch cl

Ecx ch cl
32- bits
Rcx Ecx ch cl
64- bits

CPU
Counter Register

 A counter is simply a register with combinational


logic to implement counting, that is it is possible to
retrieve the contents, add or subtract one to the
contents, and then store it back into the register in
one operation.
 In digital logic and computing, a counter is a device
which stores (and sometimes displays) the number of times
a particular event or process has occurred, often in
relationship to a clock signal.
 store the loop count in iterative operations
AX
4. Data Register
BX
General Purpose Registers CX
DX
8-bit d
dx
16-bits dh dl

Edx dh dl
32- bits
Rdx Edx dh dl
64- bits

CPU
Data Register

 General purpose register


 Holds data for output
 DX is also used along with AX register for
multiply and divide operations involving large
values
AX
BX
General Purpose Registers
CX
DX
CS
Segment Registers DS
The registers that specify the SS
location of segments are called ES
segment registers
Segments are specific areas defined
in a program for containing data,
code and stack. There are three main
segments − Code, Data and Stack
CPU
Code Segment (CS) Register

 The CS(code segment register) is used to


address the code segment of the memory i.e a
location in the memory where the code is
stored.
 Holds starting address of the section of
memory holding code
Data Segment Register
 Data Segment − It contains data, constants
and work areas
A Data Segment register or DS register stores
the starting address of the data segment.
Holds starting address of the section of data
segment
Stack Segment Register

 Stack Segment – It contains data and return


addresses of procedures or subroutines. It is
implemented as a 'stack' data structure.
 Defines the area of the memory used for the
stack
 The Stack Segment register or SS register
stores the starting address of the stack
Extra Segment Registers

 The extra segment register is used to provide


additional segments for storing data
Used by string instructions to hold destination
data
Physical Address: The segment registers store the starting addresses of a data.
To get the exact location of the data or instructions within a segment, an offset
value is required. To reference any memory location in a segment, the
processor combines the segment address in the segment register with the
offset value of the location.
AX
BX
General Purpose Registers
CX
DX
CS
Segment Registers DS
SS
Index Registers ES
An index register in a processor are SI
registers used for modifying operand DI
addresses during the run of a
program, typically for doing
vector/array operations. CPU
Source Index and Destination Index Registers

The registers SI and DI, are used for indexed


addressing and sometimes used in addition and
subtraction. There are two sets of index pointers:
 Source Index (SI) − It is used as source index for string
operations
Destination Index (DI) − It is used as destination index for
string operations

Add dl, bl
Source
Destination
AX
General Purpose Registers BX
CX
DX
CS
Segment Registers DS
SS
ES
Index Registers
SI
DI
Special Purpose IP
Registers SP

CPU
Look at the following simple program to understand the use of registers in
assembly programming. This program displays 9 stars on the screen along
with a simple message

You might also like