Write a program in 8086 assembly Language to count the number of alphabets ‘a’, ‘e’ and ‘o’ (irrespective of lower or upper case) in a strings – IGNOU MCA Assignment 2015 – 16

By | August 16, 2015

 MASTER OF COMPUTER APPLICATIONS

Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(1)/012/Assign/2015-16
Maximum Marks : 100
Weightage : 25%

 

Write a program in 8086 assembly Language (with proper comments) to count the number of alphabets ‘a’, ‘e’ and ‘o’ (irrespective of lower or upper case) in a strings. For example, in case the strings is: “ABaDEFeHIO” the count of ‘a’ will be 2, ‘e’ is 2 and ‘o’ is 1. You may assume that string is available in the memory and is of length 10. Make suitable assumptions, if any.

 

DATA SEGMENT
STR1 DB “ABaDEFeHIO”
A DB 0H
E DB 0H
O DB 0H
MSG1 DB 10,13,”COUNT OF A’s IS : $”
MSG2 DB 10,13,”COUNT OF E’s IS : $”
MSG3 DB 10,13,”COUNT OF O’s IS : $”
DATA ENDS

DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM

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

LEA SI,STR1

MOV CX,10
CHECK:
MOV AL,[SI]
CMP AL,’A’
JNE N1
INC A
N1:
CMP AL,’a’
JNE N2
INC A

N2: CMP AL,’E’
JNE N3
INC E

N3: CMP AL,’e’
JNE N4
INC E

N4: CMP AL,’O’
JNE N5
INC O

N5: CMP AL,’o’
JNE N6
INC O

N6: INC SI
LOOP CHECK

DISPLAY MSG1

MOV DL,A
ADD DL,30H
MOV AH,2
INT 21H

DISPLAY MSG2

MOV DL,E
ADD DL,30H
MOV AH,2
INT 21H

DISPLAY MSG3

MOV DL,O
ADD DL,30H
MOV AH,2
INT 21H

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

Program Code :

  1. DATA SEGMENT
  2. STR1 DB "ABaDEFeHIO"
  3. A DB 0H
  4. E DB 0H
  5. O DB 0H
  6. MSG1 DB 10,13,"COUNT OF A's IS : $"
  7. MSG2 DB 10,13,"COUNT OF E's IS : $"
  8. MSG3 DB 10,13,"COUNT OF O's IS : $"
  9. DATA ENDS
  10. DISPLAY MACRO MSG
  11. MOV AH,9
  12. LEA DX,MSG
  13. INT 21H
  14. ENDM
  15. CODE SEGMENT
  16. ASSUME CS:CODE,DS:DATA
  17. START:
  18. MOV AX,DATA
  19. MOV DS,AX
  20. LEA SI,STR1
  21. MOV CX,10
  22. CHECK:
  23. MOV AL,[SI]
  24. CMP AL,'A'
  25. JNE N1
  26. INC A
  27. N1:
  28. CMP AL,'a'
  29. JNE N2
  30. INC A
  31. N2: CMP AL,'E'
  32. JNE N3
  33. INC E
  34. N3: CMP AL,'e'
  35. JNE N4
  36. INC E
  37. N4: CMP AL,'O'
  38. JNE N5
  39. INC O
  40. N5: CMP AL,'o'
  41. JNE N6
  42. INC O
  43. N6: INC SI
  44. LOOP CHECK
  45. DISPLAY MSG1
  46. MOV DL,A
  47. ADD DL,30H
  48. MOV AH,2
  49. INT 21H
  50. DISPLAY MSG2
  51. MOV DL,E
  52. ADD DL,30H
  53. MOV AH,2
  54. INT 21H
  55. DISPLAY MSG3
  56. MOV DL,O
  57. ADD DL,30H
  58. MOV AH,2
  59. INT 21H
  60. MOV AH,4CH
  61. INT 21H
  62. CODE ENDS
  63. END START

Screen shots :-

Asm_program_Count_aeo_in_String

After Execution :

 Asm_program_Count_aeo_in_String_Output