Write a program in assembly language for finding the largest number in an array of 10 elements – IGNOU MCA Assignment 2016 – 17

By | October 7, 2016

MASTER OF COMPUTER APPLICATIONS

Course Code : MCSL-017
Course Title : C and Assembly Language Programming (Lab Course)
Assignment Number : MCA(1)/L-017/Assignment/16-17
Maximum Marks : 50
Weightage : 25%

 

Write a program in assembly language for finding the largest number in an array of 10 elements - IGNOU MCA Assignment 2016 – 17

Code:-

DATA SEGMENT
ARR DB 1,4,2,3,9,8,6,7,5,10
LEN DW $-ARR
LARGE DB ?
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX

LEA SI,ARR

MOV AL,ARR[SI]
MOV LARGE,AL

MOV CX,LEN
REPEAT:
MOV AL,ARR[SI]
CMP LARGE,AL
JG NOCHANGE

MOV LARGE,AL
NOCHANGE:
INC SI
LOOP REPEAT

MOV AH,4CH
INT 21H
CODE ENDS
END START

DATA SEGMENT
ARR DB 1,4,2,3,9,8,6,7,5,10
LEN DW $-ARR
LARGE DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARR
MOV AL,ARR[SI]
MOV LARGE,AL
MOV CX,LEN
REPEAT:
MOV AL,ARR[SI]
CMP LARGE,AL
JG NOCHANGE
MOV LARGE,AL
NOCHANGE:
INC SI
LOOP REPEAT
MOV AH,4CH
INT 21H
CODE ENDS
END START

 

Screen Shots :-

Asm_program_Largest_in_Array

Output Before Execution :-

Asm_program_Largest_in_Array_Output1

Output After Execution :-

Asm_program_Largest_in_Array_Output2

Note :- To see the variable and its value you have to click vars button in the emulator.