Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » GeneralRSS Feeds

Program that reads a string of capital letters, ending with a carriage return, and display the longest sequence of consecutive alphabetically.........

Posted By: Easy Tutor     Category: Assembly Language     Views: 7944

An AL Program that reads a string of capital letters, ending with a carriage return, and display the longest sequence of consecutive alphabetically increasing capital letters read.

Code for Program that reads a string of capital letters, ending with a carriage return, and display the longest sequence of consecutive alphabetically......... in Assembly Language

 .MODEL SMALL
 .STACK 100H

 .DATA
   PROMPT_1  DB  'Enter a string of Capital Letters : $'
   PROMPT_2  DB  0DH,0AH,'The longest consecutive increasing string is : $'
   INVALID   DB  0DH,0AH,'Invalid string of Capital Letters. Try again : $'
 
 .CODE
   MAIN PROC
     MOV AX, @DATA                ; initialize DS
     MOV DS, AX

     LEA DX, PROMPT_1             ; load and display the string PROMPT_1
     MOV AH, 9
     INT 21H

     JMP @START                   ; jump to label @START

     @TRY_AGAIN:                  ; jump label

     LEA DX, INVALID              ; load and display the string INVALID
     MOV AH, 9
     INT 21H

     @START:                      ; jump label
                                   
     MOV AH, 1                    ; set input function
     INT 21H                      ; read a character

     CMP AL, 0DH                  ; compare AL with CR
     JE @TRY_AGAIN                ; jump to label @TRY_AGAIN if AL=CR

     CMP AL, 41H                  ; compare AL with 41H
     JB @TRY_AGAIN                ; jump to label @TRY_AGAIN if AL<41H

     CMP AL, 5AH                  ; comapre AL with 5AH
     JA @TRY_AGAIN                ; jump to label @TRY_AGAIN if AL>5AH

     MOV BL, AL                   ; set BL=AL
     MOV BH, AL                   ; set BH=AL
     MOV DH, AL                   ; set DH=AL
     MOV DL, 1                    ; set DL=1
     MOV CL, 1                    ; set CL=1

     @INPUT:                      ; loop label
       INT 21H                    ; read a character

       CMP AL, 0DH                ; compare AL with CR
       JE @END_INPUT              ; jump to label @END_INPUT if AL=CR

       CMP AL, 41H                ; compare AL with 41H
       JB @TRY_AGAIN              ; jump to label @TRY_AGAIN if AL<41H

       CMP AL, 5AH                ; comapre AL with 5AH
       JA @TRY_AGAIN              ; jump to label @TRY_AGAIN if AL>5AH

       INC BL                     ; set BL=BL+1

       CMP AL, BL                 ; compare AL with BL
       JNE @CHECK_AND_REPLACE     ; jump to label @CHECK_AND_REPLACE if AL!=BL

       INC CL                     ; set CL=CL+1
       JMP @INPUT                 ; jump to label @INPUT

       @CHECK_AND_REPLACE:        ; jump label

       CMP CL, DL                 ; compare CL with DL
       JLE @SKIP_UPDATION_1       ; jump to label @SKIP_UPDATION_1 if CL<=DL

       MOV DH, BH                 ; set DH=BH
       MOV DL, CL                 ; set DL=CL

       @SKIP_UPDATION_1:          ; jump label

       MOV BH, AL                 ; set BH=AL
       MOV BL, AL                 ; set BL=AL
       MOV CL, 1                  ; set CL=1
     JMP @INPUT                   ; jump to label @INPUT

     @END_INPUT:                  ; jump label

     CMP CL, DL                   ; compare CL with DL
     JLE @SKIP_UPDATION_2         ; jump to label @SKIP_UPDATION_2 if CL<=DL

     MOV DH, BH                   ; set DH=BH
     MOV DL, CL                   ; set DL=CL

     @SKIP_UPDATION_2:            ; jump label

     MOV BX, DX                   ; set BX=DX

     LEA DX, PROMPT_2             ; load and display the string PROMPT_2
     MOV AH, 9
     INT 21H

     XOR CX, CX                   ; clear CX
     MOV CL, BL                   ; set CL=BL

     MOV DL, BH                   ; set DL=BH
     MOV AH, 2                    ; set output function

     @OUTPUT:                     ; loop label
       INT 21H                    ; print a character
       INC DL                     ; set DL=DL+1
     LOOP @OUTPUT                 ; jump to label @OUTPUT if CX!=0

     MOV AH, 4CH                  ; return control to DOS
     INT 21H
   MAIN ENDP
 END MAIN

 ;**************************************************************************;
 ;**************************************************************************;
 ;------------------------------  THE END  ---------------------------------;
 ;**************************************************************************;
 ;**************************************************************************;
  
Share: 



Easy Tutor
Easy Tutor author of Program that reads a string of capital letters, ending with a carriage return, and display the longest sequence of consecutive alphabetically......... is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

Related Articles and Code:


 

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!