Uploaded by Abu hmaid

Assignment lab5

advertisement
‫ احمد نافز الرواشده‬: ‫االسم‬
Q1: write an assembly code to count even numbers and odd numbers in array X
SOL :
ORG 100H
LEA SI , NUM
MOV BL , 0
MOV BH , 0
MOV CX , 6
L1: MOV AL , [SI]
ROR AL,1
JC L2
INC BL
JMP L3
L2: INC BH
L3: INC SI
LOOP L1
MOV EVEN , BL
MOV ODD , BH
HLT
NUM DB 1,2,4,6,7,9
EVEN DB ?
ODD DB ?
Q2: write an assembly code to multiply even numbers by 2 in the array X.
SOL:
ORG 100H
MOV SI, OFFSET X
MOV CX, 4
MOV BL,2
L1:
MOV AL, [SI]
SHR AL, 1
JC L2 ;ODD
SHL [SI], 1 ;EVEN
L2:
ADD SI,2
LOOP L1
HLT
X DW 24,3,1,2
Download