Вы находитесь на странице: 1из 5

1. program to add all even no.s in an array?

(to find even numbers just use Instruction

RCR AL,01 \\here the no is placed in ‘A’,then check the carry flag by ‘JC’ or
’JNC’

______________________________________________

MOV CL,[2500] \\length of array from mem. Location

MOV BL,00

MOV SI,3000

L2: MOV AL,[SI]

RCR AL,01\\Rotate right with carry

JNC L1 \\ IF NO CARRY COMES THEN THAT IS A EVEN NO.

ADD BL,[SI] \\ADD CONTENT OF BL WITH CURRENT LOCATION DATA AND SAVE IN BL

L1: INC SI

LOOP L2

MOV [3000],BL //save the results in location 3000

HLT

2. To find an element in an array(same as finding the string lenth of an array,here the end
of string variable is taken from an memory location)?

MOV AL,[2500]
MOV BL,01

MOV SI,[3000]

L2:CMP AL,[SI]

JZ L1

INC BL

INC SI

JMP L2

L1:MOV [3000],BL

HLT

3. FIND (A+B)2=A2+2AB+B2

MOV SI,2500

MOV AL,[SI]

MOV BL,AL

MUL BL

INC SI

MOV AL,[SI]

MUL AL

ADD AL,BL

MOV [3000],AL

HLT

4.FIND {(A+B)*(A-B)}/A

HINT:WHICH IS EQUAL TO (A2-B2)/A


5.FIND THE 12+22+32+42+52.............

HINT:we find this in simple way ie, 52+42+32+22+12

MOV CL,[2500] \\ LOAD THE VALUE OF N

MOV [3000],00

L1:MOV AL,CL

MUL AL

ADD [3000],AL

LOOP L1 \\DECREMENT CONTENT OF CX BY 1 AND JUMP TO ‘L1’ IF NOT ZERO

HLT

6. find sum of a array in decimal?

Hint:in mp the hexa decimal operation only takes place.,,to convert hex value to corresponding
decimal value we have to use an instruction

DAA \\Decimal adjust accumulator after addition

For to use thos instruction we hav to use an addition operation before DAA

First move the result to accumulator ‘AL’

Then

ADD AL,00

DAA

Thats all,then we get result in deciamal format then save the sum of array in any location

7.find the number of occurance of a specific number in an array,then check the value of number
of occurance is odd then save a value 01 to 3000;

MOV CL,[2500] \\ARRAY SIZE

MOV AL,[2600] \\NO

MOV BL,00 \\COUNT

MOV SI,3000
L2:CMP AL,[SI]

JNZ L1

INC BL

LI: INC SI

LOOP L2

// WE GET THE NO OF OCCURANCE IN BL

MOV AL,BL

RCR AL,01

JNC L2

MOV [3000],01

HLT

8. GENERATE 1,2,5,10,17,26,......

hint :which is in the form X2+1

MOV CL,[2500]

MOV SI,3000

MOV BLL,00

L1:MOV AL,BL

MUL AL

ADD AL,01

DAA

MOV [SI],AL

INC SI

INC BL

LOOP L1

HLT
9. GENETRATE THE SERIES 1,9,28,65,......

WHICH IS EQUALENT TO X3+1.

Вам также может понравиться