The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on January 31, 2008, 09:03:55 PM

Title: jump over 2 zeros in al
Post by: ragdog on January 31, 2008, 09:03:55 PM
hi  ::)

i have problem with read my hex string.
   
It print not the 2 string! I have yet 2x Inc
esi write to jump  over the 2 zero´s  or not?

example to print: msgbox Test1
                         msgbox Test2
                         msgbox Test3


.data
sztest       db054h,065h,073h,074h,031h,000h,000h,054h,065h,073h,074h,032h,000h,000h,054h,065h,073h,074h,033h,00h,00h
;Test100Test200Test300


.code

readstrings proc

LOCAL szDest1[256]:BYTE
LOCAL szDest2[256]:BYTE
LOCAL szDest3[256]:BYTE
LOCAL szDest4[256]:BYTE
LOCAL szDest5[256]:BYTE

            xor esi,esi
            xor edi,edi
        mov esi,offset sztest       
@Read_Test1:
        mov al, byte ptr [esi]      
            mov byte ptr szDest1[edi], al
            inc edi                      ;inc dest buffer
            inc esi                      ;inc src buffer
            cmp al,00h                   ;compare if al 00h
            jnz @Read_Test1              ;jmp if al not 00h
         invoke MessageBox,hWnd,addr szDest1,0,MB_OK
           
            inc esi
            inc esi
@Read_Test2:
        mov al, byte ptr [esi]      
            mov byte ptr szDest2[edi], al
            inc edi                      ;inc dest buffer
            inc esi                      ;inc src buffer
            cmp al,00h                   ;compare if al 00h
            jnz @Read_Test2              ;jmp if al not 00h
         invoke MessageBox,hWnd,addr szDest2,0,MB_OK
...
..
.

readstrings endp


thanks in forward
ragdog
Title: Re: jump over 2 zeros in al
Post by: RuiLoureiro on January 31, 2008, 09:17:30 PM
Quote from: ragdog on January 31, 2008, 09:03:55 PM

@Read_Test1:
           mov al, byte ptr [esi]        
            mov byte ptr szDest1[edi], al
            inc edi                      ;inc dest buffer
            inc esi                        ; points to the next 0
            cmp al,00h                   ;compare if al 00h
            jnz @Read_Test1              ;jmp if al not 00h
         invoke MessageBox,hWnd,addr szDest1,0,MB_OK
           
            inc esi
            ; inc esi

Hi,
         I think you have 2 inc esi   instead of    inc esi.  Is it ?
Rui
Title: Re: jump over 2 zeros in al
Post by: ragdog on January 31, 2008, 09:31:47 PM
i removed a one "inc esi"
No, unfortunately, is the same problem!

Thank you
Title: Re: jump over 2 zeros in al
Post by: RuiLoureiro on January 31, 2008, 09:51:11 PM
       lea     edi, szDest1 
and  lea    edi, szDest2   to get the address of szDest1 ... ? Doesnt work ?
Title: Re: jump over 2 zeros in al
Post by: ragdog on January 31, 2008, 09:59:11 PM
It is any other problem, the first string is displayed to the msgbox  not the string 2 ...

:'(
Title: Re: jump over 2 zeros in al
Post by: MichaelW on January 31, 2008, 10:03:19 PM
The main problem is that you are not setting edi back to zero before the second loop. Also, you need only one inc esi because the first loop is leaving esi set to the second null.
Title: Re: jump over 2 zeros in al
Post by: ragdog on January 31, 2008, 10:08:54 PM


i have it inc esi
           xor edi,edi

thanks michael

ragdog