Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » GeneralRSS Feeds

Program that prompts a user to enter a line of text. On the next line, display the capital letter entered that comes first alphabetically......

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

An AL Program that prompts a user to enter a line of text. On the next line, display the capital letter entered that comes first alphabetically and the one that comes last. If no capital letters are entered, display "No Capital Letters".

Code for Program that prompts a user to enter a line of text. On the next line, display the capital letter entered that comes first alphabetically...... in Assembly Language

 .MODEL SMALL
 .STACK 100H

 .DATA
   PROMPT_1  DB  'Enter a line of text : $'
   PROMPT_2  DB  0DH,0AH,'First Capital Letter : $'
   PROMPT_3  DB  0DH,0AH,'Last Capital Letter  : $'
   PROMPT_4  DB  0DH,0AH,' *****  No Capital Letters  *****$'

   FLAG          DB  0
   FIRST_LETTER  DB  5BH
   LAST_LETTER   DB  40H

 .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

     MOV AH, 1                    ; set input function

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

       MOV BL, AL                 ; set BL=AL

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

       CMP BL, "A"                ; compare BL with "A"
       JL @INPUT                  ; jump to label @INPUT if BL<A

       MOV FLAG, 1                ; set FLAG=1

       CMP BL, "Z"                ; compare BL with "Z"
       JG @INPUT                  ; jump to label @INPUT if BL>Z

       CMP BL, FIRST_LETTER       ; compare BL with variable FIRST_LETTER
       JG @NEXT                   ; jump to label @NEXT if BL>FIRST_LETTER
       MOV FIRST_LETTER, BL       ; set FIRST_LETTER=BL

       @NEXT:                     ; jump label
         CMP BL, LAST_LETTER      ; compare BL with variable LAST_LETTER
         JL @INPUT                ; jump to label @INPUT if BL<LAST_LETTER
         MOV LAST_LETTER, BL      ; set LAST_LETTER=BL

     JMP @INPUT                   ; jump to label @INPUT

     @END_INPUT:                  ; jump label

     CMP FLAG, 1                  ; compare FLAG with 1             
     JE @DISPLAY                  ; jump to label @DISPLAY if FLAG=1

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

     JMP @END                     ; jump to label @END

     @DISPLAY:                    ; jump label
       LEA DX, PROMPT_2           ; load and display the string PROMPT_2
       MOV AH, 9                  
       INT 21H                    

       MOV AH, 2                  ; set output function
       MOV DL, FIRST_LETTER       ; set DL=FIRST_LETTER
       INT 21H                    ; print a character

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

       MOV AH, 2                  ; set output function
       MOV DL, LAST_LETTER        ; set DL=LAST_LETTER
       INT 21H                    ; print a character

     @END:                        ; jump label

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

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



Easy Tutor
Easy Tutor author of Program that prompts a user to enter a line of text. On the next line, display the capital letter entered that comes first 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:


 
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!