CSE331 Lecture5
CSE331 Lecture5
CSE331 Lecture5
Lecture Notes # 5
Outline of the Lecture
• Flag Registers and bit fields
• 80x86 addressing modes.
Ex: Show how the flag register is affected by the addition of 38H and 2FH.
38 0011 1000
+ 2F 0010 1111
67 0110 0111
CF = 0 since there is no carry beyond d7
PF = 0 since there is odd number of 1`s in the result
AF = 1 since there is a carry from d3 to d4
ZF = 0 since the result is not zero
SF = 0 since d7 of the result is zero
Ex: Show how the flag register is affected by the following addition
¾ Note that the MOV instructions have no effect on the flag (Explain on the existing example)
The CPU can access operands (data) in various ways, called addressing modes. In 80x86 there are 7
addressing modes
1. register
2. immediate
3. direct
4. register indirect
5. based relative
6. indexed relative
7. based indexed relative
MOV AL,99H
MOV [3518],AL
Ex: MOV AL,[BX] ; moves into AL the contents of the memory location
pointed to by DS:BX
• Note that, the content of the low address will go into CL and the
high address contents will go into CH.
• There are alternative coding: MOV CX,[BX+10], MOV
CX,10[BX]
• BX+10 is effective address
¾ Alternative coding
MOV CL,[BX+DI+8]
MOV CL,[DI+BX+8]
Segment Override:
MOV AL,[BX] DS:BX however MOV AL,ES:[BX]