### Author Topic: UASM 2.46 Release  (Read 6186 times)

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #30 on: December 08, 2017, 11:00:31 PM »
Hi all,

Packages and git have been updated to 2.46.3 dated 8th Dec.
This includes all the required fixes and a new option hlcall:{on|off} to disable the c style function calling and object/pointer invocations. It's enabled by default.

Cheers

#### nidud

• Member
• Posts: 1614
##### Re: UASM 2.46 Release
« Reply #31 on: December 08, 2017, 11:26:06 PM »
Interesting development

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #32 on: December 08, 2017, 11:31:33 PM »
Great minds ... and all paths lead to Rome .. I noticed you'd published an update about function pointer invocations at about exactly the same time!

#### LiaoMi

• Member
• Posts: 329
##### Re: UASM 2.46 Release
« Reply #33 on: December 09, 2017, 12:28:38 AM »
Hi johnsa,

thanks for the Great Job! XP version waiting for updates? Its not on the list of common releases, although the link to the previous version works.

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #34 on: December 09, 2017, 01:47:39 AM »
The 32bit version is built with WinXP compatibility mode so that should work as-is on XP.

John

#### jj2007

• Member
• Posts: 8893
• Assembler is fun ;-)
##### Re: UASM 2.46 Release
« Reply #35 on: December 09, 2017, 02:29:41 AM »
Congrats, John & Habran

Works perfectly with today's version of MasmBasic; I had to add a little switch, as agreed with John. RichMasm will try to install UAsm64 2.46 if there is no \Masm32\bin\uasm64.exe on your disk. This works fine when launching RichMasm from a drive different from C.

#### Vortex

• Member
• Posts: 1873
##### Re: UASM 2.46 Release
« Reply #36 on: December 11, 2017, 06:45:00 AM »
Hi habran and johnsa,

I am trying to use high level calling syntax with COM. Converting a simple Masm COM example :

Code: [Select]
`IActiveDesktop STRUCT    QueryInterface          dd ?    AddRef                  dd ?    Release                 dd ?    ApplyChanges            dd ?    GetWallpaper            dd ?    SetWallpaper            dd ?    GetWallpaperOptions     dd ?    SetWallpaperOptions     dd ?    GetPattern              dd ?    SetPattern              dd ?    GetDesktopItemOptions   dd ?    SetDesktopItemOptions   dd ?    AddDesktopItem          dd ?    AddDesktopItemWithUI    dd ?    ModifyDesktopItem       dd ?    RemoveDesktopItem       dd ?    GetDesktopItemCount     dd ?    GetDesktopItem          dd ?    GetDesktopItemByID      dd ?    GenerateDesktopItemHtml dd ?    AddUrl                  dd ?    GetDesktopItemBySource  dd ?IActiveDesktop ENDS`
Probably, my convertion is not correct so I need your help here :

Code: [Select]
`COMINTERFACE IActiveDesktopCVIRTUAL  ApplyChanges ,DWORD, :DWORDCVIRTUAL  GetWallpaper ,DWORD, :PTR, :DWORD, :DWORDCVIRTUAL  SetWallpaper ,DWORD, :PTR, :DWORDCVIRTUAL  GetWallpaperOptions ,DWORD, :DWORD, :DWORDCVIRTUAL  SetWallpaperOptions ,DWORD, :DWORD, :DWORDCVIRTUAL  GetPattern  ,DWORD,:PTR, :DWORD, :DWORDCVIRTUAL  SetPattern ,DWORD, :PTR, :DWORDCVIRTUAL  GetDesktopItemOptions ,DWORD, :DWORD, :DWORDCVIRTUAL  SetDesktopItemOptions ,DWORD, :DWORD, :DWORDCVIRTUAL  AddDesktopItem ,DWORD, :DWORD, :DWORDCVIRTUAL  AddDesktopItemWithUI ,DWORD, :HWND, :DWORD, :DWORDCVIRTUAL  ModifyDesktopItem ,DWORD, :DWORD, :DWORDCVIRTUAL  RemoveDesktopItem ,DWORD, :DWORD, :DWORDCVIRTUAL  GetDesktopItemCount ,DWORD, :LPINT, :DWORDCVIRTUAL  GetDesktopItem ,DWORD, :DWORD, :DWORD, :DWORDCVIRTUAL  GetDesktopItemByID ,DWORD, :PTR, :DWORD, :DWORDCVIRTUAL  GenerateDesktopItemHtml ,DWORD, :PTR, :DWORD, :DWORDCVIRTUAL  AddUrl ,DWORD, :DWORD, :PTR, :DWORD, :DWORDCVIRTUAL  GetDesktopItemBySource ,DWORD, :PTR, :DWORD, :DWORDENDCOMINTERFACE`
Code: [Select]
`.386.model flat,stdcalloption casemap:noneinclude     \masm32\include\windows.incinclude     \masm32\include\kernel32.incinclude     \masm32\include\ole32.incinclude     \masm32\macros\macros.asminclude     SetWallpaper.incincludelib  \masm32\lib\kernel32.libincludelib  \masm32\lib\ole32.libLPad TYPEDEF PTR IActiveDesktop.dataCLSID_IActiveDesktop    GUID sCLSID_IActiveDesktopIID_IActiveDesktop      GUID sIID_IActiveDesktopWSTR        DesktopImg,"test.bmp"pAD         LPad 0.data?wpo         WALLPAPEROPT <>.codestart:    invoke      CoInitialize,NULL    invoke      CoCreateInstance,ADDR CLSID_IActiveDesktop,NULL,\                 CLSCTX_INPROC_SERVER,ADDR IID_IActiveDesktop,ADDR pAD                mov         edx,OFFSET wpo    mov         WALLPAPEROPT.dwSize[edx],SIZEOF(WALLPAPEROPT)    mov         WALLPAPEROPT.dwStyle[edx],WPSTYLE_CENTER    pAD->SetWallpaper(OFFSET DesktopImg,0)    coinvoke    pAD,IActiveDesktop,SetWallpaper,OFFSET DesktopImg,0    coinvoke    pAD,IActiveDesktop,SetWallpaperOptions,OFFSET wpo,0    coinvoke    pAD,IActiveDesktop,ApplyChanges,AD_APPLY_ALL    coinvoke    pAD,IActiveDesktop,Release    invoke  CoUninitialize        invoke  ExitProcess,0END start`
The error message :

Code: [Select]
`SetWallpaper.asm(41) : Error A2049: Invalid instruction operands _VCOMINVOKE(10)[SetWallpaper.asm]: Macro called from  SetWallpaper.asm(41): Main line codeSetWallpaper.asm: 55 lines, 1 passes, 170 ms, 0 warnings, 1 errors`
Line 41 seems to be the problem :

Code: [Select]
`pAD->SetWallpaper(OFFSET DesktopImg,0)`
I would like test the arrow operator ( -> ) and the built-in macro _INVOKE in two different versions of the source code above.  How should I use the the _INVOKE macro to call COM methods in my example code?  Another question, can I use the structure IActiveDesktop instead of a COMINTERFACE definition while specifying the arrow operator or the _INVOKE macro?

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #37 on: December 11, 2017, 08:24:33 PM »
Hi,

I'll test out this example and see what the issue is with that line, I suspect it may be to do with using the OFFSET operator in the macro.

The pointer syntax (->) can only be used with OINTERFACE, CLASS and COMINTERFACE (internally these types are tracked as being different from regular structures and different from each other).

In the case of the ointerface or class the vtable exists inside the instance itself, where-as with com the object contains a pointer to the vtable. So the keep the syntax consistent it handles them differently by adding extra indirection in the case of COM. Using the ointerface or class with -> requires use of a vtable (OPTION VTABLE:ON) where-as for performance reasons if you have a class that you know is not going to be dynamically modified, and hence no reason to go via a vtable, with that off the call removes the extra indirection and goes straight to the method call.

I'll get back to you asap with a fix for the offset issue.

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #38 on: December 11, 2017, 08:37:41 PM »
On another note, the _V, _INVOKE and other macros that are built-in deal entirely with the OO features. COM having the extra indirection required slightly different handling so internally uses _VCOMINVOKE and _VCOM.

Assuming you don't wanted nested calls, then using _VCOMINVOKE or _INVOKE(for normal OO) is pretty straightforward as per the example in the manual and samples folder.

#### jj2007

• Member
• Posts: 8893
• Assembler is fun ;-)
##### Re: UASM 2.46 Release
« Reply #39 on: December 11, 2017, 10:59:23 PM »
The pointer syntax (->) can only be used with...

It's very unfortunate that the authors of MASM used the <> as a reserved word; same for the exclamation mark. OTOH, there was not so much choice: {any better?} ^or this^ %no good% §advocates need these§ @mail@ ...

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #40 on: December 12, 2017, 01:42:52 AM »
I know That's why i intentionally forced it's usage to be limited. In the normal situation with < > the tokenizer knows it's in a literal so <......-> is fine, but at least for now I'd like to keep such a major divergence from traditional asm syntax quite contained.

#### Vortex

• Member
• Posts: 1873
##### Re: UASM 2.46 Release
« Reply #41 on: December 12, 2017, 04:38:47 AM »
Hi johnsa,

This one produces a syntax error message :

Code: [Select]
` _INVOKE pAD,SetWallpaper,OFFSET DesktopImg,0`
Code: [Select]
`SetWallpaper.asm(41) : Error A2210: Syntax error: _INVOKE`
I could not find any reference to the _VCOMINVOKE macro in the manual uasm246_ext.pdf.  No example using this macro.

Assembling the example oo2.asm, I get the following error messages :

Code: [Select]
`uasm64 -win64 -c -Zp8 -Zi -Zd -Zf oo2.asmUASM v2.46, Dec  8 2017, Masm-compatible assembler.Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.Source code is available under the Sybase Open Watcom Public License.oo2.asm(37) : Error A2221: Missing macro argument: CVIRTUAL, parameter 2oo2.asm(38) : Error A2221: Missing macro argument: CVIRTUAL, parameter 2oo2.asm: 274 lines, 1 passes, 153 ms, 0 warnings, 2 errors`
To fix this issue, I modified the two lines below.

Code: [Select]
`OINTERFACE Entity CVIRTUAL PrintName CVIRTUAL SetNameENDOINTERFACE`
The corrected version :

Code: [Select]
`OINTERFACE Entity CVIRTUAL PrintName, <> CVIRTUAL SetName, <>ENDOINTERFACE`

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #42 on: December 12, 2017, 09:07:59 AM »
You are right about oo2.asm, I must have forgot to update that sample after adding the return type to CVIRTUAL. I've updated it myside so it's correct and will be in the next package update.

_INVOKE and _I are designed to bypass the VTABLE altogether, their syntax is as follows:
Code: [Select]
`_INVOKE MACRO className : REQ, method : REQ, objPtr : REQ, args : VARARG_I MACRO className : REQ, method : REQ, objPtr : REQ, args : VARARG`
_INVOKE would be for normal outer calls, and _I would be used inline.

Code: [Select]
`_INVOKE MyClass, MyMethod, pObj, ......`
The _V equivalents access the object through the vtable and have slightly different syntax:

Code: [Select]
`_VINVOKE MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG_V MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG_VINVOKE pObj, MyClass, MyMethod, ....`
I didn't include any references to VCOM or VCOMINVOKE in the documents as I didn't think anyone would call those directly / they are available.. but they're sort of "internal" to implement the COMINTERFACE and method invocation against it.

They're definitions are:

Code: [Select]
`_VCOMINVOKE MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG_VCOM MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG`
So basically the same as the vtable based OO functions (VINVOKE and V) but they perform a double indirection.

I will update the packages shortly with fixes.

#### johnsa

• Member
• Posts: 714
##### Re: UASM 2.46 Release
« Reply #43 on: December 12, 2017, 09:24:51 AM »
Packages are updated, oo2.asm is fixed and the 32bit COM call issue should be fixed.

#### Vortex

• Member
• Posts: 1873
##### Re: UASM 2.46 Release
« Reply #44 on: December 13, 2017, 06:08:04 AM »
Hi johnsa,

Thanks for the update. Here are the results of my tests.

Trying the _VCOMINVOKE macro :

Code: [Select]
`_VCOMINVOKE pAD,IActiveDesktop,SetWallpaper,ADDR DesktopImg,0_VCOMINVOKE pAD,IActiveDesktop,SetWallpaperOptions,OFFSET wpo,0_VCOMINVOKE pAD,IActiveDesktop,ApplyChanges,AD_APPLY_ALL_VCOMINVOKE pAD,IActiveDesktop,Release`
Uasm is assembling my code without any error messages but the executable is crashing on Windows 7.

Investigating the case with the /EP option :

Code: [Select]
`uasm32.exe /EP /c /coff SetWallpaper.asm`
Code: [Select]
`mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_SetWallpaperPto PTR[eax].IActiveDesktop.SetWallpaper), pAD, ADDR DesktopImg,0mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_SetWallpaperOptionsPto PTR[eax].IActiveDesktop.SetWallpaperOptions), pAD, OFFSET wpo,0mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_ApplyChangesPto PTR[eax].IActiveDesktop.ApplyChanges), pAD, AD_APPLY_ALLmov eax, pADmov eax,[eax]invoke(_IActiveDesktop_ReleasePto PTR[eax].IActiveDesktop.Release), pAD`
The pAD parameter should not be pushed to the stack.

Disassembling the object file with objconv :

Code: [Select]
` _VCOMINVOKE    pAD,IActiveDesktop,SetWallpaper,ADDR DesktopImg,0`
Code: [Select]
`mov     eax, dword ptr [_pAD]                   mov     eax, dword ptr [eax]                    push    0                                       push    offset _DesktopImg                      push    dword ptr [_pAD] ; <--- This line causing problemcall    dword ptr [eax+14H]`
Assuming that _VCOM is equivalent to _VCOMINVOKE :

Code: [Select]
`_VCOMINVOKE MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG_VCOM MACRO pInterface : REQ, Interface : REQ, Function : REQ, args : VARARG`
Replacing _VCOMINVOKE  with  _VCOM :

Code: [Select]
`SetWallpaper.asm(41) : Error A2210: Syntax error: _VCOMSetWallpaper.asm(43) : Error A2210: Syntax error: _VCOMSetWallpaper.asm(45) : Error A2210: Syntax error: _VCOMSetWallpaper.asm(47) : Error A2210: Syntax error: _VCOMSetWallpaper.asm: 53 lines, 1 passes, 4 ms, 0 warnings, 4 errors`
Testing the arrow operator with OPTION VTABLE:ON and OPTION VTABLE:OFF

Code: [Select]
`pAD->SetWallpaper(OFFSET DesktopImg,0)pAD->SetWallpaperOptions(OFFSET wpo,0)pAD->ApplyChanges(AD_APPLY_ALL)pAD->Release()`
pAD is again pushed to the stack :

Code: [Select]
`mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_SetWallpaperPto PTR[eax].IActiveDesktop.SetWallpaper), pAD, OFFSET DesktopImg,0mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_SetWallpaperOptionsPto PTR[eax].IActiveDesktop.SetWallpaperOptions), pAD, OFFSET wpo,0mov eax, pADmov eax,[eax]invoke(_IActiveDesktop_ApplyChangesPto PTR[eax].IActiveDesktop.ApplyChanges), pAD, AD_APPLY_ALLmov eax, pADmov eax,[eax]invoke(_IActiveDesktop_ReleasePto PTR[eax].IActiveDesktop.Release), pAD`