Author Topic: January 2018 library and macro update.  (Read 572 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5090
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
January 2018 library and macro update.
« on: January 07, 2018, 11:26:06 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

sinsi

  • Member
  • *****
  • Posts: 1025
Re: January 2018 library and macro update.
« Reply #1 on: January 07, 2018, 03:29:39 PM »
Possible error? From szLtrim
Code: [Select]
    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).
I can walk on water but stagger on beer.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5090
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: January 2018 library and macro update.
« Reply #2 on: January 07, 2018, 05:27:37 PM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

HSE

  • Member
  • ****
  • Posts: 605
  • <AMD>< 7-32>
Re: January 2018 library and macro update.
« Reply #3 on: January 08, 2018, 01:46:00 PM »
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 ::)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5090
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: January 2018 library and macro update.
« Reply #4 on: January 08, 2018, 05:04:33 PM »
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".


hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

HSE

  • Member
  • ****
  • Posts: 605
  • <AMD>< 7-32>
Re: January 2018 library and macro update.
« Reply #5 on: January 09, 2018, 12:41:44 AM »
Gdiplus was not included in my masm64rt.inc (in the last package masm64rt.inc is in tempdir)

Perfect now  :t

Thanks