News:

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

Possible problems with SSE usage.

Started by KeepingRealBusy, July 07, 2010, 12:57:11 AM

Previous topic - Next topic

KeepingRealBusy

I tried to add a call to crt__wcslwr_s to my Timings. First, it would not assemble. I then added the code to msvcrt.inc (copy of crt__wcslwr with _s added). This fails to link. The source in VS at \vc\crt\src shows both of these functions defined in the same source module, both actually call a common subfunction, crt__wcslwr with a -1 for the size parameter and crt__wcslwr_s with the supplied size.

Why does crt__wcslwr_s not exist?

Dave.

dedndave

if you look inside masm32\include\msvcrt.inc...
    externdef _imp___wcslwr:PTR c_msvcrt
    crt__wcslwr equ <_imp___wcslwr>

try adding this to the beginning of your program
    externdef _imp___wcslwr_s:PTR c_msvcrt
    crt__wcslwr_s equ <_imp___wcslwr_s>

KeepingRealBusy

I did this, and got around the assembly error, but right into the linker error.

jj2007

It must be present in \masm32\lib\msvcrt.lib, too (and it's not there).
Add it to \masm32\tools\makecimp\msvcrt.txt...

KeepingRealBusy

JJ,

Thank you. I knew that someone here would have the answer.

Dave

dedndave

oh i see - he's just making up names   :lol

jj2007

It seems Hutch uses \masm32\tools\makecimp\makecimp.exe to modify the crt library.

MichaelW

I think this is all correct:

;==============================================================================
    include \masm32\include\masm32rt.inc
    .586
    include \masm32\macros\timers.asm
;==============================================================================
    .data
      hmsvcr80   dd 0
      ws         dw "A","B","C",0
    .code
;==============================================================================
start:
;==============================================================================

    invoke LoadLibrary, chr$("msvcr80.dll")
    mov hmsvcr80, eax
    print hex$(eax),13,10

    invoke GetProcAddress, hmsvcr80, chr$("_wcslwr_s")
    mov esi, eax
    print hex$(eax),13,10

    invoke crt_printf,cfm$("%S\n"), ADDR ws
    push SIZEOF ws
    push OFFSET ws
    call esi
    add esp, 8
    invoke crt_printf,cfm$("%S\n"), ADDR ws

    invoke Sleep, 3000

    counter_begin 1000, HIGH_PRIORITY_CLASS
        invoke crt__wcslwr, ADDR ws
    counter_end
    print str$(eax)," cycles",13,10

    counter_begin 1000, HIGH_PRIORITY_CLASS
        push SIZEOF ws
        push OFFSET ws
        call esi
        add esp, 8
    counter_end
    print str$(eax)," cycles",13,10

    invoke FreeLibrary, hmsvcr80
    print str$(eax),13,10,13,10

    inkey "Press any key to exit..."
    exit
;==============================================================================
end start


78130000
7817FCAB
ABC
abc
101 cycles
181 cycles
1


It should be no big deal to create an import library for msvcr80.dll.
eschew obfuscation

KeepingRealBusy

I don't know whether I blew it or not. I had tried to rebuild the library using "make" in \m32lib. Two modules had 2 errors, fptoa.asm and fptoa2.asm. I fixed the first error in each module from


    fbstp    [esp]


to


    fbstp    TBYTE PTR [esp]


That cleared up the first error in each, but the second error remains. A2006 undefined symbol PowerOf10. There is a proto for PowerOf10 in these modules, but the error remains.

Any good thoughts? Bad thoughts?

Dave.

KeepingRealBusy

OBTW, the make file has an error check for the assembly step, but apparently MASM does not set the error code for assembly errors using a response file.  I think I remember reporting this to MS long ago, but will have to dig to see what their response was.

Dave.

hutch--

JJ,

> It seems Hutch uses \masm32\tools\makecimp\makecimp.exe to modify the crt library.

No, the tool just makes an import library that avoids naming conflicts with masm reserve words. the content is determined by MSVCRT.DLL.

Now with the function that KeepingRealBusy  wants, the idea is to test if its there first and you do this by the normal LoadLibrary(), GetProcAddress() and see if you can call it that way. If so then you simply add the name to the import list and build the import library.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

KeepingRealBusy

Well, I  modifyied the crt library with makecimp.exe. No assembly or link problems now. When I try to execute the .exe, I get "The procedure entry point _wcslwr_s could not be located in the dynamic link library msvcrt.dll.

Now what?

Dave.

jj2007

Dave,
MichaelW found the reason: This is msvcr80.dll...

hutch--

Check to see if the function you are after is in the standard MSVCRT.DLL
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MichaelW

The attachment includes an import library and include file for msvcr80.dll and a small test app. Starting with the full module definition file (see msvcr80_full.def), I removed a number of exports that did not appear to me to be usable/useful. That left 1349 exports, versus 730 for msvcrt.lib. Note that I modified the generated include file substituting "cr8_" for "crt_" to avoid conflicts.

There is a msvcr80.dll version 8.0.50727.1433 on my Windows 2000 system. The file is dated Wednesday, October 24, 2007 so I have no idea how it got there, or if it will be present on other systems.
eschew obfuscation