tags:

views:

93

answers:

2
org 0x100
SEGMENT .CODE
    mov ah,0x9
    mov dx, Msg1
    int 0x21

    ;string input
    mov ah,0xA
    mov dx,buff
    int 0x21
    mov ax,0
    mov al,[buff+1]; length

    ;string UPPERCASE    
    mov cl, al  
    mov si, buff
    cld
loop1:
    lodsb;
    cmp al, 'a' 
    jnb upper
loop loop1
;output
mov ah,0x9
mov dx, buff
int 0x21

exit:
    mov ah, 0x8
    int 0x21
    int 0x20
upper:
    sub al,32 
    jmp loop1
SEGMENT .DATA
Msg1 db 'Press string: $'
buff db 254,0

this code perform poorly. I think that problem in "jnb upper". This program make small symbols into big symbols.

+1  A: 

It looks like you are trying to convert a string from lower case to upper case? The problem is that you are only comparing input against the letter 'a':

cmp al, 'a' 
jnb upper

If you want to convert from lowercase to upper case, you need to check for characters in the range from 'a' to 'z', and if once is in that range then subtract 32.

Also, I think you want to write the uppercase char back to memory in upper. All you are doing is updating the register, which is then overwritten in the next iteration of loop1.

Does that help?

Justin Ethier
jnb upper: it will jump _only_ if it's greater or equal than a. I don't think he needs to to any other comparison. The fact that he is not writing the value back to the buffer is the true problem.
nc3b
and what i must do? (I was not so long ago began to learn assembler)
GLeBaTi
@nc3b - Good catch, but he still needs to make sure it is not greater than 'z'
Justin Ethier
@GLeBaTi - Its been a long time since I've written any assembly. Try writing it yourself and post back to SO if you have questions...
Justin Ethier
+1  A: 

I had found my problem: When I was inputing text, '$'-not added.

GLeBaTi
+1 for following up
I. J. Kennedy