Section 7
Section 7
AND
0 and 0 = 0
1 and 1 = 0
2 and 0 = 0
1 and 1 = 1
OR
0 or 0 = 0
0 or 1 = 1
1 or 0 = 1
1 or 1 = 1
XO
R
0 xor 0 = 0
1 xor 1 = 1
2 xor 0 = 1
1 xor 1 = 0
Question 1
For the following instructions; indicate the value
of the result register, and also give the AF, CF,
and ZF
Q1
AX = F000, BX = 3456, and DX = E390
A) AND DX, AX <- DX=DX and AX
>
CF=0, ZF=0
1110 0011 1001 0000 AF unaffected
1111 0000 0000 0000
1110 0000 0000 0000
DX = E000
Q1
AX = F000, BX = 3456, and DX = E390
B) OR DH, BL
1110 0011
0101 0110 CF=0, ZF=0
1111 0111
DH = F7
Q1
AX = F000, BX = 3456, and DX = E390
C)XOR AL, 76H
0000 0000
0111 0110 CF=0,ZF=0
0111 0110
AL = 76H
Q1
AX = F000, BX = 3456, and DX = E390
D) AND DX, DX
DX=E390
Q1
AX = F000, BX = 3456, and DX = E390
E) XOR AX, AX
1111 0000
1111 1111 CF=0,ZF=0
1111 0000
AH=F0
Shift Right SHR
Shift Left SHL
Q1
AX = F000, BX = 3456, and DX = E390
K)MOV CL, 04
SHL AL, CL
ZF=1
AL=0
Q1
AX = F000, BX = 3456, and DX = E390
L)SHR DX, 1
0 1110001110010000
CF
0111000111001000 CF=0,ZF=0
DX=71C8
Q1
AX = F000, BX = 3456, and DX = E390
M)MOV CL, 3
SHR DL, CL
0 0 0 10010000
00010010 CF=0, ZF=0
DL=12H
ROR (rotate right)
Example ROR
ROL (rotate left)
Example ROL
RCR (rotate carry right)
RCR example
RCL (rotate carry left)
RCL example
CMP destination, source
Question 2
b) MOV DL, 34
CMP DL, 88
Less CF=1,
ZF=0
Q2
69 87 96 45 75
AL (Max)
69
Maximum number in an array
69 87 96 45 75
87
Maximum number in an array
69 87 96 45 75
96
Maximum number in an array
69 87 96 45 75
96
Maximum number in an array
69 87 96 45 75
96
.model small
.stack 128
.data
Grades db 69,87,96,45,75
Highest db ?
Count DW 5
.code
main proc far
; set segment registers:
mov ax, data
mov ds, ax
mov cx,count
mov bx, offset Grades
mov al,[bx] ;al MAX =69
inc bx
dec cx ; loop n-1
loop1:
cmp al,[bx]
ja skip
mov al,[bx] ;new max
skip:
inc bx
loop loop1
mov highest,al
mov ax, 4c00h ; exit to operating system.
int 21h
main endp