Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

coverting lowercase to uppercase..

leiyahleiyah Member Posts: 9
we have given an activity wherein we're going to write a program that will prompt the user to enter a lowercase letter. On the next line, display the uppercase letter entered. If no lowercase letter is entered, display "INVALID". The execution should look like this:

Enter a Lowercase letter: c
Uppercase: C
(esc key to terminate the program)

Enter a Lowercase letter: A
Uppercase: INVALID
(esc key terminates the program)

im only a begginer and i dont know what to do..
its a TASM program..
i hope you could help me with this..
thanks in advance..

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : we have given an activity wherein we're going to write a program
    : that will prompt the user to enter a lowercase letter. On the next
    : line, display the uppercase letter entered. If no lowercase letter
    : is entered, display "INVALID". The execution should look like this:
    :
    : Enter a Lowercase letter: c
    : Uppercase: C
    : (esc key to terminate the program)
    :
    : Enter a Lowercase letter: A
    : Uppercase: INVALID
    : (esc key terminates the program)
    :
    : im only a begginer and i dont know what to do..
    : its a TASM program..
    : i hope you could help me with this..
    : thanks in advance..
    :
    [color=Blue]
    Everything is coded by invoking interrupts. You need interrupt number 21H for this program. Here is a link, which explains it in minimal detail:

    [link=http://www.ctyme.com/intr/int-21.htm]http://www.ctyme.com/intr/int-21.htm[/link]

    Basically, the principle of it is to set up registers, as specified in that link and invoke an interrupt instruction: INT 21H. This will make stuff happen, like printing text to screen or getting input from user or reading/writing a file and a lot of other stuff.

    Begin with displaying some text:
    [code]
    mov dx, [strHello]
    mov ah, 9
    int 21h
    [/code]
    Next, get one symbol from user with echo:
    [code]
    mov ah, 1
    int 21h
    ;
    ; Now AL register has the character user entered from keyboard.
    ;
    [/code]
    Now, you need to test if this character is valid low case symbol. All low case symbols located between 'a' and 'z'. So, if character code in AL is below 'a' (less than 'a') - you print "INVALID". If AL is above 'z' - you also print "INVALID". Otherwise, the symbol is valid:
    [code]
    cmp al, 'a'
    jb invalid
    cmp al, 'z'
    ja invalid
    ;
    ; At this point the AL code is valid, so you need
    ; to convert it to upper case and then print it.
    ;
    sub al, 20h
    ;
    ; Any lower case character is larger than its upper case equivalent
    ; by the value of 20h, so you just need to subtract 20h and AL
    ; becomes upper case. Now, print first the text "Uppercase: " and
    ; print a character from AL. However, there is an issue here - when
    ; printing text AL may be destroyed by interrupt, so you need to
    ; store it in memory or in stack during the printing.
    ;
    [/code]
    After printing jump back to the beginning to ask again for a symbol. Check which code comes for ESC character - I think it is code 1Bh, but not sure.
    [/color]
  • frozen_rosefrozen_rose Member Posts: 2
    : : we have given an activity wherein we're going to write a program
    : : that will prompt the user to enter a lowercase letter. On the next
    : : line, display the uppercase letter entered. If no lowercase letter
    : : is entered, display "INVALID". The execution should look like this:
    : :
    : : Enter a Lowercase letter: c
    : : Uppercase: C
    : : (esc key to terminate the program)
    : :
    : : Enter a Lowercase letter: A
    : : Uppercase: INVALID
    : : (esc key terminates the program)
    : :
    : : im only a begginer and i dont know what to do..
    : : its a TASM program..
    : : i hope you could help me with this..
    : : thanks in advance..
    : :
    : [color=Blue]
    : Everything is coded by invoking interrupts. You need interrupt
    : number 21H for this program. Here is a link, which explains it in
    : minimal detail:
    :
    : [link=http://www.ctyme.com/intr/int-21.htm]http://www.ctyme.com/intr/
    : int-21.htm[/link]
    :
    : Basically, the principle of it is to set up registers, as specified
    : in that link and invoke an interrupt instruction: INT 21H. This will
    : make stuff happen, like printing text to screen or getting input
    : from user or reading/writing a file and a lot of other stuff.
    :
    : Begin with displaying some text:
    : [code]:
    : mov dx, [strHello]
    : mov ah, 9
    : int 21h
    : [/code]:
    : Next, get one symbol from user with echo:
    : [code]:
    : mov ah, 1
    : int 21h
    : ;
    : ; Now AL register has the character user entered from keyboard.
    : ;
    : [/code]:
    : Now, you need to test if this character is valid low case symbol.
    : All low case symbols located between 'a' and 'z'. So, if character
    : code in AL is below 'a' (less than 'a') - you print "INVALID". If AL
    : is above 'z' - you also print "INVALID". Otherwise, the symbol is
    : valid:
    : [code]:
    : cmp al, 'a'
    : jb invalid
    : cmp al, 'z'
    : ja invalid
    : ;
    : ; At this point the AL code is valid, so you need
    : ; to convert it to upper case and then print it.
    : ;
    : sub al, 20h
    : ;
    : ; Any lower case character is larger than its upper case equivalent
    : ; by the value of 20h, so you just need to subtract 20h and AL
    : ; becomes upper case. Now, print first the text "Uppercase: " and
    : ; print a character from AL. However, there is an issue here - when
    : ; printing text AL may be destroyed by interrupt, so you need to
    : ; store it in memory or in stack during the printing.
    : ;
    : [/code]:
    : After printing jump back to the beginning to ask again for a symbol.
    : Check which code comes for ESC character - I think it is code 1Bh,
    : but not sure.
    : [/color]


    HI, i COULD hardly understand... please help me to have the code.. my problem is the same with the above post.. I just cant really understand TASM. Can you provide me the code for me to have a basis of my succeeding problems in tasm? We have 4 problems left and the deadline in on friday.. Thanks. please reply..
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [color=Blue]I do not use TASM anymore. Do you know how to write a simple TASM program which prints simple "Hello!"? If you do, then start with that. Then add some user input. Also, search this board for code - there should be some code samples from TASM.[/color]
  • frozen_rosefrozen_rose Member Posts: 2
    : [color=Blue]I do not use TASM anymore. Do you know how to write a
    : simple TASM program which prints simple "Hello!"? If you do, then
    : start with that. Then add some user input. Also, search this board
    : for code - there should be some code samples from TASM.[/color]

    .alright, thanks anyway...
    [b]cmp al, 1Bh[/b]
    hi again, can you explain to me what is this for? Thanks a lot!!
Sign In or Register to comment.