Post on 02-Jun-2018
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
1/24
CS-401Computer Architecture & Assembly
Language ProgrammingLecture-3
Introduction to Assembly Language
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
2/24
Lets revise the last lecture
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
3/24
Basic Computer Organization
iAPX 88 Registers (16-bit)
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
4/24
iAPX 88 Registers (16-bit)
General Purpose
AXBX
CX
DX
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
5/24
iAPX 88 Registers (16-bit)
General Purpose
AH AL
AX
16-bit
8-bit 8-bit
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
6/24
iAPX 88 Registers (16-bit)
General Purpose
BH BL
BX
16-bit
8-bit 8-bit
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
7/24
iAPX 88 Registers (16-bit)
General Purpose
AX AAccumulator RegisterBX BBase Register
CX CCounter Register
DX DDestination Register
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
8/24
iAPX 88 Registers (16-bit)
Pointer / Index / Base
SIDI
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
9/24
iAPX 88 Registers (16-bit)
Pointer / Index / Base
SI SISource Index
DI DIDestination Index
IP IPInstruction Pointer
SP SPStack Pointer
BP BPBase Pointer
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
10/24
iAPX 88 Registers (16-bit)
Flag Register
- - - - O D I T S Z - A - P - C
C = Carry S = Sign Bit
P = Parity T = Trap Flag
A= Auxiliary Carry I = Interrupt Flag
Z= Zero Bit D = Direction Flag
O = Overflow
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
11/24
Registers
Program Counter
Instruction Pointer
Function:
Address of next instruction to be executed
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
12/24
Instruction Groups
Data Movement Instructions
Arithmetic / Logic Instructions
Program Control Instructions
Special Instructions
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
13/24
Data Movement
mov ax,bx ; move data from bx to ax
lda 0234 ; load 0234 into
; accumulator
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
14/24
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
Arithmetic and Logic Instructions
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
15/24
iAPX 88 Registers (16-bit)
Segment
CS CSCode SegmentDS DSData Segment
SS SSStack Segment
ES ESExtra Segment
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
16/24
iAPX 88 Registers (16-bit)
General Purpose
AX AH,ALBX BH,BL
CX CH,CL
DX DH,DL
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
17/24
A Simple Program
Move 5 to AX mov ax,5
Move 10 to BX mov bx,10
ADD BX to AX add ax,bx
Move 15 to BX mov bx,15
ADD BX to AX add ax,bx
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
18/24
General Instruction Format
instruction dest, srcinstruction dest
instruction src
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
19/24
Assembler
NASM
The Netwide Assembler
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
20/24
Linker
ALINK
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
21/24
Debugger
AFD
Advanced Full Screen Debug
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
22/24
EX01.ASM
[ORG 0X100]
mov ax,5
mov bx,10
Add ax,bx
Mov bx,15
Add ax,bx
Mov ax,0x4c00
Int 0x21
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
23/24
EX01.LST
8/11/2019 Assembly Language Programming - CS401 Power Point Slides Lecture 03
24/24
Word Representation
4 Byte Word
Representation in Memory
MSB LSB
MSB LSB
LSB MSB
0 1 2 3
0 1 2 3
Representation 1
Representation 2
Little Endian Notation
Big Endian Notation