Reading string from a buffer to another and print it out

Started by jnrico, September 26, 2005, 02:19:52 PM

Previous topic - Next topic

jnrico

This is my first assember program. All I am trying to do is read a string from a buffer copy it to another and print it out once I am done.
The program runs, but nothing prints out. Thanks in advance for any help you guys can provide me on this.

.data
       src db "This is the string", 0

    .data?
       dest db 256 dup (?)
       
    .code

start:
    call main

    exit

main proc

      LOCAL srcPtr :DWORD
      LOCAL desPtr :DWORD
     
      mov srcPtr, OFFSET src
      mov desPtr, OFFSET dest
     
      push edi
      push esi

      cld         
       mov esi, srcPtr
      mov edi, desPtr

  label1:
       lodsb      
       stosb         
       cmp al, 0      
       jne label1
       
      print edi
     
      pop edi
      pop esi

    ret

main endp

end start

Tedd

1. Are you linking it as a console application?
2. loadsb followed by stosb is messing up your values for esi & edi (each one will add one to each - so add 2 to each for each loop!)
   -- use just movsb instead :wink
No snowflake in an avalanche feels responsible.


tenkey

The value of EDI at the end of the loop is not the address to the beginning of your string!
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8