You are on page 1of 40

Computer Organization

Assembly Language Programming

Lecture-2
Introduction to Assembly Language

12/23/2019 1
Basic Computer Organization

REGISTERS

12/23/2019 2
Types of Registers
There two categories of registers
 General purpose register
 Special purpose registers

12/23/2019 3
General Purpose Registers
Function of GPR
 Use to store data as will as addresses
 They combine data and address registers

 These register are used for arithmetic and data


movement
 8 to 32 bits registers

12/23/2019 4
General Purpose Registers
Commonly used general purpose registers
 Accumulator register (AX)
 Base register (BX)

 Counter register (CX)

 Data register (DX)

12/23/2019 5
General Purpose Registers
Accumulator register:
 General purpose register
 Use for arithmetic and logic operations

 Hold the result of those operations

 Initially set to zero

 Consist of two 8 bits register

 Combine use as one 16 bits register

12/23/2019 6
General Purpose Registers
Bits 15……………………………………………………….0

16 bits AX Register

8-bits AH register 8-bits AL register

12/23/2019 7
General Purpose Registers
Base/index/pointer register
 Perform arithmetic and data movement
 Holds the Address of Operands but not data

 BX can hold a memory address that point to


another variable e.g. Array,loop
 It contain data pointer

 Consist of two 8 bits register

 Combine use as one 16 bits register

12/23/2019 8
Cont..
Bits 15……………………………………………………….0

16 bits BX Register

8-bits BH register 8-bits BL register

12/23/2019 9
Cont..
Counter register:
 Act as counter for repeating or looping
instruction
 The instruction given are automatically
repeated and decrement the value of CX
 And quite when it is equal to 0

 Consist of two 8 bits register

 Combine use as one 16 bits register

12/23/2019 10
Cont..
Bits 15……………………………………………………….0

16 bits CX Register

8-bits CH register 8-bits CL register

12/23/2019 11
Cont..
Data register:
 Special role in multiply & divide operations
 Work like buffer

 Hold any thing that is copies from memory


ready for processor to use it
 In I/O operations DX can be use as post number

12/23/2019 12
Cont..
Bits 15……………………………………………………….0

16 bits DX Register

8-bits DH register 8-bits DL register

12/23/2019 13
GPR

12/23/2019 14
Cont..

Flag / Program Status Word

Function:
Collection of different boolean
information each bit has an
independent meaning

12/23/2019 15
Registers
Flag / Program Status Word

C O P D Z I A S
Direction Interrupt Auxalry
Carry Over Parity Zero Sign
carry
flow bit

A sample 8 – bit flag register

12/23/2019 16
12/23/2019 17
12/23/2019 18
12/23/2019 19
12/23/2019 20
12/23/2019 21
12/23/2019 22
12/23/2019 23
12/23/2019 24
Registers
Carry Flag

1111111111111111
+1111111111111111
0000000000000001
0000000000000000

16 – bit Accumulator
Carry Flag = CF
12/23/2019 25
Special Purpose Register
These register hold state of program
They are use
 By CU to control operation of CPU
 By OS to control execution of program

12/23/2019 26
Special Purpose Register

Types of SPR
 Instruction Register IR

 Memory Buffer Register MBR

 Memory Address Register MAR

 Program Counter PC

12/23/2019 27
Cont..
Instruction Register:
 Part of CU
 Store the instructions currently being executed

 Each instruction to be executed is loaded into


the IR
 It is also called Current Instruction Register

12/23/2019 28
Cont..
Memory Address Register:
 Holds the memory address
 The memory address from which data will be
provided to CPU
 The address to which the data will be sent & store

 Hold the memory location of data that need to


be access
 In both reading and writing it hold address of
memory location where data to be R/W
12/23/2019 29
Cont..
Memory Buffer Register:
 Holds contents of memory
 Which are to be move from memory to other
components
 Or from components to memory

 Work as buffer
 Allow processor and memory units to act
independently

12/23/2019 30
Cont...
Program Counter:
 Also called instruction pointer
 Contain address of next instruction to be fetch

 Each instruction fetch


 PC increase its store value by 1

12/23/2019 31
Registers

General Purpose

Function:
Temporary Storage
of
Intermediate Results

12/23/2019 32
Segments Registers

12/23/2019 33
Index Registers

12/23/2019 34
MNEMONIC

12/23/2019 35
Instruction Groups

Data Movement Instructions


Arithmetic / Logic Instructions
Program Control Instructions
Special Instructions

12/23/2019 36
Data Movement

mov ax,bx ; move data from bx to ax

lda 0234 ; load 0234 into


; accumulator

12/23/2019 37
Arithmetic and Logic Instructions

and ax,1234 ; AND 1234 with ax

add bx,0534 ; ADD 0534 to bx

add bx,[1200] ; ADD data at address 1200 to


bx

add ax,[1234] ; ADD data from address 1234


to ax
12/23/2019 38
Program Control Instructions

cmp ax,0 ; Compare ax with 0

jne 1234 ; Jump if not equal to the


instruction
; at address 1234

12/23/2019 39
Special Instructions

cli ; Clear the interrupt flag

sti ; Set the interrupt flag

12/23/2019 40

You might also like