Author Topic: Asmc source and binaries  (Read 5486 times)

nidud

  • Member
  • *****
  • Posts: 1423
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #60 on: December 23, 2017, 08:02:27 AM »
Some more COM stuff.

Code: [Select]
- added support for Class::Method proto
- added support for Class::Method proc
- added support for Class::Method(...)
- added support for com_ptr[Vtbl].proc_ptr(...)

Class::Method proto Class@Method proto :ptr Class

The conflict between Class and ClassVtbl.

I remove the Vtbl structs in the Windows include files to simplify declarations and usage. On creation of new classes this may however not be a good idea but still possible.

Normal C declaration:
Code: [Select]
ClassVtbl struct
   Method()
ClassVtbl ends

Class struct
   lpVtbl PClassVtbl ?
Class ends

Alternate declaration:
Code: [Select]
Class union
struct
   lpVtbl PClassVtbl ?
ends
struct
   Method()
ends
Class ends

The assembler will now search for ClassVtbl when pointers are expanded and use it if available. Expansion of p.Method() will in the latter be [rax].Class.Method and [rax].ClassVtbl.Method in the former.

Well, it's a very spesific word this «Vtbl», but the implementation was also spesific: to target the C implementation of a COM interface. This in turn dictates the general rules for usage.

Code: [Select]
METHOD macro entry, args:vararg
    local __type, __ptr
    ifnb <args>
        __type typedef proto :ptr, &args
    else
        __type typedef proto :ptr
    endif
    __ptr typedef ptr __type
    entry __ptr ?
    endm

Use Class::Class(Class*) as constructor
Code: [Select]
DEFINE_CLASS macro Class, args:vararg
    P&Class& typedef ptr Class
    P&Class&Vtbl typedef ptr &Class&Vtbl
    ifnb <args>
        exitm<&Class&::&Class& proto :P&Class&, &args>
    else
        exitm<&Class&::&Class& proto :P&Class&>
    endif
    endm

Code: [Select]
DEFINE_CLASS(TWindow)

TWindowVtbl struct
    METHOD  IsInsideX, :SINT
    METHOD  IsInsideY, :SINT
    METHOD  IsInsideXY, :SINT, :SINT
    METHOD  Release
TWindowVtbl ends

TWindow struct
    lpVtbl  PTWindowVtbl ?

    Flags   UINT ?
    Window  PCHAR_INFO ?
    rc     SMALL_RECT <>
TWindow ends

Code: [Select]
TWindow::IsInsideX proc x:SINT

    xor eax,eax
    .repeat

        .break .if dx > [rcx].rc.Right
        .break .if dx < [rcx].rc.Left

        mov eax,edx
        sub ax,[rcx].rc.Left
        inc eax

    .until 1
    ret

TWindow::IsInsideX endp

TWindow::IsInsideXY proc x:SINT, y:SINT

    .if TWindow::IsInsideX(rcx, edx)
        TWindow::IsInsideY(rcx, r8d)
    .endif
    ret

TWindow::IsInsideXY endp

AssemblyChallenge

  • Member
  • **
  • Posts: 110
Re: Asmc source and binaries
« Reply #61 on: January 06, 2018, 12:55:32 AM »
Hi nidud.

I have been following your great work with Asmc. One thing I would like to see from your project is some sort of page and/or manual, something like the one from Uasm's guys.

The info included in Git/Readme, for example, is very short IMHO. In the first page of this post someone asked "What is Asmc?" and then you replied with some features (handling of strings, .SWITCH, etc). Could you please create some sort of PDF with all the details? I was tempted to simply copy/paste that post in a file but it would be -probably- incomplete as Asmc has a lot more under the hood.

Regards.

nidud

  • Member
  • *****
  • Posts: 1423
    • https://github.com/nidud/asmc
Re: Asmc source and binaries
« Reply #62 on: January 06, 2018, 02:13:13 AM »
The text you refer to is taken from the Asmc help file included in the package. In addition to this there are a few thousand ASM-files with test cases and samples including all extensions and features of the assembler.

AssemblyChallenge

  • Member
  • **
  • Posts: 110
Re: Asmc source and binaries
« Reply #63 on: January 06, 2018, 03:05:40 AM »
Let me spare some time -and embarrassment- to the newcomers of Asmc. The help file is located at:

asmc-master\source\asmc\asmc.chm

Thank you, I was looking everywhere... except in the source code :icon_redface:

AssemblyChallenge

  • Member
  • **
  • Posts: 110
Re: Asmc source and binaries
« Reply #64 on: January 12, 2018, 06:35:21 AM »
Hi Nidud.

After my adventures while trying Asmc and the cvpack.exe building error, maybe you should include that file in Asmc's tree, or perhaps explain in the help file that you must download it from Jwasm's site. I got this tip from good friend Ramon.

Regards.

PD: In my next project I will be using your compiler.