Convert String to Uppercase

Hi I'm a newbie who's trying to write an Assembly program which can receive a sentence (containing letters, numbers and other characters) from the keyboard, then convert all the letters in the sentence to Uppercase (all other characters and numbers remain unchanged for output). How would I go about this? I don't have much idea at all besides the basic layout for the program. Any help would be much appreciated!

Freddy

Comments

  • : Hi I'm a newbie who's trying to write an Assembly program which can receive a sentence (containing letters, numbers and other characters) from the keyboard, then convert all the letters in the sentence to Uppercase (all other characters and numbers remain unchanged for output). How would I go about this? I don't have much idea at all besides the basic layout for the program. Any help would be much appreciated!
    :
    : Freddy
    :

    Dude , do u have the code with u by now? I got to pass it up in 2 weeks time..Please do send it to me, or if anyone knows, please do send it to my email extreme_sham@yahoo.com

  • : : Hi I'm a newbie who's trying to write an Assembly program which can receive a sentence (containing letters, numbers and other characters) from the keyboard, then convert all the letters in the sentence to Uppercase (all other characters and numbers remain unchanged for output). How would I go about this? I don't have much idea at all besides the basic layout for the program. Any help would be much appreciated!
    : :
    : : Freddy
    : :
    :
    : Dude , do u have the code with u by now? I got to pass it up in 2 weeks time..Please do send it to me, or if anyone knows, please do send it to my email extreme_sham@yahoo.com
    :
    :
    [blue]First of all, make a loop where you can load every symbol into a register, test it for some values and put it back:[/blue][code]
    .DATA
    strHello Db 'Hello, World! UpPeRcAsEtEsT ***$'
    .CODE
    ; ---------------------------------------------------------------
    ; DS:BX <- string to convert
    ; CX <- number of symbols at DS:SI
    ; ---------------------------------------------------------------
    MakeUpperCase Proc

    @_ForEveryChar:
    Mov al, [bx] ; AL = ASCII code

    ; --- Check if AL is in range ['a'..'z']
    Cmp al, 'a'
    Jb @_NextChar ; AL value is below 'a'
    Cmp al, 'z'
    Ja @_NextChar ; AL value is above 'z'

    ; --- AL is in ['a'..'z']
    Sub al, 20h ; AL now in ['A'..'Z']
    Mov [bx], al ; Put it back

    @_NextChar:
    Inc bx ; BX -> next symbol
    Loop @_ForEveryChar

    ret
    MakeUpperCase EndP

    ; ... using it
    Mov cx, 32
    Mov bx, offset [strHello]
    Call MakeUpperCase
    ; ...
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

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

Categories