Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy string and convert to upper case

Status
Not open for further replies.

yep2678

Programmer
Mar 28, 2006
1
US
This is what I have and think it is correct but the result shows up as all spaces... Im lost... Any help would be great. Thanks

TITLE process_strings
.586
.MODEL flat,stdcall
ExitProcess PROTO, ExitCode:DWORD

.data
message BYTE "You cant always get what you want",0
result BYTE SIZEOF message DUP(" "),0

.code
public fini
loop4 PROC

;----------Copy the string message to result
mov ebx,0
mov ecx,LENGTHOF message
next_char:
mov al,message[ebx]
cmp al,'a'
jb no_change
cmp al,'z'
ja no_change
and al,0DFh
no_change:
mov result[ebx],al
inc ebx
loop next_char

fini:: push 0
call ExitProcess
loop4 ENDP
END loop4
 
i think the conversion routine is solid,
nothing wrong there.

like tessa said, maybe ds needs to be set up first.
put this code at the beginning of your loop4 routine
and see what happens:

push cs
pop ds

instead of using ebx as a pointer i would have used esi,
and let lodsb do the byte fetching. should be faster.

 
I got this running in Linux/NASM for IA-32 with no trouble. I'd say watch the addressing syntax and know precisely what your macros are doing.

What compiler are you using?

Code:
section .text

        global _start

_start:
        xor     ebx, ebx
        mov     edx, $msg_len
next_char:
        mov     al, [msg+ebx]
        cmp     al, 'a'
        jb      no_change
        cmp     al, 'z'
        ja      no_change
        and     al, 0xDF
no_change:
        mov     [res+ebx], al
        inc     ebx
        cmp     ebx, edx
        jnz     next_char

        mov     ecx,$msg
        mov     ebx,1
        mov     eax,4
        int     80h

        mov     ecx,$res
        mov     ebx,1
        mov     eax,4
        int     80h

        mov     ebx,0
        mov     eax,1
        int     80h

section .data
msg     db      "You can't always get what you want", 0xa
msg_len equ     $ - msg
res     db      "                                  ", 0xa

Cheers,
ND [smile]

[small]bigoldbulldog AT hotmail[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top