News:

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

Main Menu

UAsm WinInc and the CStr mystery

Started by jj2007, February 23, 2024, 12:34:42 AM

Previous topic - Next topic

jj2007

So I gave it a try:
- downloaded UAsm64 and WinInc
- installed WinInc to \WinInc
- opened \WinInc\Samples\WinGUI1\WinGUI1.ASM (in RichMasm, what else?)
- built the libraries using \WinInc\Def\MAKELIBS.BAT
- corrected the simple line include windows.inc as follows:
        include \WinInc\include\windows.inc
        includelib \WinInc\Lib\kernel32.Lib
        includelib \WinInc\Lib\user32.Lib
        includelib \WinInc\Lib\gdi32.Lib
- hit F6, and got an error message: Error A2143: Symbol redefinition: CStr

Since I am an optimist, I renamed the CStr MACRO to xCStr and tried again, and voilĂ , all is fine, it works :badgrin:

Questions:
a) Why is there an error? Redefining macros isn't a problem, so that means it's a different type of symbol.
b) Where is the other CStr?

_japheth

Quote from: jj2007 on February 23, 2024, 12:34:42 AMQuestions:
a) Why is there an error? Redefining macros isn't a problem, so that means it's a different type of symbol.
b) Where is the other CStr?

Perhaps the listing file might give a clue?
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

jj2007

Right :thumbsup:

@CatStr  . . . . . . . . . . . .        Func
@Environ . . . . . . . . . . . .        Func
@InStr . . . . . . . . . . . . .        Func
@SizeStr . . . . . . . . . . . .        Func
@SubStr  . . . . . . . . . . . .        Func
ALIGNADDR  . . . . . . . . . . .        Proc
ASDOUBLE . . . . . . . . . . . .        Func
ASFLOAT  . . . . . . . . . . . .        Func
COMINTERFACE . . . . . . . . . .        Proc
CSTR . . . . . . . . . . . . . .        Func
CStr . . . . . . . . . . . . . .        Func
CVIRTUAL . . . . . . . . . . . .        Proc
ENDCOMINTERFACE  . . . . . . . .        Proc
ENDMETHODS . . . . . . . . . . .        Proc
EXPAND_PREFIX  . . . . . . . . .        Func
FP10 . . . . . . . . . . . . . .        Func
FP4  . . . . . . . . . . . . . .        Func
FP8  . . . . . . . . . . . . . .        Func

So it's some built-in function. But why are there plenty of sample.asm files with a CStr macro then? Doesn't make sense.

HSE

UAsm have an internal macros library.

Not so useful if you have your own macros.

That can be disable with -nomlib in command line.
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on February 23, 2024, 01:36:44 AMUAsm have an internal macros library.

Not so useful if you have your own macros.

It's actually not my own macros, it's their own CStr macro - check the WinInc\Samples folder.

_japheth

Quote from: jj2007 on February 23, 2024, 01:19:57 AMSo it's some built-in function. But why are there plenty of sample.asm files with a CStr macro then? Doesn't make sense.

It makes sense if you know the history of WinInc. It was supposed to work with Masm and JWasm - and the samples provided are mostly written by me ( forgot the details, so no offense meant if there's a sample from someone else )
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

Vortex

Hello,

ml.exe supplied with the Masm32 package can assemble the example :

\masm32\bin\ml /c /coff /I\WinInc\Include WinGUI1.ASM

jj2007

Quote from: _japheth on February 23, 2024, 04:02:43 AMIt makes sense if you know the history of WinInc. It was supposed to work with Masm and JWasm - and the samples provided are mostly written by me

Thanks, that explains it. In hindsight, you would have probably created a macro.asm instead of including the CStr macro in the examples. Anyway, not a big deal; I am working on a n00b-proof installer.

I admit I don't like the -nomlib solution. Likewise for AsmC's /Znk or /Zne. An assembler should work with its default options in 99% of all cases, not the other way round.

Quote from: Vortex on February 23, 2024, 05:13:54 AMml.exe supplied with the Masm32 package can assemble the example

Which is not surprising, given that the UAsm/JWasm/AsmC family are perfect MASM clones. The trouble comes with the 64-bit version, where the Watcom clones offer the full functionality but ML.exe is seriously crippled :sad:

jj2007

P.S.: I am trying my luck with \WinInc\Sampl64\WinGUI1\WinGUI1.asm

*** Assemble using UAsm64  ***
\WinInc\Include\winnt.inc(5066) : Error A2091: Language type must be specified
 @DefProto(3)[winasm.inc]: Macro called from
  \WinInc\Include\winnt.inc(5066): Included by
   \WinInc\Include\windef.inc(149): Included by
    \WinInc\Include\windows.inc(111): Included by
     Tmp_File.asm(12): Main line code
\WinInc\Include\winnt.inc(5297) : Error A2091: Language type must be specified
 \WinInc\Include\winnt.inc(5297): Included by
  \WinInc\Include\windef.inc(149): Included by
   \WinInc\Include\windows.inc(111): Included by
    Tmp_File.asm(12): Main line code
\WinInc\Include\winnt.inc(5299) : Error A2091: Language type must be specified
 \WinInc\Include\winnt.inc(5299): Included by
  \WinInc\Include\windef.inc(149): Included by
   \WinInc\Include\windows.inc(111): Included by
    Tmp_File.asm(12): Main line code
\WinInc\Include\winnt.inc(5366) : Error A2091: Language type must be specified
 \WinInc\Include\winnt.inc(5366): Included by
  \WinInc\Include\windef.inc(149): Included by
   \WinInc\Include\windows.inc(111): Included by
    Tmp_File.asm(12): Main line code
\WinInc\Include\winnt.inc(5379) : Error A2091: Language type must be specified
 \WinInc\Include\winnt.inc(5379): Included by
  \WinInc\Include\windef.inc(149): Included by
   \WinInc\Include\windows.inc(111): Included by
    Tmp_File.asm(12): Main line code
\WinInc\Include\winnt.inc(5380) : Error A2091: Language type must be specified
 \WinInc\Include\winnt.inc(5380): Included by
  \WinInc\Include\windef.inc(149): Included by
   \WinInc\Include\windows.inc(111): Included by
    Tmp_File.asm(12): Main line code
Tmp_File.asm(36) : Error A2082: Must be in segment block
Tmp_File.asm(37) : Error A2082: Must be in segment block
Tmp_File.asm(43) : Error A2082: Must be in segment block
Tmp_File.asm(45) : Error A2082: Must be in segment block
Tmp_File.asm(46) : Error A2030: Instruction or register not accepted in current CPU mode
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(47) : Error A2082: Must be in segment block
Tmp_File.asm(48) : Error A2082: Must be in segment block
Tmp_File.asm(49) : Error A2082: Must be in segment block
Tmp_File.asm(50) : Error A2142: Unmatched block nesting: OnCommand
Tmp_File.asm(54) : Error A2082: Must be in segment block
Tmp_File.asm(56) : Error A2092: PROC, MACRO or macro loop directive must precede LOCAL
Tmp_File.asm(58) : Error A2082: Must be in segment block
Tmp_File.asm(59) : Error A2030: Instruction or register not accepted in current CPU mode
Tmp_File.asm(60) : Error A2160: INVOKE requires prototype for procedure
Tmp_File.asm(61) : Error A2030: Instruction or register not accepted in current CPU mode
Tmp_File.asm(61) : Error A2082: Must be in segment block
Tmp_File.asm(61) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(62) : Error A2082: Must be in segment block
Tmp_File.asm(63) : Error A2030: Instruction or register not accepted in current CPU mode
Tmp_File.asm(63) : Error A2082: Must be in segment block
Tmp_File.asm(63) : Error A2082: Must be in segment block
Tmp_File.asm(64) : Error A2082: Must be in segment block
Tmp_File.asm(64) : Error A2082: Must be in segment block
Tmp_File.asm(64) : Error A2082: Must be in segment block
Tmp_File.asm(64) : Error A2082: Must be in segment block
Tmp_File.asm(64) : Fatal error A1113: Too many errors
*** Assembly error ***

Yep, that's a clear message: "Not for n00bs!"

Does anybody have a short & crispy 64-bit example that works with the current version of UAsm, without any cryptic commandline options?

_japheth

Quote from: jj2007 on February 23, 2024, 06:41:02 AMP.S.: I am trying my luck with \WinInc\Sampl64\WinGUI1\WinGUI1.asm

*** Assemble using UAsm64  ***
\WinInc\Include\winnt.inc(5066) : Error A2091: Language type must be specified
 @DefProto(3)[winasm.inc]: Macro called from
  \WinInc\Include\winnt.inc(5066): Included by
   \WinInc\Include\windef.inc(149): Included by
    \WinInc\Include\windows.inc(111): Included by
     Tmp_File.asm(12): Main line code
[snip]
Tmp_File.asm(64) : Fatal error A1113: Too many errors
*** Assembly error ***

Yep, that's a clear message: "Not for n00bs!"

Does anybody have a short & crispy 64-bit example that works with the current version of UAsm, without any cryptic commandline options?

Well, I definitely don't feel responsible for UAsm, but since WinInc is my child:

Why don't you look into the MAKEFILE that is supplied with this sample? It's using JWasm as assembler, but nevertheless one may be able to see that the -win64 cmdline option is used there. Did you set the equivalent option for UAsm?




Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

jj2007

Quote from: _japheth on February 23, 2024, 07:48:49 PMWhy don't you look into the MAKEFILE that is supplied with this sample? It's using JWasm as assembler, but nevertheless one may be able to see that the -win64 cmdline option is used there. Did you set the equivalent option for UAsm?

I'm a BASIC guy, never needed an extra makefile to get the job done. But thanks for the hint, anyway. Yes, the -win64 option was set, RichMasm autodetects the need to do so.

Now I got it built, but RegisterClassEx fails without last error being set.

TimoVJL

Quote from: jj2007 on February 23, 2024, 08:47:09 PMI'm a BASIC guy, ...
surely, but many basic programmers use also many another languages too  :biggrin:
May the source be with you

jj2007

Right. I, for example, have used 68k and x86 assembler, Python, JavaScript, Fortran, PHP and several C and BASIC dialects for almost 40 years, and never needed a "makefile". Btw if you haven't that behemoth of Visual Shit installed, your system won't even find nmake.

_japheth

Quote from: jj2007 on February 24, 2024, 02:20:20 AM.... for almost 40 years, and never needed a "makefile".

Correct. You don't need it in your struggle for survival. But I guess that's also true for Basic ...

QuoteBtw if you haven't that behemoth of Visual Shit installed, your system won't even find nmake.

Also true. But Open Watcom's wmake - and even Borland's make - might do the job as well. But that's already a bit "advanced".

Have you got your RegisterClassEx problem solved? I just looked into the source - there's no such API call. Perhaps you meant RegisterClass instead? Using that API definitely requires the -Zp8 cmdline option - but you surely know that, of course...

Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

jj2007

Quote from: _japheth on February 24, 2024, 03:24:32 AMHave you got your RegisterClassEx problem solved? I just looked into the source - there's no such API call. Perhaps you meant RegisterClass instead? Using that API definitely requires the -Zp8 cmdline option - but you surely know that, of course...

Yes, I know that, and RichMasm sets -Zp8. Thanks for reminding me.

In the meantime, I've advanced a bit, and there is a new problem:
WinMain proc hInstance:HINSTANCE, hPrevInstance:HINSTANCE, lpszCmdline:LPSTR, cmdshow:UINT
LOCAL msg:MSG
  wc equ [rbx.WNDCLASSEX]        ; we use an equate for better readability
  lea rbx, wcx
  mov wc.hInstance, rv(GetModuleHandle, 0)
  mov wc.hIcon, rv(LoadIcon, rax, IDI_APPLICATION)        ; click on the first Rsrc bookmark to change the icon
  mov wc.hIconSm, rax            ; the rv macro returns results in rax
  mov wc.hCursor, rv(LoadCursor, NULL, IDC_ARROW)     ; get a cursor
  invoke RegisterClassEx, rbx            ; the window class needs to be registered
  wsStyle=WS_OVERLAPPEDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN
  invoke CreateWindowEx, 0, wc.lpszClassName, Chr$("Hello World"), wsStyle, 300+320*@64, 127, 300, 200, NULL, rv(LoadMenu, wc.hInstance, 100), wc.hInstance, NULL
  msgLoop:    inc eax
    shr eax, 1
    je @F                ; quit if GetMessage returned 0 (exit OK) or -1 (error), or if CwEx failed
      invoke TranslateMessage, addr msg    ; translates virtual-key messages into character messages
    invoke DispatchMessage, addr msg    ; dispatches a message to a window procedure
    invoke GetMessage, addr msg, 0, 0, 0    ; retrieve a message from the queue, and return a BOOL
      jmp msgLoop
@@:    invoke ExitProcess, 0 ;msg.wParam
WinMain endp

UAsm: Tmp_File.asm(39) : Error A2142: Unmatched block nesting: WinMain

Same with JWasm: Warning A4109: Invalid command-line option: -nomlib
Tmp_File.asm(39) : Error A2142: Unmatched block nesting: WinMain

I've stared a while at this proc, renamed it to test if there was a name conflict... no luck. Besides, it works perfectly in a 64-bit JBasic program.

Any idea?

I got the WinMain problem half solved: Error A2262: Missing .ENDPROLOG: WinMain
Yep, UAsm and JWasm can, apparently, not imagine that a proc can be left with ExitProcess instead of a ret.
But now the Error A2142 moved to WndProc :rolleyes: