Thursday, August 25, 2011
Wednesday, August 17, 2011
a letter to a teacher by a student !
Long back one of my class had a brilliant student ,she had acheived a UG degree from IITs.On analysing her performance and various companies calling for campus ,I asked her to take up the offer by microsoft
This was her reply to me ....
Hididi,
All know politicians r so corrupt n inefficient.
Weknow how a good political system and efficient n responsiblegovernment can do as it did in china, south korea..sometimes i think of joining politics so that i contribute if notmuch then atleast something to change the political system.
But u were right. I m a student of technology n i should focus on that.Let narendra modi do politics..
you asked me why i dont want to join microsoft?
Why you adviced me to join microsoft?
Probably because
indians get much respect n recognition there.
I will get a lot opportunities and infrastructure.
I will get a huge pay there..
life will be so easy so high standard with no problems..
By 1990, India and china were equal economies. Now china is a 4 trilliondollar economy and India is just 1 trillion dollar. One of thereasons is that chinese people dont know english language and thus work in the country.. same for south korea. Same for germany.. Myfrench course instructor in IIT Kanpur was from france and she openly said that french people hate english language.. now u will say china n India have different government system.. thencompare India with US. Same governance system, similar amount ofnatural resources. US had even more serious problems than India. Itshard to believe how whitemen and black people live together, so manyraces from all parts of the world live together. Its so huge countrythat its more vulnerable to corruption and problems than India orany other country. Just we people lack confidence that we are notinferior to anybody. From my past
experience,especially during my preparations for JEE I learnt that one who looses confidence during tough times looses the most and one who somehow maintains confidence during toughest times is the ultimate winner.
Inspite all the problems, wher India stands today is because of its scientists and engineers. India has developed indigenous oil drilling technology and nuclear technology. After so many unsuccesfulattempts, India earns today by launching satellites of othercountries.
Its because of the people who chose to work in thecountry.. Barack obama asks their countrymen to work hard because he fears Indian scientists and engineers will overtake them in future.
50 years ago IITs were established with a vision that they wouldtechnologically revolutionize the nation. There is a great responsibility on iitians to build the nation. I feel its my moralresponsibility to work for the nation. And I think u r doing really a great job by training the engineers..
I strongly diagree with one thing u said that taxing on people andfunding institutes and colleges is just money circulation..
Headlinescome “Bill Gates launched windows 7”. Who knows or cares that itsnot bill gates but Indian engineers r behind that.
So why not to work in India. If all start thinking of working in foreign and running away from problems then ho gaya kalyan sab ka...
Microsoft and US are already at their highest but our country is in the middle.So contributing to our country in bringing it up is more pleasuring task for me than to contribute to already developed US. There are people which run away from problems and there are people whichfight against the problem. Different people different thinking different choices.
Maybe ur more correct than me as u r more experienced about the actualworld than me but let me too experience.Maybe situation may arise that I have work in europe or US, I will trymy best to work for the people.
I hope u are not satisfied with my reply..
I hope younger generation are hotblooded as well commited to country .I thought of sharing with you all.
Sunday, August 7, 2011
8086 lab manual
1. ADDITION OF TWO 8-BIT HEXADECIMAL NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD BL,DL
JNC NEXT
INC CL
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : E9
ENTER SECOND NUMBER : FA
SUM OF TWO 8-BIT NUMBER IS : 1E3
ENTER FIRST NUMBER : AB
ENTER SECOND NUMBER : CD
SUM OF TWO 8-BIT NUMBER IS : 178
2. ADDITION OF TWO 8-BIT BCD
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
ADD AL,DL
DAA
JNC NEXT
INC CL
NEXT:MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 97
ENTER SECOND NUMBER : 56
SUM OF TWO 8-BIT NUMBER IS : 153
ENTER FIRST NUMBER : 82
ENTER SECOND NUMBER : 19
SUM OF TWO 8-BIT NUMBER IS : 101
3. ADDITION OF TWO 16-BIT HEXADECIMAL NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 16-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD BX,DX
JNC NEXT
INC CL
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 2345
ENTER SECOND NUMBER : 5646
SUM OF TWO 16-BIT NUMBER IS : 0798B
ENTER FIRST NUMBER : FFFF
ENTER SECOND NUMBER : AAAA
SUM OF TWO 16-BIT NUMBER IS : 1AAA9
4. ADDITION OF TWO 16-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 16-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
ADD AL,DL
DAA
MOV BL,AL
MOV AL,BH
ADC AL,DH
DAA
JNC NEXT
INC CL
NEXT:MOV BH,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 6987
ENTER SECOND NUMBER : 3991
SUM OF TWO 16-BIT NUMBER IS : 10978
ENTER FIRST NUMBER : 9999
ENTER SECOND NUMBER : 8888
SUM OF TWO 16-BIT NUMBER IS : 18887
5. SUBTRACTION OF TWO 8-BIT HEXADECIMAL NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
SUB BL,DL
JNC NEXT
NEG BL
MOV CL,'-'
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 55
ENTER SECOND NUMBER : AA
SUBTRACTION OF TWO 8-BIT NUMBER IS : -55
ENTER FIRST NUMBER : FA
ENTER SECOND NUMBER : 93
SUBTRACTION OF TWO 8-BIT NUMBER IS : -67
6. SUBTRACTION OF TWO 8-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
SUB AL,DL
DAS
JNC NEXT
MOV CH,99H
SUB CH,AL
MOV AL,CH
ADD AL,01H
DAA
MOV CL,'-'
NEXT:
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 98
ENTER SECOND NUMBER : 54
SUBTRACTION OF TWO 8-BIT NUMBER IS : 044
ENTER FIRST NUMBER : 87
ENTER SECOND NUMBER : 98
SUBTRACTION OF TWO 8-BIT NUMBER IS : -11
7. SUBTRACTION OF TWO 16-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'SUBTRACTION IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,' '
SUB BX,DX
MOV CL,00H
JNC NEXT
INC CL
MOV CL,'-'
NEG BX
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : DE32
ENTER SECOND NUMBER : 97CA
SUBTRACTION OF TWO 8-BIT NUMBER IS : 04668
ENTER FIRST NUMBER : 698F
ENTER SECOND NUMBER : B2C6
SUBTRACTION OF TWO 8-BIT NUMBER IS : -4937
8. SUBTRACTION OF TWO 16-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 16-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MOV CL,' '
MOV AL,BL
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,DH
DAS
MOV BH,AL
JNC NEXT
MOV AX,0000H
SUB AL,BL
ADD DL,01H
DAS
MOV BL,AL
MOV AL,AH
SBB AL,BH
DAS
MOV BH,AL
MOV CL,'-'
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 9873
ENTER SECOND NUMBER : 8642
SUBTRACTION OF TWO 8-BIT NUMBER IS : 01231
ENTER FIRST NUMBER : 2431
ENTER SECOND NUMBER : 9247
SUBTRACTION OF TWO 8-BIT NUMBER IS : -6816
9. MULTIPLICATION OF TWO 8-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER THE SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'PRODUCT IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MUL DL
MOV BX,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 01
ENTER SECOND NUMBER : 01
PRODUCT IS : 0001
ENTER FIRST NUMBER : 0A
ENTER SECOND NUMBER : 0A
PRODUCT IS : 0064
10.MULTIPLICATION OF TWO 16-BIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'PRODUCT IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MUL DX
MOV BX,DX
MOV SI,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4: RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,04H
MOV CL,04H
L3: MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
CMP CH,03H
JNZ L5
MOV DX,SI
L5:MOV BL,DH
MOV DH,DL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER FIRST NUMBER : F4D9
ENTER SECOND NUMBER : 6A52
PRODUCT OF TWO NUMBERS : 65B04782
ENTER FIRST NUMBER : 23CD
ENTER SECOND NUMBER : 542E
PRODUCT OF TWO NUMBERS : 0BC5B2D6
10. DIVISION OF 8-BIT BY 8-BIT NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE DIVIDEND:','$'
MESS2 DB 0AH,0DH,'ENTER THE DIVISOR:','$'
MESS3 DB 0AH,0DH,'DIVISION IS :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AH,00H
MOV AL,BL
DIV DL
MOV BH,AL
MOV AL,00H
DIV DL
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LP1:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BH,BL
JMP LP1
NXT:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE DIVIDEND : D1
ENTER THE DIVISOR : B2
DIVISION : 01.00
ENTER THE DIVIDEND : A2
ENTER THE DIVISOR : 13
DIVISION : 08.00
11. DIVISION OF 16-BIT BY 16-BIT NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE DIVIDEND:','$'
MESS2 DB 0AH,0DH,'ENTER THE DIVISOR:','$'
MESS3 DB 0AH,0DH,'DIVISION IS :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV DX,0000H
MOV AX,BX
DIV SI
MOV BX,AX
MOV AX,0000H
DIV SI
MOV SI,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
BACK:MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L3
ADD DL,07H
L3:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L4
ADD BL,07H
L4:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BX,SI
MOV BL,BH
JMP BACK
NXT:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE DIVIDEND : 6543
ENTER THE DIVISOR : 1234
DIVISION : 0005.90
ENTER THE DIVIDEND : FFFF
ENTER THE DIVISOR : CCCC
DIVISION : 0001.40
13.AVERAGE OF ‘N’ 8-BIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$'
MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$'
MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV dh,00h
BACK: DEC CH
MOV DL,','
MOV AH,06H
INT 21H
JZ NEXT
CALL READ
ADD BL,DL
JNC LP1
INC DH
LP1:JMP BACK
NEXT:MOV AL,BL
MOV AH,DH
DIV BH
MOV BL,AL
MOV AL,00H
DIV BH
MOV BH,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LP2: MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BL,BH
JMP LP2
NXT:RET
DISP ENDP
CODE ENDS
END START
OUPTUT:
ENTER THE LIMIT: 05
ENTER THE NUMBERS: 34,65,24,87,45
THE AVERAGE IS : 4E.99
14. AVERAGE OF 8-BIT NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$'
MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$'
MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV DH,CH
MOV BH,00H
N1:MOV AL,CH
SUB AL,01H
DAS
MOV CH,AL
JZ N2
MOV DL,','
MOV AH,06H
INT 21H
CALL READ
MOV AL,BL
ADD AL,DL
DAA
MOV BL,AL
JNC N3
MOV AL,BH
ADD AL,01H
DAA
MOV BH,AL
N3:JMP N1
N2:MOV CH,02H
MOV DL,DH
MOV DH,00H
MOV CL,00H
N4: MOV AX,BX
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,00H
DAS
MOV BH,AL
MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
CMP BX,DX
JAE N4
DEC CH
JZ N5
MOV QUO,CL
MOV CL,00H
MOV BH,BL
JMP N4
N5: MOV BL,QUO
MOV BH,CL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LOP:MOV CL,04H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ RT
CMP CH,01H
JNZ L3
MOV DL,'.'
MOV AH,06H
INT 21H
L3:MOV BL,BH
JMP LOP
RT:RET
DISP ENDP
CODE ENDS
END START
OUPTUT:
ENTER THE LIMIT: 05
ENTER THE NUMBERS: 34,45,56,67,78
THE AVERAGE IS : 56
15.ADDITION OF TWO 6-DIGIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE 1ST NUMBER: ''$'
MESS2 DB 0AH,0DH,'ENTER THE 2ND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 6-DIGIT NUMBER IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV BL,BH
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD SI,DX
ADC BL,BH
JNC NEXT
INC CL
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,03H
X1:MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
DEC CH
JZ X2
CMP CH,02H
JNZ R3
MOV BH,DL
JMP X1
R3:MOV DH,DL
JMP X1
X2:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,03H
LP1:MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ LAST
CMP CH,02H
JNZ L3
MOV DX,SI
L3: MOV BL,DH
MOV DH,DL
JMP LP1
LAST :RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER: 23ABCF
ENTER FIRST NUMBER:F45C24
SUM OF TWO NUMBERS:11807F3
ENTER FIRST NUMBER: 111111
ENTER FIRST NUMBER:222222
SUM OF TWO NUMBERS:0333333
16.ADDITION OF TWO 6-DIGIT NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE 1ST NUMBER: ''$'
MESS2 DB 0AH,0DH,'ENTER THE 2ND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 6-DIGIT NUMBER IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV BH,BL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD AL,DL
DAA
MOV DL,AL
MOV AL,AH
ADC BH,BL
MOV DH,DL
MOV SI,DX
ADC BH,BL
MOV AL,BH
DAA
MOV BH,AL
JNC NEX
INC CL
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,03H
X1:MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
R1:SHL DL,CL
MOV AH,01H
INT 21H
R2:AND AL,0FH
OR DL,AL
DEC CH
JZ X2
CMP CH,01H
JZ R3
R3:MOV DH,DL
JMP X1
X2:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,03H
LP1:MOV CL,04H
MOV DL,BH
SHR DL,CL
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ LAST
CMP CH,02H
JNZ L3
MOV DX,SI
L3: MOV BH,DH
MOV DH,DL
JMP LP1
LAST :RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER: 234567
ENTER FIRST NUMBER:954132
SUM OF TWO NUMBERS:1188699
ENTER FIRST NUMBER: 111111
ENTER FIRST NUMBER:222222
SUM OF TWO NUMBERS:0333333
17.TO FIND MAXIMUM AND MINIMUM OF GIVEN NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'ENTER NUMBERS :''$'
MESS3 DB 0AH,0DH,'MAXIMUM IS :''$'
MESS4 DB 0AH,0DH,'MINIMUM IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
MOV BL,DL
L1:DEC CH
JZ L2
MOV DL,','
MOV AH,06H
INT 21H
CALL READ
MOV DH,DL
CMP BH,DL
JAE L3
XCHG BH,DL
L3:CMP BL,DH
JBE L4
XCHG BL,DH
L4:JMP L1
L2:LEA DX,MESS3
MOV AH,09H
INT 21H
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
MOV BH,BL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC N2
ADD BH,07H
N2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
ENTER NUMBERS : 22, 78, 96, 30, 12
MAXIMUM IS : 96
MINIMUM IS : 12
ENTER LIMIT : 07
ENTER NUMBERS : 32,12,F4,09,67,F5,8D
MAXIMUM IS : F5
MINIMUM IS : 09
18. SORTING OF ‘N’NUMBERS
DATA SEGMENT
M1 DB 0AH,0DH,'ENTER THE LIMIT:' , '$'
M2 DB 0AH,0DH,'THE NUMBERS IS:' , '$'
M3 DB 0AH,0DH,'THE SORTED NUMBERS ARE :' , '$'
ARRAY DB 20 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START : MOV AX,DATA
MOV DS,AX
LEA DX,M1
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
MOV BH,CH
MOV DI,BX
LEA DX,M2
MOV AH,09H
INT 21H
LEA SI ,ARRAY
L1: CALL READ
MOV [SI],CH
INC SI
DEC BL
JNZ L1
LEA DX,M3
MOV AH,09H
INT 21H
LEA BP,ARRAY
L2: MOV BL,BH
MOV SI,BP
L4: DEC BL
JZ L3
INC SI
MOV AL,[BP]
CMP AL,[SI]
JNA L4
MOV AH,[SI]
MOV [SI],AL
MOV [BP],AH
JMP L4
L3:INC BP
DEC BH
JNZ L2
LEA SI,ARRAY
MOV BX,DI
L5:CALL DISP
INC SI
DEC BH
JNZ L5
MOV AX,4C00H
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R1
SUB AL,07H
R1:MOV CL,04H
SHL AL,CL
MOV CH,AL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR CH,AL
MOV DL,' '
MOV AH,06H
INT 21H
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV BL,[SI]
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC X1
ADD DL,07H
X1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC X2
ADD BL,07H
X2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
MOV DL,' '
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE LIMIT : 05
THE NO IS : 65 41 37 82 04
THE SORTED NUMBERS ARE : 04 37 41 65 82
ENTER THE LIMIT : 06
THE NO IS : 23 ,06,14,98,67,25
THE SORTED NUMBERS ARE : 06,14,23,25,67,98
19.ADDITION OF TWO MATRICES (HEXADECIMAL)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$' M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$' M5 DB 0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,00H
MOV DL,[SI]
ADD DL,[DI]
JNC L5
INC DH
L5:MOV [BX],DH
INC BX
MOV [BX],DL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
PUBLIC READ1
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
MOV CL,04H
MOV DL,[BX]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT 1:
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
11 11
11 11
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
SUM OF TWO MATRICES:
013 013
014 014
OUTPUT 2:
ENTER THE ORDER OF FIRST MATRIX : 2 3
ENTER THE ORDER OF SECOND MATRIX : 2 2
MATRICES CANNOT BE ADDED
20.ADDITION OF TWO MATRICES (BCD)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$'
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,00H
MOV AL,[SI]
ADD AL,[DI]
DAA
JNC L5
INC DH
L5:MOV [BX],DH
INC BX
MOV [BX],AL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP l6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
MOV CL,04H
MOV DL,[BX]
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
12 13
15 14
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
SUM OF TWO MATRICES:
014 016
017 016
21. SUBTRACTION OF TWO MATRICES (HEXADECIMAL)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$'
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' DIFFERENCE OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,' '
MOV DL,[DI]
SUB DL,[SI]
JNC L52
NEG DL
MOV DH,'-'
L5:MOV [BX],DH
INC BX
MOV [BX],DL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
AND DL,0FH
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
MOV AH,06H
INT 21H
INC BX
MOV DL,[BX]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
55 65
75 85
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
DIFFERENCE OF TWO MATRICES:
053 063
073 083
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 3
MATRICES CANNOT BE SUBTRACTED
22. SUBTRACTION OF TWO MATRICES (BCD)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' DIFFERENCE OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,' '
MOV AL,[DI]
SUB AL,[SI]
DAS
JNC L5
MOV DL,99H
SUB DL,AL
MOV AL,DL
ADD AL,01H
DAA
MOV DH,'-'
L5:MOV [BX],DH
INC BX
MOV [BX],AL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
MOV AH,06H
INT 21H
INC BX
MOV DL,[BX]
SHR DL,CL
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
10 10
10 10
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
DIFFERENCE OF TWO MATRICES:
08 08
08 08
23.TRANSPOSE OF THE MATRIX
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF THE MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'TRANSPOSE MATRIX:',0AH,0DH,'$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
LEA SI,MAT1
CALL READ1
LEA DI,MAT1
LEA SI,MAT2
MOV DH,00H
MOV DL,COL
MOV AH,COL
L3:MOV AL,ROW
MOV BX,DI
L1:MOV CL,[BX]
MOV [SI],CL
ADD BX,DX
INC SI
DEC AL
JNZ L1
INC DI
DEC AH
JNZ L3
LEA SI,MAT2
CALL DISP
MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
AND DL,0FH
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MESSAGE M3
BSPCE 0AH
MOV DH,COL
D4:MOV BH,ROW
LOP:MOV CL,04H
MOV DL,[SI]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[SI]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC SI
BSPCE ' '
DEC BH
JNZ LOP
DEC DH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT :
ENTER THE ORDER OF THE MATRIX : 2 3
ENTER THE ELEMENTS OF THE MATRIX:
11 55 99
22 74 51
TRANSPOSE MATRIX :
11 22
55 74
99 51
24.GENERATION OF PRIME NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'PRIME NUMBERS UPTO LIMIT :''$'
MESS3 DB 0AH,0DH,'NO OF ELEMENTS IN PRIME SERIES= ''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR SI,SI
MOV DH,00H
L1: INC DH
JZ L3
CMP DH,CH
JA L3
CALL SQRT
MOV BH,01H
L2:MOV AL,DH
MOV AH,00H
INC BH
CMP BH,DL
JA L4
DIV BH
CMP AH,00H
JNZ L2
JMP L1
L4:MOV BL,DH
CALL DISP
MOV DL,','
MOV AH,06H
INT 21H
INC SI
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2: OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC N2
ADD BL,07H
N2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC DISP
MOV DL,00H
T1:INC DL
MOV AL,DH
MOV AH,00H
DIV DL
CMP DL,AL
JC T1
JZ T2
DEC DL
T2:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 0F
PRIME NUMBERS UPTO LIMIT : 01,02,03,05,07,0B,0D
NO. OF ELEMENTS IN PRIME SERIES : 07
25. GENERATION OF PRIME NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'PRIME NUMBERS UPTO LIMIT :''$'
MESS3 DB 0AH,0DH,'NO OF ELEMENTS IN PRIME SERIES= ''$'
NUM DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV DH,00H
MOV SI,0000H
L1:MOV AL,DH
ADD AL,01H
DAA
JC L3
MOV DH,AL
CMP DH,CH
JA L3
CALL SQRT
MOV BH,01H
L2:MOV AL,BH
ADD AL,01H
DAA
MOV BH,AL
CMP BH,DL
JA L4
MOV AH,00H
MOV NUM,DH
L5:MOV AL,NUM
SUB AL,BH
DAS
MOV NUM,AL
MOV AL,AH
ADD AL,01H
DAA
MOV AH,AL
CMP NUM,BH
JAE L5
CMP NUM,00H
JZ L1
JMP L2
L4: MOV BL,DH
CALL DISP
MOV DL,'.'
MOV AH,06H
INT 21H
MOV AX,SI
ADD AL,01H
DAA
MOV SI,AX
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC DISP
MOV DL,00H
T1:INC DL
MOV BL,00H
MOV CL,DH
T2:MOV AL,CL
SUB AL,DL
DAS
MOV CL,AL
INC BL
CMP CL,DL
JAE T2
CMP DL,BL
JC T1
JE T3
DEC DL
T3:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 09
PRIME NUMBERS UPTO LIMIT : 01,02,03,05,07
NO. OF ELEMENTS IN PRIME SERIES : 05
26.GENERATION OF PERFECT DIVIDING NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 'ENTER THE LIMIT :','$'
MESS2 DB 0AH,0DH,'PERFECT DIVISORS:','$'
MESS3 DB 0AH,0DH,'NUMBER OF PERFECT DIVISORS UPTO THE LIMIT=','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR SI,SI
MOV DH,01H
L1: INC DH
JZ L3
CMP DH,CH
JA L3
CALL SQRT
MOV BL,01H
MOV BH,01H
L2: INC BH
CMP BH,DL
JA L4
MOV AH,00H
MOV AL,DH
DIV BH
CMP AH,00H
JNE L2
ADD AL,BH
ADD BL,AL
JMP L2
L4: CMP BL,DH
JNE L1
CALL DISP
MOV DL,' '
MOV AH,06H
INT 21H
INC SI
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC N2
ADD BL,07H
N2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC SQRT
MOV DL,00H
T1:INC DL
MOV AL,DH
MOV AH,00H
DIV DL
CMP DL,AL
JC T1
JZ T2
DEC DL
T2:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : FF
PERFECT DIVISORS ARE: 06 1C
NO. OF ELEMENTS : 02
27.GENERATION OF PERFECT DIVIDING NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 'ENTER THE LIMIT :','$'
MESS2 DB 0AH,0DH,'PERFECT DIVISORS :','$'
MESS3 DB 0AH,0DH,'NUMBER OF PERFECT DIVISORS UPTO THE LIMIT=','$'
LIM DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR DI,DI
CALL PERFECT
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CX,DI
MOV BL,CL
CALL DISP
MOV AH,4CH
INT 21H
PERFECT PROC NEAR
PUBLIC PERFECT
MOV BL,01H
P1:CMP BH,BL
JA P3
RET
P3: CALL SQRT
MOV DL,01H
MOV CH,CL
MOV CL,02H
P4: CMP CH,CL
JC P5
MOV AH,BL
XOR DH,DH
CALL DIVD
CMP AH,00H
JNZ P7
MOV AL,DL
ADD AL,DH
DAA
ADD AL,CL
DAA
MOV DL,AL
P7: MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
JMP P4
P5: CMP DL,01H
JE P6
CMP BL,DL
JNE P6
CALL DISP
MOV AX,DI
ADD AL,01H
DAA
MOV DI,AX
P6: MOV AL,BL
ADD AL,01H
DAA
MOV BL,AL
JMP P1
PERFECT ENDP
SQRT PROC NEAR
PUBLIC SQRT
MOV CL,01H
B3: XOR DH,DH
MOV AH,BL
MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
CALL DIVD
CMP DH,CL
JAE B3
MOV AL,CL
SUB AL,01H
DAS
MOV CL,AL
RET
SQRT ENDP
DIVD PROC NEAR
PUBLIC DIVD
B1: CMP AH,CL
JB B2
MOV AL,AH
SUB AL,CL
DAS
MOV AH,AL
MOV AL,DH
ADD AL,01H
DAA
MOV DH,AL
JMP B1
B2:RET
DIVD ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV BH,AL
SUB BH,30H
MOV CL,04H
SHL BH,CL
MOV AH,01H
INT 21H
SUB AL,30H
OR BH,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV AH,BL
MOV DL,AH
MOV CL,04H
SHR AH,CL
ADD AH,30H
MOV DL,AH
MOV AH,06H
INT 21H
MOV AH,BL
AND AH,0FH
ADD AH,30H
MOV DL,AH
MOV AH,06H
INT 21H
MOV DL,' '
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 99
PERFECT DIVISORS ARE: 06 28
NO. OF ELEMENTS : 02
ENTER LIMIT : 20
PERFECT DIVISORS ARE: 06
NO. OF ELEMENTS : 01
27.GENERATION OF FIBONACCI SERIES (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,0DH,'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
ADD TEMP,BH
JC NEXT
MOV BL,TEMP
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT: AA
FIBONACCI SERIES UPTO THE LIMIT AA IS : 00 01 01 02 03 05 08 0D 15 22 37 59 90
NUMBERS OF ELEMENTS IN FIBONACCI SERIES : 13
28.GENERATION OF FIBONACCI SERIES (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,ODH'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
ADD TEMP,BH
JC NEXT
MOV BL,TEMP
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : FF
PERFECT DIVISORS ARE: 06 1C
NO. OF ELEMENTS IN PRIME SERIES : 02
ENTER THE LIMIT: 08
THE FIBONACCI SERIES UPTO THE LIMIT 09 IS: 00,01,01,02,03,05,08
NUMBERS OF ELEMENTS IN THE FIBONACCI SERIES:07
29.GENERATION OF FIBONACCI SERIES (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,0DH,'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH, 09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
MOV AL,TEMP
ADD AL,BH
DAA
JC NEXT
MOV BL,AL
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT: 99
FIBONACCI SERIES UPTO THE LIMIT 99 IS : 00 01 01 02 03 05 08 13 21 34 55 89
NUMBER OF ELEMENTS IN THE FIBONACCI SERIES :12
30.FACTORIAL OF A NUMBER USING RECURSION TECHNIQUE
DATA SEGMENT
MESS1 DB 'ENTER THE NUMBER(0-8):''$'
MESS2 DB 0AH,0DH, ' FACTORIAL OF THE GIVEN NUMBER=''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV AX,0001H
MOV BH,00H
CALL FACT
MOV BX,AX
CALL DISP
MOV AH,4CH
INT 21H
FACT PROC NEAR
PUBLIC FACT
CMP BX,0001H
JBE NEXT
MUL BX
DEC BX
CALL FACT
NEXT:RET
FACT ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CL,04H
MOV CH,02H
BACK:MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L3
MOV BH,BL
JMP BACK
L3:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NO<0-8> : 7
FACTORIAL OF THE GIVEN NUMBER : 13B0
ENTER THE NO<0-8> : 5
FACTORIAL OF THE GIVEN NUMBER : 0078
31. CONVERSION FROM BINARY TO GRAY ( HEXADECIMAL )
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER BINARY CODE :''$'
MESS2 DB 0AH,0DH,'EQUIVALENT GRAY CODE :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
SHR DL,01H
XOR BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER BINARY CODE: 10
EQUIVALENT GRAY CODE: 18
ENTER BINARY CODE: 80
EQUIVALENT GRAY CODE: C0
ENTER BINARY CODE: F0
EQUIVALENT GRAY CODE: 88
32.CONVERSION FROM GRAY CODE TO BINARY CODE(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER GRAY CODE :''$'
MESS2 DB 0AH,0DH,'EQUIVALENT BINARY CODE :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV CH,07H
M1:SHR DL,01H
XOR BL,DL
DEC CH
JNZ M1
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER GRAY CODE: ‘21
EQUIVALENT BINARY CODE: ‘3E
ENTER GRAY CODE: 80
EQUIVALENT BINARY CODE: FF
33.CONVERSION OF ARRAY OF BINARY CODE TO GRAY CODE
(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'BINARY CODE GRAY CODE :''$'
NL DB 0AH,0DH,' ','$'
BSP DB' ','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
M1:LEA DX,NL
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
SHR DL,01H
XOR BL,DL
LEA DX,BSP
MOV AH,09H
INT 21H
CALL DISP
DEC BH
JNZ M1
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
BINARY CODE GRAY CODE
3E 21
21 31
16 1D
10 18
02 03
34. CONVERSION OF ARRAY OF GRAYCODE TO BINARY CODE
(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'GRAY CODE BINARY CODE :''$'
NL DB 0AH,0DH,' ','$'
BSP DB' ','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
M2:LEA DX,NL
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV CH,07H
M1: SHR DL,01H
XOR BL,DL
DEC CH
JNZ M1
LEA DX,BSP
MOV AH,09H
INT 21H
CALL DISP
DEC BH
JNZ M2
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
GRAY BINARY
03 02
14 18
21 3E
C2 83
A5 C6
35.GCD OF TWO 8-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'GCD OF TWO NUMBER IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
T1:MOV AL,BH
MOV AH,00H
DIV BL
MOV BH,BL
MOV BL,AH
CMP AH,00H
JNE T1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 0A
ENTER SECOND NUMBER : 05
GCD OF TWO NUMBER IS : 05
ENTER FIRST NUMBER : 0C
ENTER SECOND NUMBER : 06
GCD OF TWO NUMBER IS : 06
36.GCD OF TWO 8-BIT NUMBERS(BCD).
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'GCD OF TWO NUMBER IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
N1:CMP BH,BL
JZ N3
JNB N2
MOV AL,BL
SUB AL,BH
DAS
MOV BL,AL
JMP N1
N2:MOV AL,BH
SUB AL,BL
DAS
MOV BH,AL
JMP N1
N3:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BH
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : ‘08
ENTER SECOND NUMBER : ‘12
GCD OF TWO NUMBER IS : ‘04
ENTER FIRST NUMBER : ‘09
ENTER SECOND NUMBER : ‘06
GCD OF TWO NUMBER IS : ‘03
37.REVERSE OF A BYTE
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE NUMBER :','$'
MESS2 DB 0AH,0DH,'REVERSE OF A GIVEN BYTE :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,00H
MOV CH,08H
N1: SHL DL,01H
RCR BL,01H
DEC CH
JNZ N1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV DL,' '
MOV AH,06H
INT 21H
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NUMBER : 12
REVERSE OF GIVEN BYTE: 48
ENTER THE NUMBER:F8
REVERSE OF GIVEN BYTE:1F
38.REVERSAL OF WORD
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE NUMBER :','$'
MESS2 DB 0AH,0DH,'REVERSE OF A GIVEN NUMBER :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
MOV BX,0000H
MOV CH,10H
N1: SHL DX,01H
RCR BX,01H
DEC CH
JNZ N1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4: RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NUMBER: F4C9
REVERSE OF THE GIVEN WORD:932F
ENTER THE NUMBER: B27A
REVERSE OF THE GIVEN WORD:5E4D
39.REVERSAL OF AN ARRAY
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'ENTER THE ARRAY ELEMENTS :''$'
MESS3 DB 0AH,0DH,'REVERSE OF THE STRING :''$'
NUM DB 10 DUP (0)
RNUM DB 10 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV DH,CH
LEA BX,NUM
L1:CALL READ
MOV [BX],DL
INC BX
DEC DH
JNZ L1
LEA SI,RNUM
LEA BX,NUM
MOV DL,CH
MOV DH,00H
ADD BX,DX
MOV DH,CH
L2:DEC BX
MOV DL,[BX]
MOV [SI],DL
DEC DH
JZ NEXT
INC SI
JMP L2
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV DL,','
MOV AH,06H
INT 21H
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2: OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
LEA SI,RNUM
MOV CL,04H
M3:MOV DL,','
MOV AH,06H
INT 21H
MOV bL,[SI]
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC M1
ADD DL,07H
M1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC M2
ADD BL,07H
M2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ M4
INC SI
JMP M3
M4: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT OF AN ARRAY:05
ENTER THE ARRAY ELEMENTS:12,4C,DB,D5
REVERSE OF THE GIVEN ARRAY:D5,DB,4C,12
40.TO DISPLAY CURRENT TIME.
DATA SEGMENT
MESS1 DB 0AH,0DH,'TIME IS:'0AH,0DH,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
L1:MOV AH,2CH
INT 21H
MOV AL,CH
CALL CONV
CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV AL,CL
CALL CONV
CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV DL,0DH
MOV AH,06H
INT 21H
JMP L1
MOV AH,4CH
INT 21H
DISP PROC NEAR
PUBLIC DISP
MOV BL,AH
MOV DL,AL
ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,BL
ADD DL,30H
MOV AH,06H
INT 21H
RET
DISP ENDP
CONV PROC NEAR
PUBLIC CONV
MOV AH,00H
MOV BH,0AH
DIV BH
RET
CONV ENDP
CODE ENDS
END START
OUTPUT:
THE CURRENT TIME IS: 23:37:23.85
41.TO DISPLAY CURRENT DATE.
DATA SEGMENT
MESS1 DB 0AH,0DH,'THE CURRENT DATE IS:'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV AH,2AH
INT 21H
MOV SI,CX
MOV BL,DH
MOV BH,DL
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
MOV BL,BH
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
XOR DX,DX
MOV AX,SI
MOV CX,0064H
DIV CX
MOV DH,DL
MOV BL,AL
CALL DISP
MOV BL,DH
MOV AH,4CH
INT 21H
CONV PROC NEAR
PUBLIC CONV
MOV CL,04H
XOR AH,AH
MOV AL,BL
MOV BL,0AH
DIV BL
SHL AL,CL
ADD AL,AH
DAA
MOV BL,AL
RET
CONV ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
CALL CONV
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
THE CURRENT DATE IS: MON 07/11/2011
INTERFACING PROGRAMS
1.SEVEN SEGMENT DISPLAY
CONFIGURATION
PORT A OUTPUT
PORT B OUTPUT
PORT C LOW OUTPUT
PORT C UP OUTPUT
ADDRESSES
PORTA EQU 0D800H
PORTB EQU 0D801H
PORTC EQU 0D802H
CONTROL WORD
For 8255, Port A and B are used as output ports. The control word format of 8255 according to hardware connections is:
1.SEVEN SEGMENT DISPLAY
DATA SEGMENT
MESS1 DB 'ENTER A 4-DIGIT NUMBER: ','$'
SEVSEG DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
NUMAR DB 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV DX,0D883H
MOV AL,80H
OUT DX,AL
LEA SI,NUMAR
CALL READ
L2:LEA SI,NUMAR
MOV CH,03H
L1:MOV DX,0D882H
MOV AL,CH
OUT DX,AL
MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
CALL DELAY
INC SI
SUB CH,01H
JNC L1
JMP L2
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
LEA BX,SEVSEG
MOV CL,04H
R2:MOV AH,01H
INT 21H
SUB AL,30H
XLAT
MOV [SI],AL
INC SI
DEC CL
JNZ R2
RET
READ ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV DI,00FFH
D2:MOV BP,0FFFH
D1:DEC BP
JNZ D1
DEC DI
JNZ D2
RET
DELAY ENDP
CODE ENDS
END START
2.GENERATE VARIABLE SQUARE WAVE GENERATOR USING 8253
CONFIGURATION
BINARY COUNTER,
MODE 3, R/W LSB FIRST THEN MSB
COUNTER 0
ADDRESSES
COUNTER 0---À 0D888
COUNTER 1---À 0D889
COUNTER 2---À 0D88A
CONTROL REGISTER ---À 0D88B
CONTROL WORD IS 36H
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RW1 RW0 M2 M1 M0 BCD
0 0 1 1 0 1 1 0
3 6
PROGRAM
DATA SEGMENT
MESS DB 'ENTER THE FREQUENCY IN KHZ (01-65KHZ):','$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
LEA DX, MESS
MOV AH, 09H
INT 21H
CALL READ
XOR AH, AH
MOV BX, 03E8H
MUL BX
MOV BX, AX
MOV DX, 001FH
MOV AX, 3E0CH
DIV BX
MOV BX, AX
MOV AL, 36H
MOV DX, 0D88BH
OUT DX, AL
MOV DX, 0D888H
MOV AL, BL
OUT DX, AL
MOV AL, BH
OUT DX, AL
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH, 01H
INT 21H
MOV DH, AL
SUB DH, 30H
MOV AH, 01H
INT 21H
MOV DL, AL
SUB DL, 30H
MOV AL, DH
MOV DH, 0AH
MUL DH
ADD AL, DL
RET
READ ENDP
CODE ENDS
END START
3.GENERATE SQUARE WAVE,SINE ,SAW,TRIANGULAR,STAIRCASE WAVEFORM USING DAC INTERFACE
CONFIGURATION:
PORT A ----> OUTPUT, ADDRESS IS 0D880
PORT B ----> OUTPUT ADDRESS IS 0D881
PORT C LOW ---> OUTPUT ADDRESS IS D882
PORT C HIGH--> OUPTUT ADDRESS IS 0D882
CONTROL PORT ADDRESS IS 0D883S
CONTROL WORD IS 80
D7 D6 D5 D4 D3 D2 D1 D0
BSR or
I/O MODE MODE FOR PORTA PORT A PORT C
(UPPER) MODE FOR PORTA MODE FOR PORTB PORT B PORT C
(LOWER)
1 0 0 0 0 0 0 0
8 0
PROGRAM :
DATA SEGMENT
MESS1 DB 0AH,0DH,' *****************************',0AH,0DH
DB ' 1) SQUARE WAVE',0AH,0DH
DB ' 2) TRIANGULAR WAVE', 0AH,0DH
DB ' 3) STAIRCASE WAVE',0AH,0DH
DB ' 4) SAWTOOTH WAVE',0AH,0DH
DB ' 5) SINE WAVE',0AH,0DH
DB ' ******************************************'
DB 0AH,0DH, ' ENTER THE CHOICE :','$'
MESS2 DB 0AH,0DH,'INVALID CHOICE','$'
SINTT DB 00H,00H,00H,00H,01H,02H,03H,04H,05H,06H,08H,09H,0BH,0DH,0FH
DB 11H,13H,16H,18H,1BH,1EH,21H,24H,27H,2AH,2EH,31H,34H,38H,3CH
DB 40H,44H,47H,4BH,50H,54H,58H,5CH,61H,65H,69H,6EH,72H,77H,7BH
DB 7FH,81H,88H,8DH,91H,96H,9AH,9EH,0A3H,0A7H,0ABH,0AFH,0B3H,0B7H
DB 0BBH,0BFH,0C3H,0C7H,0CAH,0CEH,0D1H,0D4H,0D8H,0DBH,0DEH,0E1H
DB 0E4H,0E7H,0E9H,0EBH,0EEH,0F2H,0F4H,0F6H,0F7H,0F9H,0FAH
DB 0FBH,0FCH,0FDH,0FEH,0FFH,0FFH,0FFH
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AL,80H
MOV DX,0D883H
OUT DX,AL
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
CMP DL,01H
JNE L1
CALL SQWAVE
JMP L6
L1: CMP DL,02H
JNE L2
CALL TRWAVE
JMP L6
L2:CMP DL,3H; SHOULD BE CMP DL,03 NOT CALL DL,30H
JNE L3
CALL STCASE
JMP L6
L3:CMP DL,04H
JNE L4
CALL SAWT
JMP L6
L4:CMP DL,05H
JNE L5
CALL SINWAVE
JMP L6
L5:LEA DX,MESS2
MOV AH,09H
INT 21H
L6: MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READ ENDP
SQWAVE PROC NEAR
PUBLIC SQWAVE
LOOP1: MOV AL,00H
MOV DX,0D880H
OUT DX,AL
CALL DELAYS
MOV AL,0FFH
MOV DX,0D880H
OUT DX,AL
CALL DELAYS
JMP LOOP1
RET
SQWAVE ENDP
TRWAVE PROC NEAR
PUBLIC TRWAVE
T3: MOV CL,00H
MOV BL,0FFH
T1:MOV AL,CL
MOV DX,0D880H
OUT DX,AL
INC CL
CMP CL,BL
JC T1
T2:MOV AL,CL
MOV DX,0D880H
OUT DX,AL
DEC CL
JNZ T2
JMP T3
RET
TRWAVE ENDP
STCASE PROC NEAR
PUBLIC STCASE
MOV AL,00H
S2: MOV DX,0D880H
OUT DX,AL
CALL DELAYS
ADD AL,40H
JMP S2
RET
STCASE ENDP
SAWT PROC NEAR
PUBLIC SAWT
N2: MOV AL,00H
MOV BL,02H
N1:;MOV AL,CL
MOV DX,0D880H
OUT DX,AL
CALL DELAY
INC AL
CMP CL,BL
JNC N1
JMP N1
RET
SAWT ENDP
SINWAVE PROC NEAR
PUBLIC SINWAVE
P3:LEA SI,SINTT
P1:MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
INC SI
CMP AL,0FFH
JNZ P1
P2:MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
DEC SI
CMP AL,00H
JNZ P2
JMP P3
RET
SINWAVE ENDP
DELAYS PROC NEAR
PUBLIC DELAYS
MOV DI,0004H
G2:MOV BP,0FFFFH
G1:DEC BP
JNZ G1
DEC DI
JNZ G2
RET
DELAYS ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV BP,0FFFFH
D1:DEC BP
JNZ D1
RET
DELAY ENDP
CODE ENDS
END START
END
4.TO TEST ALL THE GATES OF A GIVEN IC 74XX IS GOOD OR BAD
CONFIGURATION:
PORT A ----> OUTPUT, ADDRESS IS 0D880
PORT B ----> OUTPUT ADDRESS IS 0D881
PORT C LOW ---> OUTPUT ADDRESS IS D882
PORT C HIGH--> OUPTUT ADDRESS IS 0D882
CONTROL PORT ADDRESS IS 0D883
CONTROL WORD IS 80
D7 D6 D5 D4 D3 D2 D1 D0
BSR or
I/O MODE MODE FOR PORTA PORT A PORT C
(UPPER) MODE FOR PORTA MODE FOR PORTB PORT B PORT C
(LOWER)
1 0 0 0 0 0 1 0
8 2
DATA SEGMENT
NANDTT DB 0FH,0FH,0FH,00H
ANDTT DB 00H,00H,00H,0FH
ORTT DB 00H,0FH,0FH,0FH
XORTT DB 00H,0FH,0FH,00H
MESS1 DB 0AH,0DH,'ENTER THE IC NUMBER (7400/7408/7432/7486):','$'
MESS2 DB 0AH,0DH,'IC IS GOOD.','$'
MESS3 DB 0AH,0DH,'IC IS BAD.','$'
MESS4 DB 0AH,0DH,'IC IS NOT MATCHING.','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
CMP BX,7400H
JNE G1
LEA BX,NANDTT
CALL TEST1
JMP AHEAD
G1: CMP BX,7408H
JNE G2
LEA BX,ANDTT
CALL TEST1
JMP AHEAD
G2:CMP BX,7432H
JNE G3
LEA BX,ORTT
CALL TEST1
JMP AHEAD
G3: CMP BX,7486H
JNE G4
LEA BX,XORTT
CALL TEST1
JMP AHEAD
G4: LEA DX,MESS4
MOV AH,09H
INT 21H
AHEAD: MOV AH,4CH
INT 21H
TEST1 PROC NEAR
PUBLIC TEST1
MOV DX,0D883H
MOV AL,82H
OUT DX,AL
MOV CL,04H
MOV CH,00H
T1:MOV AL,CH
MOV DX,0D880H
OUT DX,AL
PUSH CX
MOV CX,0002H
BACKRP: CALL DELAY
DEC CX
JNZ BACKRP
POP CX
MOV DX,0D881H
IN AL,DX
AND AL,0FH
CMP AL,[BX]
JNE T2
ADD CH,55H
INC BX
DEC CL
JNZ T1
LEA DX,MESS2
MOV AH,09H
INT 21H
JMP T3
T2: LEA DX,MESS3
MOV AH,09H
INT 21H
T3:RET
TEST1 ENDP
READ PROC NEAR
PUBLIC READ
MOV CH,02H
AGAIN : MOV CL,04H
MOV AH,01H
INT 21H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
DEC CH
JZ NXT
MOV DH,DL
JMP AGAIN
NXT:RET
READ ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV BP,0FFFFH
D1: DEC BP
JNZ D1
RET
DELAY ENDP
CODE ENDS
END START
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD BL,DL
JNC NEXT
INC CL
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : E9
ENTER SECOND NUMBER : FA
SUM OF TWO 8-BIT NUMBER IS : 1E3
ENTER FIRST NUMBER : AB
ENTER SECOND NUMBER : CD
SUM OF TWO 8-BIT NUMBER IS : 178
2. ADDITION OF TWO 8-BIT BCD
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
ADD AL,DL
DAA
JNC NEXT
INC CL
NEXT:MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 97
ENTER SECOND NUMBER : 56
SUM OF TWO 8-BIT NUMBER IS : 153
ENTER FIRST NUMBER : 82
ENTER SECOND NUMBER : 19
SUM OF TWO 8-BIT NUMBER IS : 101
3. ADDITION OF TWO 16-BIT HEXADECIMAL NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 16-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD BX,DX
JNC NEXT
INC CL
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 2345
ENTER SECOND NUMBER : 5646
SUM OF TWO 16-BIT NUMBER IS : 0798B
ENTER FIRST NUMBER : FFFF
ENTER SECOND NUMBER : AAAA
SUM OF TWO 16-BIT NUMBER IS : 1AAA9
4. ADDITION OF TWO 16-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 16-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
ADD AL,DL
DAA
MOV BL,AL
MOV AL,BH
ADC AL,DH
DAA
JNC NEXT
INC CL
NEXT:MOV BH,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 6987
ENTER SECOND NUMBER : 3991
SUM OF TWO 16-BIT NUMBER IS : 10978
ENTER FIRST NUMBER : 9999
ENTER SECOND NUMBER : 8888
SUM OF TWO 16-BIT NUMBER IS : 18887
5. SUBTRACTION OF TWO 8-BIT HEXADECIMAL NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NUMBER IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
SUB BL,DL
JNC NEXT
NEG BL
MOV CL,'-'
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 55
ENTER SECOND NUMBER : AA
SUBTRACTION OF TWO 8-BIT NUMBER IS : -55
ENTER FIRST NUMBER : FA
ENTER SECOND NUMBER : 93
SUBTRACTION OF TWO 8-BIT NUMBER IS : -67
6. SUBTRACTION OF TWO 8-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 8-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
MOV AL,BL
SUB AL,DL
DAS
JNC NEXT
MOV CH,99H
SUB CH,AL
MOV AL,CH
ADD AL,01H
DAA
MOV CL,'-'
NEXT:
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 98
ENTER SECOND NUMBER : 54
SUBTRACTION OF TWO 8-BIT NUMBER IS : 044
ENTER FIRST NUMBER : 87
ENTER SECOND NUMBER : 98
SUBTRACTION OF TWO 8-BIT NUMBER IS : -11
7. SUBTRACTION OF TWO 16-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'SUBTRACTION IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,' '
SUB BX,DX
MOV CL,00H
JNC NEXT
INC CL
MOV CL,'-'
NEG BX
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : DE32
ENTER SECOND NUMBER : 97CA
SUBTRACTION OF TWO 8-BIT NUMBER IS : 04668
ENTER FIRST NUMBER : 698F
ENTER SECOND NUMBER : B2C6
SUBTRACTION OF TWO 8-BIT NUMBER IS : -4937
8. SUBTRACTION OF TWO 16-BIT BCD NUMBERS
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NO:','$'
MESS2 DB 0AH,0DH,'ENTER SECOND NO:','$'
MESS3 DB 0AH,0DH,'SUBTRACTION OF TWO 16-BIT NO IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MOV CL,' '
MOV AL,BL
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,DH
DAS
MOV BH,AL
JNC NEXT
MOV AX,0000H
SUB AL,BL
ADD DL,01H
DAS
MOV BL,AL
MOV AL,AH
SBB AL,BH
DAS
MOV BH,AL
MOV CL,'-'
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
MOV AH,06H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 9873
ENTER SECOND NUMBER : 8642
SUBTRACTION OF TWO 8-BIT NUMBER IS : 01231
ENTER FIRST NUMBER : 2431
ENTER SECOND NUMBER : 9247
SUBTRACTION OF TWO 8-BIT NUMBER IS : -6816
9. MULTIPLICATION OF TWO 8-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE FIRST NUMBER:','$'
MESS2 DB 0AH,0DH,'ENTER THE SECOND NUMBER:','$'
MESS3 DB 0AH,0DH,'PRODUCT IS:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MUL DL
MOV BX,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 01
ENTER SECOND NUMBER : 01
PRODUCT IS : 0001
ENTER FIRST NUMBER : 0A
ENTER SECOND NUMBER : 0A
PRODUCT IS : 0064
10.MULTIPLICATION OF TWO 16-BIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'PRODUCT IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AX,BX
MUL DX
MOV BX,DX
MOV SI,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3: MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4: RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,04H
MOV CL,04H
L3: MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
CMP CH,03H
JNZ L5
MOV DX,SI
L5:MOV BL,DH
MOV DH,DL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER FIRST NUMBER : F4D9
ENTER SECOND NUMBER : 6A52
PRODUCT OF TWO NUMBERS : 65B04782
ENTER FIRST NUMBER : 23CD
ENTER SECOND NUMBER : 542E
PRODUCT OF TWO NUMBERS : 0BC5B2D6
10. DIVISION OF 8-BIT BY 8-BIT NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE DIVIDEND:','$'
MESS2 DB 0AH,0DH,'ENTER THE DIVISOR:','$'
MESS3 DB 0AH,0DH,'DIVISION IS :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV AH,00H
MOV AL,BL
DIV DL
MOV BH,AL
MOV AL,00H
DIV DL
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LP1:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BH,BL
JMP LP1
NXT:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE DIVIDEND : D1
ENTER THE DIVISOR : B2
DIVISION : 01.00
ENTER THE DIVIDEND : A2
ENTER THE DIVISOR : 13
DIVISION : 08.00
11. DIVISION OF 16-BIT BY 16-BIT NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE DIVIDEND:','$'
MESS2 DB 0AH,0DH,'ENTER THE DIVISOR:','$'
MESS3 DB 0AH,0DH,'DIVISION IS :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV DX,0000H
MOV AX,BX
DIV SI
MOV BX,AX
MOV AX,0000H
DIV SI
MOV SI,AX
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
BACK:MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L3
ADD DL,07H
L3:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L4
ADD BL,07H
L4:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BX,SI
MOV BL,BH
JMP BACK
NXT:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE DIVIDEND : 6543
ENTER THE DIVISOR : 1234
DIVISION : 0005.90
ENTER THE DIVIDEND : FFFF
ENTER THE DIVISOR : CCCC
DIVISION : 0001.40
13.AVERAGE OF ‘N’ 8-BIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$'
MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$'
MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV dh,00h
BACK: DEC CH
MOV DL,','
MOV AH,06H
INT 21H
JZ NEXT
CALL READ
ADD BL,DL
JNC LP1
INC DH
LP1:JMP BACK
NEXT:MOV AL,BL
MOV AH,DH
DIV BH
MOV BL,AL
MOV AL,00H
DIV BH
MOV BH,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LP2: MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ NXT
MOV DL,'.'
MOV AH,06H
INT 21H
MOV BL,BH
JMP LP2
NXT:RET
DISP ENDP
CODE ENDS
END START
OUPTUT:
ENTER THE LIMIT: 05
ENTER THE NUMBERS: 34,65,24,87,45
THE AVERAGE IS : 4E.99
14. AVERAGE OF 8-BIT NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT: ''$'
MESS2 DB 0AH,0DH,'ENTER THE NUMBER:','$'
MESS3 DB 0AH,0DH,'AVERAGE IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV DH,CH
MOV BH,00H
N1:MOV AL,CH
SUB AL,01H
DAS
MOV CH,AL
JZ N2
MOV DL,','
MOV AH,06H
INT 21H
CALL READ
MOV AL,BL
ADD AL,DL
DAA
MOV BL,AL
JNC N3
MOV AL,BH
ADD AL,01H
DAA
MOV BH,AL
N3:JMP N1
N2:MOV CH,02H
MOV DL,DH
MOV DH,00H
MOV CL,00H
N4: MOV AX,BX
SUB AL,DL
DAS
MOV BL,AL
MOV AL,BH
SBB AL,00H
DAS
MOV BH,AL
MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
CMP BX,DX
JAE N4
DEC CH
JZ N5
MOV QUO,CL
MOV CL,00H
MOV BH,BL
JMP N4
N5: MOV BL,QUO
MOV BH,CL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CH,02H
LOP:MOV CL,04H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ RT
CMP CH,01H
JNZ L3
MOV DL,'.'
MOV AH,06H
INT 21H
L3:MOV BL,BH
JMP LOP
RT:RET
DISP ENDP
CODE ENDS
END START
OUPTUT:
ENTER THE LIMIT: 05
ENTER THE NUMBERS: 34,45,56,67,78
THE AVERAGE IS : 56
15.ADDITION OF TWO 6-DIGIT NUMBERS (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE 1ST NUMBER: ''$'
MESS2 DB 0AH,0DH,'ENTER THE 2ND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 6-DIGIT NUMBER IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV BL,BH
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD SI,DX
ADC BL,BH
JNC NEXT
INC CL
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,03H
X1:MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2:AND AL,0FH
OR DL,AL
DEC CH
JZ X2
CMP CH,02H
JNZ R3
MOV BH,DL
JMP X1
R3:MOV DH,DL
JMP X1
X2:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,03H
LP1:MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ LAST
CMP CH,02H
JNZ L3
MOV DX,SI
L3: MOV BL,DH
MOV DH,DL
JMP LP1
LAST :RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER: 23ABCF
ENTER FIRST NUMBER:F45C24
SUM OF TWO NUMBERS:11807F3
ENTER FIRST NUMBER: 111111
ENTER FIRST NUMBER:222222
SUM OF TWO NUMBERS:0333333
16.ADDITION OF TWO 6-DIGIT NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE 1ST NUMBER: ''$'
MESS2 DB 0AH,0DH,'ENTER THE 2ND NUMBER:','$'
MESS3 DB 0AH,0DH,'SUM OF TWO 6-DIGIT NUMBER IS : ', '$'
QUO DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START :MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV SI,DX
MOV BH,BL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV CL,00H
ADD AL,DL
DAA
MOV DL,AL
MOV AL,AH
ADC BH,BL
MOV DH,DL
MOV SI,DX
ADC BH,BL
MOV AL,BH
DAA
MOV BH,AL
JNC NEX
INC CL
NEXT: CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,03H
X1:MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
R1:SHL DL,CL
MOV AH,01H
INT 21H
R2:AND AL,0FH
OR DL,AL
DEC CH
JZ X2
CMP CH,01H
JZ R3
R3:MOV DH,DL
JMP X1
X2:RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV CH,03H
LP1:MOV CL,04H
MOV DL,BH
SHR DL,CL
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ LAST
CMP CH,02H
JNZ L3
MOV DX,SI
L3: MOV BH,DH
MOV DH,DL
JMP LP1
LAST :RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER: 234567
ENTER FIRST NUMBER:954132
SUM OF TWO NUMBERS:1188699
ENTER FIRST NUMBER: 111111
ENTER FIRST NUMBER:222222
SUM OF TWO NUMBERS:0333333
17.TO FIND MAXIMUM AND MINIMUM OF GIVEN NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'ENTER NUMBERS :''$'
MESS3 DB 0AH,0DH,'MAXIMUM IS :''$'
MESS4 DB 0AH,0DH,'MINIMUM IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
MOV BL,DL
L1:DEC CH
JZ L2
MOV DL,','
MOV AH,06H
INT 21H
CALL READ
MOV DH,DL
CMP BH,DL
JAE L3
XCHG BH,DL
L3:CMP BL,DH
JBE L4
XCHG BL,DH
L4:JMP L1
L2:LEA DX,MESS3
MOV AH,09H
INT 21H
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
MOV BH,BL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC N2
ADD BH,07H
N2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
ENTER NUMBERS : 22, 78, 96, 30, 12
MAXIMUM IS : 96
MINIMUM IS : 12
ENTER LIMIT : 07
ENTER NUMBERS : 32,12,F4,09,67,F5,8D
MAXIMUM IS : F5
MINIMUM IS : 09
18. SORTING OF ‘N’NUMBERS
DATA SEGMENT
M1 DB 0AH,0DH,'ENTER THE LIMIT:' , '$'
M2 DB 0AH,0DH,'THE NUMBERS IS:' , '$'
M3 DB 0AH,0DH,'THE SORTED NUMBERS ARE :' , '$'
ARRAY DB 20 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START : MOV AX,DATA
MOV DS,AX
LEA DX,M1
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
MOV BH,CH
MOV DI,BX
LEA DX,M2
MOV AH,09H
INT 21H
LEA SI ,ARRAY
L1: CALL READ
MOV [SI],CH
INC SI
DEC BL
JNZ L1
LEA DX,M3
MOV AH,09H
INT 21H
LEA BP,ARRAY
L2: MOV BL,BH
MOV SI,BP
L4: DEC BL
JZ L3
INC SI
MOV AL,[BP]
CMP AL,[SI]
JNA L4
MOV AH,[SI]
MOV [SI],AL
MOV [BP],AH
JMP L4
L3:INC BP
DEC BH
JNZ L2
LEA SI,ARRAY
MOV BX,DI
L5:CALL DISP
INC SI
DEC BH
JNZ L5
MOV AX,4C00H
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R1
SUB AL,07H
R1:MOV CL,04H
SHL AL,CL
MOV CH,AL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR CH,AL
MOV DL,' '
MOV AH,06H
INT 21H
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV BL,[SI]
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC X1
ADD DL,07H
X1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC X2
ADD BL,07H
X2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
MOV DL,' '
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE LIMIT : 05
THE NO IS : 65 41 37 82 04
THE SORTED NUMBERS ARE : 04 37 41 65 82
ENTER THE LIMIT : 06
THE NO IS : 23 ,06,14,98,67,25
THE SORTED NUMBERS ARE : 06,14,23,25,67,98
19.ADDITION OF TWO MATRICES (HEXADECIMAL)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$' M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$' M5 DB 0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,00H
MOV DL,[SI]
ADD DL,[DI]
JNC L5
INC DH
L5:MOV [BX],DH
INC BX
MOV [BX],DL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
PUBLIC READ1
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
MOV CL,04H
MOV DL,[BX]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT 1:
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
11 11
11 11
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
SUM OF TWO MATRICES:
013 013
014 014
OUTPUT 2:
ENTER THE ORDER OF FIRST MATRIX : 2 3
ENTER THE ORDER OF SECOND MATRIX : 2 2
MATRICES CANNOT BE ADDED
20.ADDITION OF TWO MATRICES (BCD)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$'
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' SUM OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,00H
MOV AL,[SI]
ADD AL,[DI]
DAA
JNC L5
INC DH
L5:MOV [BX],DH
INC BX
MOV [BX],AL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP l6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
MOV CL,04H
MOV DL,[BX]
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
12 13
15 14
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
SUM OF TWO MATRICES:
014 016
017 016
21. SUBTRACTION OF TWO MATRICES (HEXADECIMAL)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$'
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' DIFFERENCE OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,' '
MOV DL,[DI]
SUB DL,[SI]
JNC L52
NEG DL
MOV DH,'-'
L5:MOV [BX],DH
INC BX
MOV [BX],DL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
AND DL,0FH
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
MOV AH,06H
INT 21H
INC BX
MOV DL,[BX]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
55 65
75 85
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
DIFFERENCE OF TWO MATRICES:
053 063
073 083
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 3
MATRICES CANNOT BE SUBTRACTED
22. SUBTRACTION OF TWO MATRICES (BCD)
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF FIRST MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF FIRST MATRIX:',0AH,0DH,'$
M4 DB 0AH,0DH,0AH,'ENTER THE ELEMENTS OF SECOND MATRIX:',0AH,0DH,'$'
M5 DB 0AH,0DH,0AH,' DIFFERENCE OF TWO MATRICES: ',0AH,0DH, '$'
M6 DB 0AH,0DH,0AH,' MATRICES CANNOT BE ADDED: ','$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
MAT3 DB 30 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
CALL READO
CMP BX,DX
JZ L1
MESSAGE M6
JMP L7
L1:MESSAGE M3
LEA SI,MAT1
CALL READ1
MESSAGE M4
LEA SI,MAT2
CALL READ1
MESSAGE M5
BSPCE 0AH
LEA DI,MAT1
LEA SI,MAT2
LEA BX,MAT3
MOV CH,ROW
L6:MOV CL,COL
L2:MOV DH,' '
MOV AL,[DI]
SUB AL,[SI]
DAS
JNC L5
MOV DL,99H
SUB DL,AL
MOV AL,DL
ADD AL,01H
DAA
MOV DH,'-'
L5:MOV [BX],DH
INC BX
MOV [BX],AL
INC DI
INC SI
INC BX
DEC CL
JNZ L2
DEC CH
JZ L3
JMP L6
L3: CALL DISP
L7: MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA BX,MAT3
MOV CH,ROW
D4:MOV DH,COL
LOP:MOV CL,04H
MOV DL,[BX]
MOV AH,06H
INT 21H
INC BX
MOV DL,[BX]
SHR DL,CL
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[BX]
AND DL,0FH
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC BX
BSPCE ' '
DEC DH
JNZ LOP
DEC CH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE ORDER OF FIRST MATRIX : 2 2
ENTER THE ORDER OF SECOND MATRIX : 2 2
ENTER THE ELEMENTS OF FIRST MATRIX:
10 10
10 10
ENTER THE ORDER OF SECOND MATRIX
02 02
02 02
DIFFERENCE OF TWO MATRICES:
08 08
08 08
23.TRANSPOSE OF THE MATRIX
DATA SEGMENT
M1 DB 'ENTER THE ORDER OF THE MATRIX:','$'
M2 DB 0AH,0DH,0AH,'ENTER THE ORDER OF SECOND MATRIX:','$'
M3 DB 0AH,0DH,0AH,'TRANSPOSE MATRIX:',0AH,0DH,'$'
MAT1 DB 10 DUP(0)
MAT2 DB 10 DUP(0)
ROW DB 00H
COL DB 00H
DATA ENDS
MESSAGE MACRO MESS
LEA DX,MESS
MOV AH,09H
INT 21H
ENDM
BSPCE MACRO ASC
MOV DL,ASC
MOV AH,06H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MESSAGE M1
CALL READO
MOV BX,DX
MOV ROW,DH
MOV COL,DL
MESSAGE M2
LEA SI,MAT1
CALL READ1
LEA DI,MAT1
LEA SI,MAT2
MOV DH,00H
MOV DL,COL
MOV AH,COL
L3:MOV AL,ROW
MOV BX,DI
L1:MOV CL,[BX]
MOV [SI],CL
ADD BX,DX
INC SI
DEC AL
JNZ L1
INC DI
DEC AH
JNZ L3
LEA SI,MAT2
CALL DISP
MOV AH,4CH
INT 21H
READO PROC NEAR
PUBLIC READO
MOV AH,01H
INT 21H
MOV DH,AL
SUB DH,30H
BSPCE ' '
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READO ENDP
READ1 PROC NEAR
BSPCE 0AH
MOV CH,ROW
N2:MOV BH,COL
N1:CALL READ
MOV [SI],DL
INC SI
BSPCE ' '
DEC BH
JNZ N1
DEC CH
JZ N3
BSPCE 0AH
BSPCE 0DH
JMP N2
N3:RET
READ1 ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
AND DL,0FH
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL, 0AH
JC R2
SUB AL,07H
AND AL,0FH
R2:OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MESSAGE M3
BSPCE 0AH
MOV DH,COL
D4:MOV BH,ROW
LOP:MOV CL,04H
MOV DL,[SI]
SHR DL,CL
CMP DL,0AH
JC D1
ADD DL,07H
D1: ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,[SI]
AND DL,0FH
CMP DL,0AH
JC D2
ADD DL,07H
D2: ADD DL,30H
MOV AH,06H
INT 21H
INC SI
BSPCE ' '
DEC BH
JNZ LOP
DEC DH
JZ D3
BSPCE 0AH
BSPCE 0DH
JMP D4
D3: RET
DISP ENDP
CODE ENDS
END START
OUTPUT :
ENTER THE ORDER OF THE MATRIX : 2 3
ENTER THE ELEMENTS OF THE MATRIX:
11 55 99
22 74 51
TRANSPOSE MATRIX :
11 22
55 74
99 51
24.GENERATION OF PRIME NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'PRIME NUMBERS UPTO LIMIT :''$'
MESS3 DB 0AH,0DH,'NO OF ELEMENTS IN PRIME SERIES= ''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR SI,SI
MOV DH,00H
L1: INC DH
JZ L3
CMP DH,CH
JA L3
CALL SQRT
MOV BH,01H
L2:MOV AL,DH
MOV AH,00H
INC BH
CMP BH,DL
JA L4
DIV BH
CMP AH,00H
JNZ L2
JMP L1
L4:MOV BL,DH
CALL DISP
MOV DL,','
MOV AH,06H
INT 21H
INC SI
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2: OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC N2
ADD BL,07H
N2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC DISP
MOV DL,00H
T1:INC DL
MOV AL,DH
MOV AH,00H
DIV DL
CMP DL,AL
JC T1
JZ T2
DEC DL
T2:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 0F
PRIME NUMBERS UPTO LIMIT : 01,02,03,05,07,0B,0D
NO. OF ELEMENTS IN PRIME SERIES : 07
25. GENERATION OF PRIME NUMBERS (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'PRIME NUMBERS UPTO LIMIT :''$'
MESS3 DB 0AH,0DH,'NO OF ELEMENTS IN PRIME SERIES= ''$'
NUM DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV DH,00H
MOV SI,0000H
L1:MOV AL,DH
ADD AL,01H
DAA
JC L3
MOV DH,AL
CMP DH,CH
JA L3
CALL SQRT
MOV BH,01H
L2:MOV AL,BH
ADD AL,01H
DAA
MOV BH,AL
CMP BH,DL
JA L4
MOV AH,00H
MOV NUM,DH
L5:MOV AL,NUM
SUB AL,BH
DAS
MOV NUM,AL
MOV AL,AH
ADD AL,01H
DAA
MOV AH,AL
CMP NUM,BH
JAE L5
CMP NUM,00H
JZ L1
JMP L2
L4: MOV BL,DH
CALL DISP
MOV DL,'.'
MOV AH,06H
INT 21H
MOV AX,SI
ADD AL,01H
DAA
MOV SI,AX
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC DISP
MOV DL,00H
T1:INC DL
MOV BL,00H
MOV CL,DH
T2:MOV AL,CL
SUB AL,DL
DAS
MOV CL,AL
INC BL
CMP CL,DL
JAE T2
CMP DL,BL
JC T1
JE T3
DEC DL
T3:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 09
PRIME NUMBERS UPTO LIMIT : 01,02,03,05,07
NO. OF ELEMENTS IN PRIME SERIES : 05
26.GENERATION OF PERFECT DIVIDING NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 'ENTER THE LIMIT :','$'
MESS2 DB 0AH,0DH,'PERFECT DIVISORS:','$'
MESS3 DB 0AH,0DH,'NUMBER OF PERFECT DIVISORS UPTO THE LIMIT=','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR SI,SI
MOV DH,01H
L1: INC DH
JZ L3
CMP DH,CH
JA L3
CALL SQRT
MOV BL,01H
MOV BH,01H
L2: INC BH
CMP BH,DL
JA L4
MOV AH,00H
MOV AL,DH
DIV BH
CMP AH,00H
JNE L2
ADD AL,BH
ADD BL,AL
JMP L2
L4: CMP BL,DH
JNE L1
CALL DISP
MOV DL,' '
MOV AH,06H
INT 21H
INC SI
JMP L1
L3:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV BX,SI
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC N1
ADD DL,07H
N1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC N2
ADD BL,07H
N2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
SQRT PROC NEAR
PUBLIC SQRT
MOV DL,00H
T1:INC DL
MOV AL,DH
MOV AH,00H
DIV DL
CMP DL,AL
JC T1
JZ T2
DEC DL
T2:RET
SQRT ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : FF
PERFECT DIVISORS ARE: 06 1C
NO. OF ELEMENTS : 02
27.GENERATION OF PERFECT DIVIDING NUMBERS(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 'ENTER THE LIMIT :','$'
MESS2 DB 0AH,0DH,'PERFECT DIVISORS :','$'
MESS3 DB 0AH,0DH,'NUMBER OF PERFECT DIVISORS UPTO THE LIMIT=','$'
LIM DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
LEA DX,MESS2
MOV AH,09H
INT 21H
XOR DI,DI
CALL PERFECT
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CX,DI
MOV BL,CL
CALL DISP
MOV AH,4CH
INT 21H
PERFECT PROC NEAR
PUBLIC PERFECT
MOV BL,01H
P1:CMP BH,BL
JA P3
RET
P3: CALL SQRT
MOV DL,01H
MOV CH,CL
MOV CL,02H
P4: CMP CH,CL
JC P5
MOV AH,BL
XOR DH,DH
CALL DIVD
CMP AH,00H
JNZ P7
MOV AL,DL
ADD AL,DH
DAA
ADD AL,CL
DAA
MOV DL,AL
P7: MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
JMP P4
P5: CMP DL,01H
JE P6
CMP BL,DL
JNE P6
CALL DISP
MOV AX,DI
ADD AL,01H
DAA
MOV DI,AX
P6: MOV AL,BL
ADD AL,01H
DAA
MOV BL,AL
JMP P1
PERFECT ENDP
SQRT PROC NEAR
PUBLIC SQRT
MOV CL,01H
B3: XOR DH,DH
MOV AH,BL
MOV AL,CL
ADD AL,01H
DAA
MOV CL,AL
CALL DIVD
CMP DH,CL
JAE B3
MOV AL,CL
SUB AL,01H
DAS
MOV CL,AL
RET
SQRT ENDP
DIVD PROC NEAR
PUBLIC DIVD
B1: CMP AH,CL
JB B2
MOV AL,AH
SUB AL,CL
DAS
MOV AH,AL
MOV AL,DH
ADD AL,01H
DAA
MOV DH,AL
JMP B1
B2:RET
DIVD ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV BH,AL
SUB BH,30H
MOV CL,04H
SHL BH,CL
MOV AH,01H
INT 21H
SUB AL,30H
OR BH,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV AH,BL
MOV DL,AH
MOV CL,04H
SHR AH,CL
ADD AH,30H
MOV DL,AH
MOV AH,06H
INT 21H
MOV AH,BL
AND AH,0FH
ADD AH,30H
MOV DL,AH
MOV AH,06H
INT 21H
MOV DL,' '
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 99
PERFECT DIVISORS ARE: 06 28
NO. OF ELEMENTS : 02
ENTER LIMIT : 20
PERFECT DIVISORS ARE: 06
NO. OF ELEMENTS : 01
27.GENERATION OF FIBONACCI SERIES (HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,0DH,'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
ADD TEMP,BH
JC NEXT
MOV BL,TEMP
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT: AA
FIBONACCI SERIES UPTO THE LIMIT AA IS : 00 01 01 02 03 05 08 0D 15 22 37 59 90
NUMBERS OF ELEMENTS IN FIBONACCI SERIES : 13
28.GENERATION OF FIBONACCI SERIES (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,ODH'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH,09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
ADD TEMP,BH
JC NEXT
MOV BL,TEMP
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
MOV DL,AL
MOV CL,04H
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2: ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : FF
PERFECT DIVISORS ARE: 06 1C
NO. OF ELEMENTS IN PRIME SERIES : 02
ENTER THE LIMIT: 08
THE FIBONACCI SERIES UPTO THE LIMIT 09 IS: 00,01,01,02,03,05,08
NUMBERS OF ELEMENTS IN THE FIBONACCI SERIES:07
29.GENERATION OF FIBONACCI SERIES (BCD)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE LIMIT:''$'
MESS2 DB 0AH,0DH,'FIBONACCI SERIES UPTO THE LIMIT ','$'
MESS3 DB 0AH,0DH,'THE NUMBER OF ELEMENTS IN FIBONACCI SERIES IS: ','$'
MESS4 DB 'IS: ','$'
TEMP DB 01H
COUNT DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,CH
CALL DISP
LEA DX,MESS4
MOV AH, 09H
INT 21H
XOR BX,BX
AGAIN: INC COUNT
CALL DISP
MOV AL,TEMP
ADD AL,BH
DAA
JC NEXT
MOV BL,AL
MOV TEMP,BH
MOV BH,BL
CMP BL,CH
JA NEXT
JMP AGAIN
NEXT:LEA DX,MESS3
MOV AH,09H
INT 21H
MOV AL,COUNT
ADD AL,00H
DAA
MOV BL,AL
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV AH,01H
INT 21H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV DL,' '
MOV AH,06H
INT 21H
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT: 99
FIBONACCI SERIES UPTO THE LIMIT 99 IS : 00 01 01 02 03 05 08 13 21 34 55 89
NUMBER OF ELEMENTS IN THE FIBONACCI SERIES :12
30.FACTORIAL OF A NUMBER USING RECURSION TECHNIQUE
DATA SEGMENT
MESS1 DB 'ENTER THE NUMBER(0-8):''$'
MESS2 DB 0AH,0DH, ' FACTORIAL OF THE GIVEN NUMBER=''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV AX,0001H
MOV BH,00H
CALL FACT
MOV BX,AX
CALL DISP
MOV AH,4CH
INT 21H
FACT PROC NEAR
PUBLIC FACT
CMP BX,0001H
JBE NEXT
MUL BX
DEC BX
CALL FACT
NEXT:RET
FACT ENDP
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CL,04H
MOV CH,02H
BACK:MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L3
MOV BH,BL
JMP BACK
L3:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NO<0-8> : 7
FACTORIAL OF THE GIVEN NUMBER : 13B0
ENTER THE NO<0-8> : 5
FACTORIAL OF THE GIVEN NUMBER : 0078
31. CONVERSION FROM BINARY TO GRAY ( HEXADECIMAL )
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER BINARY CODE :''$'
MESS2 DB 0AH,0DH,'EQUIVALENT GRAY CODE :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
SHR DL,01H
XOR BL,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER BINARY CODE: 10
EQUIVALENT GRAY CODE: 18
ENTER BINARY CODE: 80
EQUIVALENT GRAY CODE: C0
ENTER BINARY CODE: F0
EQUIVALENT GRAY CODE: 88
32.CONVERSION FROM GRAY CODE TO BINARY CODE(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER GRAY CODE :''$'
MESS2 DB 0AH,0DH,'EQUIVALENT BINARY CODE :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV CH,07H
M1:SHR DL,01H
XOR BL,DL
DEC CH
JNZ M1
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER GRAY CODE: ‘21
EQUIVALENT BINARY CODE: ‘3E
ENTER GRAY CODE: 80
EQUIVALENT BINARY CODE: FF
33.CONVERSION OF ARRAY OF BINARY CODE TO GRAY CODE
(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'BINARY CODE GRAY CODE :''$'
NL DB 0AH,0DH,' ','$'
BSP DB' ','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
M1:LEA DX,NL
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
SHR DL,01H
XOR BL,DL
LEA DX,BSP
MOV AH,09H
INT 21H
CALL DISP
DEC BH
JNZ M1
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
BINARY CODE GRAY CODE
3E 21
21 31
16 1D
10 18
02 03
34. CONVERSION OF ARRAY OF GRAYCODE TO BINARY CODE
(HEXADECIMAL)
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'GRAY CODE BINARY CODE :''$'
NL DB 0AH,0DH,' ','$'
BSP DB' ','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
M2:LEA DX,NL
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
MOV CH,07H
M1: SHR DL,01H
XOR BL,DL
DEC CH
JNZ M1
LEA DX,BSP
MOV AH,09H
INT 21H
CALL DISP
DEC BH
JNZ M2
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER LIMIT : 05
GRAY BINARY
03 02
14 18
21 3E
C2 83
A5 C6
35.GCD OF TWO 8-BIT HEXADECIMAL NUMBERS.
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'GCD OF TWO NUMBER IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
T1:MOV AL,BH
MOV AH,00H
DIV BL
MOV BH,BL
MOV BL,AH
CMP AH,00H
JNE T1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : 0A
ENTER SECOND NUMBER : 05
GCD OF TWO NUMBER IS : 05
ENTER FIRST NUMBER : 0C
ENTER SECOND NUMBER : 06
GCD OF TWO NUMBER IS : 06
36.GCD OF TWO 8-BIT NUMBERS(BCD).
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER FIRST NUMBER :''$'
MESS2 DB 0AH,0DH,'ENTER SECOND NUMBER :''$'
MESS3 DB 0AH,0DH,'GCD OF TWO NUMBER IS :''$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
CALL READ
MOV BL,DL
N1:CMP BH,BL
JZ N3
JNB N2
MOV AL,BL
SUB AL,BH
DAS
MOV BL,AL
JMP N1
N2:MOV AL,BH
SUB AL,BL
DAS
MOV BH,AL
JMP N1
N3:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BH
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER FIRST NUMBER : ‘08
ENTER SECOND NUMBER : ‘12
GCD OF TWO NUMBER IS : ‘04
ENTER FIRST NUMBER : ‘09
ENTER SECOND NUMBER : ‘06
GCD OF TWO NUMBER IS : ‘03
37.REVERSE OF A BYTE
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE NUMBER :','$'
MESS2 DB 0AH,0DH,'REVERSE OF A GIVEN BYTE :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BL,00H
MOV CH,08H
N1: SHL DL,01H
RCR BL,01H
DEC CH
JNZ N1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV DL,' '
MOV AH,06H
INT 21H
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CL,04H
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC L2
ADD BL,07H
L2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NUMBER : 12
REVERSE OF GIVEN BYTE: 48
ENTER THE NUMBER:F8
REVERSE OF GIVEN BYTE:1F
38.REVERSAL OF WORD
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER THE NUMBER :','$'
MESS2 DB 0AH,0DH,'REVERSE OF A GIVEN NUMBER :','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
MOV BX,0000H
MOV CH,10H
N1: SHL DX,01H
RCR BX,01H
DEC CH
JNZ N1
CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CH,02H
R3:MOV AH,01H
INT 21H
MOV CL,04H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
R2: AND AL,0FH
OR DL,AL
DEC CH
JZ R4
MOV DH,DL
JMP R3
R4: RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV CH,02H
L3:MOV CL,04H
MOV DL,BH
SHR DL,CL
CMP DL,0AH
JC L1
ADD DL,07H
L1: ADD DL,30H
MOV AH,06H
INT 21H
AND BH,0FH
CMP BH,0AH
JC L2
ADD BH,07H
L2:ADD BH,30H
MOV DL,BH
MOV AH,06H
INT 21H
DEC CH
JZ L4
MOV BH,BL
JMP L3
L4:RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
ENTER THE NUMBER: F4C9
REVERSE OF THE GIVEN WORD:932F
ENTER THE NUMBER: B27A
REVERSE OF THE GIVEN WORD:5E4D
39.REVERSAL OF AN ARRAY
DATA SEGMENT
MESS1 DB 0AH,0DH,'ENTER LIMIT :''$'
MESS2 DB 0AH,0DH,'ENTER THE ARRAY ELEMENTS :''$'
MESS3 DB 0AH,0DH,'REVERSE OF THE STRING :''$'
NUM DB 10 DUP (0)
RNUM DB 10 DUP (0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV CH,DL
LEA DX,MESS2
MOV AH,09H
INT 21H
MOV DH,CH
LEA BX,NUM
L1:CALL READ
MOV [BX],DL
INC BX
DEC DH
JNZ L1
LEA SI,RNUM
LEA BX,NUM
MOV DL,CH
MOV DH,00H
ADD BX,DX
MOV DH,CH
L2:DEC BX
MOV DL,[BX]
MOV [SI],DL
DEC DH
JZ NEXT
INC SI
JMP L2
NEXT:CALL DISP
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV CL,04H
MOV DL,','
MOV AH,06H
INT 21H
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,0AH
JC R1
SUB DL,07H
R1:SHL DL,CL
MOV AH,01H
INT 21H
SUB AL,30H
CMP AL,0AH
JC R2
SUB AL,07H
AND AL,0FH
R2: OR DL,AL
RET
READ ENDP
DISP PROC NEAR
PUBLIC DISP
LEA DX,MESS3
MOV AH,09H
INT 21H
LEA SI,RNUM
MOV CL,04H
M3:MOV DL,','
MOV AH,06H
INT 21H
MOV bL,[SI]
MOV DL,BL
SHR DL,CL
CMP DL,0AH
JC M1
ADD DL,07H
M1:ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
CMP BL,0AH
JC M2
ADD BL,07H
M2:ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
DEC CH
JZ M4
INC SI
JMP M3
M4: RET
DISP ENDP
CODE ENDS
END START
OUTPUT
ENTER THE LIMIT OF AN ARRAY:05
ENTER THE ARRAY ELEMENTS:12,4C,DB,D5
REVERSE OF THE GIVEN ARRAY:D5,DB,4C,12
40.TO DISPLAY CURRENT TIME.
DATA SEGMENT
MESS1 DB 0AH,0DH,'TIME IS:'0AH,0DH,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
L1:MOV AH,2CH
INT 21H
MOV AL,CH
CALL CONV
CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV AL,CL
CALL CONV
CALL DISP
MOV DL,':'
MOV AH,06H
INT 21H
MOV DL,0DH
MOV AH,06H
INT 21H
JMP L1
MOV AH,4CH
INT 21H
DISP PROC NEAR
PUBLIC DISP
MOV BL,AH
MOV DL,AL
ADD DL,30H
MOV AH,06H
INT 21H
MOV DL,BL
ADD DL,30H
MOV AH,06H
INT 21H
RET
DISP ENDP
CONV PROC NEAR
PUBLIC CONV
MOV AH,00H
MOV BH,0AH
DIV BH
RET
CONV ENDP
CODE ENDS
END START
OUTPUT:
THE CURRENT TIME IS: 23:37:23.85
41.TO DISPLAY CURRENT DATE.
DATA SEGMENT
MESS1 DB 0AH,0DH,'THE CURRENT DATE IS:'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV AH,2AH
INT 21H
MOV SI,CX
MOV BL,DH
MOV BH,DL
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
MOV BL,BH
CALL DISP
MOV DL,'-'
MOV AH,06H
INT 21H
XOR DX,DX
MOV AX,SI
MOV CX,0064H
DIV CX
MOV DH,DL
MOV BL,AL
CALL DISP
MOV BL,DH
MOV AH,4CH
INT 21H
CONV PROC NEAR
PUBLIC CONV
MOV CL,04H
XOR AH,AH
MOV AL,BL
MOV BL,0AH
DIV BL
SHL AL,CL
ADD AL,AH
DAA
MOV BL,AL
RET
CONV ENDP
DISP PROC NEAR
PUBLIC DISP
MOV CL,04H
CALL CONV
MOV DL,BL
SHR DL,CL
ADD DL,30H
MOV AH,06H
INT 21H
AND BL,0FH
ADD BL,30H
MOV DL,BL
MOV AH,06H
INT 21H
RET
DISP ENDP
CODE ENDS
END START
OUTPUT:
THE CURRENT DATE IS: MON 07/11/2011
INTERFACING PROGRAMS
1.SEVEN SEGMENT DISPLAY
CONFIGURATION
PORT A OUTPUT
PORT B OUTPUT
PORT C LOW OUTPUT
PORT C UP OUTPUT
ADDRESSES
PORTA EQU 0D800H
PORTB EQU 0D801H
PORTC EQU 0D802H
CONTROL WORD
For 8255, Port A and B are used as output ports. The control word format of 8255 according to hardware connections is:
1.SEVEN SEGMENT DISPLAY
DATA SEGMENT
MESS1 DB 'ENTER A 4-DIGIT NUMBER: ','$'
SEVSEG DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
NUMAR DB 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
MOV DX,0D883H
MOV AL,80H
OUT DX,AL
LEA SI,NUMAR
CALL READ
L2:LEA SI,NUMAR
MOV CH,03H
L1:MOV DX,0D882H
MOV AL,CH
OUT DX,AL
MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
CALL DELAY
INC SI
SUB CH,01H
JNC L1
JMP L2
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
LEA BX,SEVSEG
MOV CL,04H
R2:MOV AH,01H
INT 21H
SUB AL,30H
XLAT
MOV [SI],AL
INC SI
DEC CL
JNZ R2
RET
READ ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV DI,00FFH
D2:MOV BP,0FFFH
D1:DEC BP
JNZ D1
DEC DI
JNZ D2
RET
DELAY ENDP
CODE ENDS
END START
2.GENERATE VARIABLE SQUARE WAVE GENERATOR USING 8253
CONFIGURATION
BINARY COUNTER,
MODE 3, R/W LSB FIRST THEN MSB
COUNTER 0
ADDRESSES
COUNTER 0---À 0D888
COUNTER 1---À 0D889
COUNTER 2---À 0D88A
CONTROL REGISTER ---À 0D88B
CONTROL WORD IS 36H
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RW1 RW0 M2 M1 M0 BCD
0 0 1 1 0 1 1 0
3 6
PROGRAM
DATA SEGMENT
MESS DB 'ENTER THE FREQUENCY IN KHZ (01-65KHZ):','$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
LEA DX, MESS
MOV AH, 09H
INT 21H
CALL READ
XOR AH, AH
MOV BX, 03E8H
MUL BX
MOV BX, AX
MOV DX, 001FH
MOV AX, 3E0CH
DIV BX
MOV BX, AX
MOV AL, 36H
MOV DX, 0D88BH
OUT DX, AL
MOV DX, 0D888H
MOV AL, BL
OUT DX, AL
MOV AL, BH
OUT DX, AL
MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH, 01H
INT 21H
MOV DH, AL
SUB DH, 30H
MOV AH, 01H
INT 21H
MOV DL, AL
SUB DL, 30H
MOV AL, DH
MOV DH, 0AH
MUL DH
ADD AL, DL
RET
READ ENDP
CODE ENDS
END START
3.GENERATE SQUARE WAVE,SINE ,SAW,TRIANGULAR,STAIRCASE WAVEFORM USING DAC INTERFACE
CONFIGURATION:
PORT A ----> OUTPUT, ADDRESS IS 0D880
PORT B ----> OUTPUT ADDRESS IS 0D881
PORT C LOW ---> OUTPUT ADDRESS IS D882
PORT C HIGH--> OUPTUT ADDRESS IS 0D882
CONTROL PORT ADDRESS IS 0D883S
CONTROL WORD IS 80
D7 D6 D5 D4 D3 D2 D1 D0
BSR or
I/O MODE MODE FOR PORTA PORT A PORT C
(UPPER) MODE FOR PORTA MODE FOR PORTB PORT B PORT C
(LOWER)
1 0 0 0 0 0 0 0
8 0
PROGRAM :
DATA SEGMENT
MESS1 DB 0AH,0DH,' *****************************',0AH,0DH
DB ' 1) SQUARE WAVE',0AH,0DH
DB ' 2) TRIANGULAR WAVE', 0AH,0DH
DB ' 3) STAIRCASE WAVE',0AH,0DH
DB ' 4) SAWTOOTH WAVE',0AH,0DH
DB ' 5) SINE WAVE',0AH,0DH
DB ' ******************************************'
DB 0AH,0DH, ' ENTER THE CHOICE :','$'
MESS2 DB 0AH,0DH,'INVALID CHOICE','$'
SINTT DB 00H,00H,00H,00H,01H,02H,03H,04H,05H,06H,08H,09H,0BH,0DH,0FH
DB 11H,13H,16H,18H,1BH,1EH,21H,24H,27H,2AH,2EH,31H,34H,38H,3CH
DB 40H,44H,47H,4BH,50H,54H,58H,5CH,61H,65H,69H,6EH,72H,77H,7BH
DB 7FH,81H,88H,8DH,91H,96H,9AH,9EH,0A3H,0A7H,0ABH,0AFH,0B3H,0B7H
DB 0BBH,0BFH,0C3H,0C7H,0CAH,0CEH,0D1H,0D4H,0D8H,0DBH,0DEH,0E1H
DB 0E4H,0E7H,0E9H,0EBH,0EEH,0F2H,0F4H,0F6H,0F7H,0F9H,0FAH
DB 0FBH,0FCH,0FDH,0FEH,0FFH,0FFH,0FFH
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AL,80H
MOV DX,0D883H
OUT DX,AL
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
CMP DL,01H
JNE L1
CALL SQWAVE
JMP L6
L1: CMP DL,02H
JNE L2
CALL TRWAVE
JMP L6
L2:CMP DL,3H; SHOULD BE CMP DL,03 NOT CALL DL,30H
JNE L3
CALL STCASE
JMP L6
L3:CMP DL,04H
JNE L4
CALL SAWT
JMP L6
L4:CMP DL,05H
JNE L5
CALL SINWAVE
JMP L6
L5:LEA DX,MESS2
MOV AH,09H
INT 21H
L6: MOV AH,4CH
INT 21H
READ PROC NEAR
PUBLIC READ
MOV AH,01H
INT 21H
MOV DL,AL
SUB DL,30H
RET
READ ENDP
SQWAVE PROC NEAR
PUBLIC SQWAVE
LOOP1: MOV AL,00H
MOV DX,0D880H
OUT DX,AL
CALL DELAYS
MOV AL,0FFH
MOV DX,0D880H
OUT DX,AL
CALL DELAYS
JMP LOOP1
RET
SQWAVE ENDP
TRWAVE PROC NEAR
PUBLIC TRWAVE
T3: MOV CL,00H
MOV BL,0FFH
T1:MOV AL,CL
MOV DX,0D880H
OUT DX,AL
INC CL
CMP CL,BL
JC T1
T2:MOV AL,CL
MOV DX,0D880H
OUT DX,AL
DEC CL
JNZ T2
JMP T3
RET
TRWAVE ENDP
STCASE PROC NEAR
PUBLIC STCASE
MOV AL,00H
S2: MOV DX,0D880H
OUT DX,AL
CALL DELAYS
ADD AL,40H
JMP S2
RET
STCASE ENDP
SAWT PROC NEAR
PUBLIC SAWT
N2: MOV AL,00H
MOV BL,02H
N1:;MOV AL,CL
MOV DX,0D880H
OUT DX,AL
CALL DELAY
INC AL
CMP CL,BL
JNC N1
JMP N1
RET
SAWT ENDP
SINWAVE PROC NEAR
PUBLIC SINWAVE
P3:LEA SI,SINTT
P1:MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
INC SI
CMP AL,0FFH
JNZ P1
P2:MOV AL,[SI]
MOV DX,0D880H
OUT DX,AL
DEC SI
CMP AL,00H
JNZ P2
JMP P3
RET
SINWAVE ENDP
DELAYS PROC NEAR
PUBLIC DELAYS
MOV DI,0004H
G2:MOV BP,0FFFFH
G1:DEC BP
JNZ G1
DEC DI
JNZ G2
RET
DELAYS ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV BP,0FFFFH
D1:DEC BP
JNZ D1
RET
DELAY ENDP
CODE ENDS
END START
END
4.TO TEST ALL THE GATES OF A GIVEN IC 74XX IS GOOD OR BAD
CONFIGURATION:
PORT A ----> OUTPUT, ADDRESS IS 0D880
PORT B ----> OUTPUT ADDRESS IS 0D881
PORT C LOW ---> OUTPUT ADDRESS IS D882
PORT C HIGH--> OUPTUT ADDRESS IS 0D882
CONTROL PORT ADDRESS IS 0D883
CONTROL WORD IS 80
D7 D6 D5 D4 D3 D2 D1 D0
BSR or
I/O MODE MODE FOR PORTA PORT A PORT C
(UPPER) MODE FOR PORTA MODE FOR PORTB PORT B PORT C
(LOWER)
1 0 0 0 0 0 1 0
8 2
DATA SEGMENT
NANDTT DB 0FH,0FH,0FH,00H
ANDTT DB 00H,00H,00H,0FH
ORTT DB 00H,0FH,0FH,0FH
XORTT DB 00H,0FH,0FH,00H
MESS1 DB 0AH,0DH,'ENTER THE IC NUMBER (7400/7408/7432/7486):','$'
MESS2 DB 0AH,0DH,'IC IS GOOD.','$'
MESS3 DB 0AH,0DH,'IC IS BAD.','$'
MESS4 DB 0AH,0DH,'IC IS NOT MATCHING.','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA DX,MESS1
MOV AH,09H
INT 21H
CALL READ
MOV BX,DX
CMP BX,7400H
JNE G1
LEA BX,NANDTT
CALL TEST1
JMP AHEAD
G1: CMP BX,7408H
JNE G2
LEA BX,ANDTT
CALL TEST1
JMP AHEAD
G2:CMP BX,7432H
JNE G3
LEA BX,ORTT
CALL TEST1
JMP AHEAD
G3: CMP BX,7486H
JNE G4
LEA BX,XORTT
CALL TEST1
JMP AHEAD
G4: LEA DX,MESS4
MOV AH,09H
INT 21H
AHEAD: MOV AH,4CH
INT 21H
TEST1 PROC NEAR
PUBLIC TEST1
MOV DX,0D883H
MOV AL,82H
OUT DX,AL
MOV CL,04H
MOV CH,00H
T1:MOV AL,CH
MOV DX,0D880H
OUT DX,AL
PUSH CX
MOV CX,0002H
BACKRP: CALL DELAY
DEC CX
JNZ BACKRP
POP CX
MOV DX,0D881H
IN AL,DX
AND AL,0FH
CMP AL,[BX]
JNE T2
ADD CH,55H
INC BX
DEC CL
JNZ T1
LEA DX,MESS2
MOV AH,09H
INT 21H
JMP T3
T2: LEA DX,MESS3
MOV AH,09H
INT 21H
T3:RET
TEST1 ENDP
READ PROC NEAR
PUBLIC READ
MOV CH,02H
AGAIN : MOV CL,04H
MOV AH,01H
INT 21H
SHL AL,CL
MOV DL,AL
MOV AH,01H
INT 21H
AND AL,0FH
OR DL,AL
DEC CH
JZ NXT
MOV DH,DL
JMP AGAIN
NXT:RET
READ ENDP
DELAY PROC NEAR
PUBLIC DELAY
MOV BP,0FFFFH
D1: DEC BP
JNZ D1
RET
DELAY ENDP
CODE ENDS
END START
Subscribe to:
Posts (Atom)