0% found this document useful (0 votes)
29 views44 pages

Section 7

Uploaded by

adhamkassem898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views44 pages

Section 7

Uploaded by

adhamkassem898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

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

1110 0011 1001 0000


1110 0011 1001 0000 CF=0,ZF=0
1110 0011 1001 0000

DX=E390
Q1
AX = F000, BX = 3456, and DX = E390
E) XOR AX, AX

1111 0000 0000 0000


1111 0000 0000 0000 CF=0,ZF=1
0000 0000 0000 0000
AX = 0
Q1
AX = F000, BX = 3456, and DX = E390
G) AND AH, 0FF

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

CF=0 0000 0000 0 0 0 0

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

Give the values of CF and ZF after the following:


Q2

a) MOV BX, 2500


CMP BX,
1400
D S

Greater CF=0, ZF=0


Q2

b) MOV DL, 34
CMP DL, 88

Less CF=1,
ZF=0
Q2

c) SUB AX, AX Ax=0


CMP AX, 0000 Equal CF=0, ZF=1
CMP AX, 0FFFFH Less CF=1, ZF=0
CMP destination, source
Question 3
Indicate if the jump will happen or not:
A) MOV CL, 5
SUB AL, AL ;AL=00000000
SHL AL, CL ;CF=0
JNC TARGET ; jump happens
Q3
MOV BX, 2500
CMP BX, 1400
JA TARGET ; jump happens
Write an assembly program that finds the
maximum number in an array
Maximum number in an array

69 87 96 45 75

AL (Max)

69
Maximum number in an array

69 87 96 45 75

If Greater than Max


Will be the new Max
AL (Max)

87
Maximum number in an array

69 87 96 45 75

If Greater than Max


Will be the new Max
AL (Max)

96
Maximum number in an array

69 87 96 45 75

If Greater than Max


Will be the new Max
AL (Max)

96
Maximum number in an array

69 87 96 45 75

If Greater than Max


Will be the new Max
AL (Max)

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

end main ; set entry point and stop the assembler.


Write an assembly program that turns
Uppercase letters into lowercase
ASCII Table
.model small
.stack 128
.data
string db 'mY NAME is JOe'
;??????????????
strOut db 14 dup(?)
Count DW 14
.code
main proc far
; set segment registers:
mov ax, data
mov ds, ax
mov cx,count
mov si, offset string
mov bx, offset strOut
loop1:
mov al,[si]
cmp al,'A'
jb skip
cmp al,'Z'
ja skip
Add al,20h ;upper case -> lower case
skip:
mov [bx],al
inc si
inc bx
loop loop1
mov ax, 4c00h ; exit to operating system.
int 21h
main endp
end main ; set entry point and stop the assembler.
(ASSIGNMENT)
Write an assembly program that
counts the number of zero in a binary
word

You might also like