An Assembly Language program to find minimal and maximal elements – IGNOU MCA Assignment 2014 – 15

By | July 18, 2014

 MASTER OF COMPUTER APPLICATIONS
Course Code : MCSL-017
Course Title : C and Assembly Language Programming
Assignment Number : MCA(1)/L017/Assign/2014-15
Maximum Marks : 100
Weightage : 25%

 

Develop and execute an assembly language program to read an array of numbers and find the minimal and maximal elements. 

 

DATA SEGMENT
ARR DB 5,3,7,1,9,2,6,8,4
LEN DW $-ARR
MIN DB ?
MAX 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 MIN,AL
MOV MAX,AL

MOV CX,LEN
REPEAT:
MOV AL,ARR[SI]
CMP MIN,AL
JL CHECKMAX

MOV MIN,AL
CHECKMAX:
CMP MAX,AL
JG DONE

MOV MAX,AL
DONE:
INC SI
LOOP REPEAT

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

Program Code :

  1. DATA SEGMENT
  2. ARR DB 5,3,7,1,9,2,6,8,4
  3. LEN DW $-ARR
  4. MIN DB ?
  5. MAX DB ?
  6. DATA ENDS
  7. CODE SEGMENT
  8. ASSUME DS:DATA CS:CODE
  9. START:
  10. MOV AX,DATA
  11. MOV DS,AX
  12. LEA SI,ARR
  13. MOV AL,ARR[SI]
  14. MOV MIN,AL
  15. MOV MAX,AL
  16. MOV CX,LEN
  17. REPEAT:
  18. MOV AL,ARR[SI]
  19. CMP MIN,AL
  20. JL CHECKMAX
  21. MOV MIN,AL
  22. CHECKMAX:
  23. CMP MAX,AL
  24. JG DONE
  25. MOV MAX,AL
  26. DONE:
  27. INC SI
  28. LOOP REPEAT
  29. MOV AH,4CH
  30. INT 21H
  31. CODE ENDS
  32. END START

Screen shots :-

Asm_program_Min_Max_Array

Before Execution :-

Asm_program_Min_Max_Array_V1

After Execution :-

Asm_program_Min_Max_Array_V2

 

Leave a Reply