News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

January 2018 library and macro update.

Started by hutch--, January 07, 2018, 11:26:06 AM

Previous topic - Next topic

hutch--

Zip file contains the most current masm64 library modules and the most current macro file. Unzip this file into a separate directory and manually copy the library file to the m64lib directory overwriting the existing modules. Then run the "makeit.bat" file to build the library. Copy the "macros64.inc" file into the "macros64" directory overwriting the earlier file. This should allow you to build any of the recent examples.

sinsi

Possible error? From szLtrim

    mov rax, rdx                    ; store buffer adress in RAX
    sub rcx, 1
  lbl0:                             ; trim the front chars off src
    add rcx, 1
    cmp BYTE PTR [rcx], 33          ; ditch anything below ASCII 33
    jb lbl0

Doesn't check for the terminating zero in src, so an empty/blank string wouldn't get caught (or potentially return rubbish from memory after).

hutch--

Yes you are right, it exits that code on a zero but drops directly into the following loop code. I am guilty of writing suicide code as I would not pass a zero length string to it but its easy enough to modify so it just exits the proc on a zero. When I get time I will set up a test piece and modify the algo. Thanks for finding it.

Slightly later : I think this one does the job, the old code did not crash but it did not tell you anything either. The test rdx, rdx caught the zero. I will put it back into a module shortly.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc


    .data
      test1 db "    1234567890",0
      test2 db 0

      ptst1 dq test1
      ptst2 dq test2

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    rcall szLtrimx, ptst1, ptst1

    conout ptst1,lf,lf

    rcall szLtrimx, ptst2, ptst2
    cmp rax, 0
    jne @F
    conout "String of 0 length passed",lf,lf
  @@:

    waitkey

    invoke ExitProcess,0

    ret

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

NOSTACKFRAME

szLtrimx proc

  ; rcx = src string
  ; rdx = dest buffer

    mov rax, rdx                    ; store buffer adress in RAX

    sub rcx, 1
  lbl0:                             ; trim the front chars off src
    add rcx, 1
    cmp BYTE PTR [rcx],0
    jne @F
    xor rax, rax
    ret
  @@:
    cmp BYTE PTR [rcx], 33          ; ditch anything below ASCII 33
    jb lbl0

    mov r9, -1
  lbl1:
  REPEAT 3                          ; unroll by 4
    add r9, 1
    movzx rdx, BYTE PTR [rcx+r9]
    mov BYTE PTR [rax+r9], dl
    test rdx, rdx
    jz lbl2
  ENDM

    add r9, 1
    movzx rdx, BYTE PTR [rcx+r9]
    mov BYTE PTR [rax+r9], dl
    test rdx, rdx
    jnz lbl1

  lbl2:                             ; return value is in RAX
    ret

szLtrimx endp

STACKFRAME

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

HSE

Hi Hutch!

Compiling library block_l and rtrim, and several Gdip functions apparently are missing.

Later: matrix3 compilation say that arrev is undefined.
Sorry. I have the newer files of 2016!!

But Gdip functions still missing ::)
Equations in Assembly: SmplMath

hutch--

GDIplus is enabled with the following in the macro file.

  ; ========================================================

    GdiPlusBegin MACRO
      .data
        gdii GdiplusStartupInput <>
        GDItoken@@@@ dq ?
      .code
      mov gdii.GdiplusVersion, 1
      mov gdii.DebugEventCallback, 0
      mov gdii.SuppressBackgroundThread, 0
      mov gdii.SuppressExternalCodecs, 0
      invoke GdiplusStartup,ADDR GDItoken@@@@,ADDR gdii,0
    ENDM

    GdiPlusEnd MACRO
      invoke GdiplusShutdown,GDItoken@@@@        ; cleanup on exit
    ENDM

  ; ========================================================

The library has a procedure "LoadGdiImage" for loading jpg and similar files and returning a bitmap handle.

The library procedure "arrev" is in the zip file. Now the file posted in this zip file are later than any of the others before it. You must copy them into the m64lib directory overwriting the existing files and build the library using "makeit.bat".



HSE

Gdiplus was not included in my masm64rt.inc (in the last package masm64rt.inc is in tempdir)

Perfect now  :t

Thanks
Equations in Assembly: SmplMath