Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Program to check whether the characters in a string are in ascending order or not

Posted By: Matilda Hughes     Category: Assembly Language     Views: 11230

A Program to check whether the characters in a string are in ascending order or not.

Code for Program to check whether the characters in a string are in ascending order or not in Assembly Language

.MODEL  SMALL
.DATA
        NL1     DB      0AH,0DH,'IT IS ASCENDING ORDER$'
        NL2     DB      0AH,0DH,'IT IS DESCENDING ORDER$'
        FA      DB      00
        FD      DB      00
        STR1    DB      20 DUP(' '),'$'
.CODE

MAIN    PROC
        MOV AX,@DATA
        MOV DS,AX

        LEA SI,STR1
        MOV AH,01H

        MOV CL,00H
LBL1:
        INT 21H
        CMP AL,0DH
        JE  LBL2
        MOV [SI],AL
        INC SI
        INC CL
        JMP LBL1

LBL2:
;        DEC CL
        MOV AL,'$'
        MOV [SI],AL
        LEA SI,STR1
        MOV BL,CL
LBL4:

        MOV AL,[SI]
        CMP AL,[SI+1]
        JL  LBL6
        INC SI
        LOOP LBL4


LBL5:
        CMP FA,00
        JG LBL7
DES:
        LEA DX,NL2
        MOV AH,09H
        INT 21H
        JMP EXIT

LBL6:
        INC FA
        DEC CL
        INC SI
        JMP LBL4
        
LBL7:
        DEC BL
        CMP FA,BL
        JNE DES

        LEA DX,NL1
        MOV AH,09H
        INT 21H

EXIT:
        MOV AH,4CH
        INT 21H
        
MAIN    ENDP
        END     MAIN


;LBL2:
;        MOV AL,'$'
;        MOV [SI],AL


OUTPUT
***********

Z:\assembly\SYSTEM~1\AS1>EX9
ABC
IT IS ASCENDING ORDER
Z:\assembly\SYSTEM~1\AS1>EX9
DCA
IT IS DESCENDING ORDER
  
Share: 



Matilda Hughes
Matilda Hughes author of Program to check whether the characters in a string are in ascending order or not is from London, United Kingdom.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!