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

Lecture-6

Addressing Modes Branching &


Bit Manipulation
Addressing Modes

Base + Index

mov ax,[bx+si]
Addressing Modes

Base + Index + Offset

mov ax,[bx+si+num1]
Addressing Modes
mov ax,[num1] ; (o) - Offset

mov ax,[bx] ; (b) - Base


mov ax,[si] ; (i) - Index
mov ax,[bx+num1] ; b+o
mov ax,[si+num1] ; i+o
mov ax,[bx+si] ; b+i
mov ax,[bx+si+num1] ; b+i+o
Segment Override Prefix

Instruction Opcode
mov ax,[cs:bx] 2E9B07
mov ax,[es:bx] 268B07
mov ax,[ss:bx] 368B07
mov ax,[bx] 8B07
Bubble Sort
Iteration 1:

60 55 45 58
Bubble Sort
Iteration 1:

55 60 45 58
Bubble Sort
Iteration 1:

55 45 60 58
Bubble Sort
Iteration 1:

55 45 58 60
Bubble Sort
Iteration 2:

55 45 58 60
Bubble Sort
Iteration 2:

45 55 58 60
Bubble Sort
Iteration 2:

45 55 58 60
Bubble Sort
Iteration 2:

45 55 58 60
Bubble Sort
Iteration 3:

45 55 58 60
Bubble Sort
Iteration 3:

45 55 58 60
Bubble Sort
Iteration 3:

45 55 58 60
Bubble Sort
Iteration 3:

45 55 58 60
Signed / Unsigned Numbers

Number Representation
2 0x0002
-2 0xFFFE
; two’s
compliment of ;
decimal 65534
Signed / Unsigned Numbers
Example

mov ax, -2 ; ax = 65534


mov ax, 2 ; bx = 2
cmp ax, bx
ja label1 ; true! 65534
> 2
Signed / Unsigned Numbers
Example

mov ax, 65534 ; ax = 0xFFFE


mov ax, -2 ; bx = 0xFFFE

; same representation
; different interpretation
Signed / Unsigned Numbers
Order and Range (16 – Bit)

Unsigned Numbers:

0<1<2<3<4 <………<65535

Signed Numbers:

-32768<-32767<…..<0<……<32767
Multiplication
1 1 0 1 1 3
x 0 1 0 1 x 5
1 1 0 1
0 0 0 0 x
1 1 0 1 x x
0 0 0 0 x x x
1 0 0 0 0 0 0 1 6 5
Shift Instructions

shr shift logical right


shl shift logical left
sar shift arithmetic right
sal shift arithmetic left
Rotate Instructions

ror rotate right


rol rotate left
rcr rotate through carry right
rcl rotate through carry left
shr

0
CF

1 0 1 0 1 0 1 0 1
shl

0
CF

1 1 0 1 0 1 0 1 0
sal

0
CF

1 1 0 1 0 1 0 1 0
sar
0
CF

1 0 1 0 1 0 1 0 1

1
CF

1 0 1 0 1 0 1 1 1
ror

CF

1 0 1 0 1 0 1 0 0
rol

CF

1 1 0 1 0 1 0 1 0
rcr

CF

1 0 1 0 1 0 1 0 0
rcl

CF

1 1 0 1 0 1 0 1 0

You might also like