Microprocessor 8086 Assembly-occurance of space in a string

Microprocessor 8086 Assembly-occurance of space in a string

.MODEL SMALL
.DATA
MSG1 DB "ENTER THE STRING: $"
MSG2 DB "THE OCCURENCE OF SPACE: $"
STRING DB 50 DUP('$')
COUNT DB 0
.CODE
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
LEA SI,STRING
LOOP1:
MOV AH,01H
INT 21H
MOV BL,AL
MOV [SI],BL
CMP BL,0DH
JZ DOWN1
INC SI
JMP LOOP1
DOWN1:
LEA SI,STRING
LEA DX,MSG2
MOV AH,09H
INT 21H
LOOP2:
MOV BL,[SI]
CMP BL,0DH
JZ DOWN3
CMP BL,' '
JZ LOOP3
INC SI
JMP LOOP2
LOOP3:
INC COUNT
INC SI
JMP LOOP2
DOWN3:
ADD COUNT,30H
MOV AH,02H
MOV DL,COUNT
INT 21H
MOV AH,4CH
INT 21H
END

Output
ENTER THE STRING: Anandhu Arjunan
THE OCCURENCE OF SPACE: 1

Comments

Popular posts from this blog

Introduction to C++ Programming Language

The Assembly Process Of 8086 Microprocessor-Two Pass Assembling Steps

Installing 8086 Assembler on a Computer