News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

szLeft issue

Started by akalenuk, July 05, 2006, 01:34:17 PM

Previous topic - Next topic

akalenuk

I wrote some code with "szLeft" and found some provlems. First of all, it not necesserly ended the returned string by 0. Sometimes it did, sometimes - not. I wasted couple of hours trying to find the problem in my code, then put an "inc" and an "mov" after "invoke szLeft" and it turned allright. No big deal. But yesterday i downloaded new MASM package and the rest of the day played with new features, so the code left untouched. This morning i've rebuilt that fixed code and gave it to the boss. We were both surprised to see, that all the processed strings were missing one symbol. It was the last symbol of the strings returned by "szLeft". I've reinstalled MASM32 8 and rebuilt the program. It became normal again.

So what is the difference between szLeft in MASM32 8 and MASM32 9? Why that last symbol vanishes?

hutch--

Using the currednt version from version 9.0 this is a test piece that works fine.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .data?
      value dd ?

    .data
      item db "1234567890",0

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    LOCAL itm   :DWORD
    LOCAL pbuf  :DWORD
    LOCAL buffer[64]:BYTE

    mov pbuf, ptr$(buffer)

    mov eax, OFFSET item
    mov itm, eax

    cls
    print rv(szLeft,itm,pbuf,8),13,10
    print rv(szLeft,itm,pbuf,7),13,10
    print rv(szLeft,itm,pbuf,6),13,10
    print rv(szLeft,itm,pbuf,5),13,10
    print rv(szLeft,itm,pbuf,4),13,10
    print rv(szLeft,itm,pbuf,3),13,10
    print rv(szLeft,itm,pbuf,2),13,10
    print rv(szLeft,itm,pbuf,1),13,10

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««


It produces this result.


12345678
1234567
123456
12345
1234
123
12
1
Press any key to continue ...


Perhaps you could tell us a bit more about how you are using it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

akalenuk

Quote from: hutch-- on July 05, 2006, 03:03:29 PM

    print rv(szLeft,itm,pbuf,8),13,10

By the way, what is this "rv()" thing? Is it a new feature? I believe i never saw this before  :eek

Quote from: hutch-- on July 05, 2006, 03:03:29 PM
Perhaps you could tell us a bit more about how you are using it.

Allright. I use it to put a substring into string.

                                invoke szLeft,ADDR buffer,ADDR bufl,k
                                invoke szRight,ADDR buffer,ADDR bufr,l   
                                mov ebx,k
                                inc ebx
                                mov bufl[ebx],0
                                mov ebx,l
                                inc ebx
                                mov bufr[ebx],0
                                mov buffer[0],0
                                invoke szCatStr,ADDR buffer,ADDR bufl
                                invoke szCatStr,ADDR buffer,ADDR buff
                                invoke szCatStr,ADDR buffer,ADDR bufr

It works fine in an old version. I believe, now i should only increment k and skip this string caping thing in the middle, right?