News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

macros64 errors

Started by markallyn, September 26, 2017, 08:18:23 AM

Previous topic - Next topic

markallyn

Hello everyone,

I searched the forum for this topic but came up empty handed.

I have been trying to include macros64.inc into a small project.  When I do I get error messages from the assembler regarding three symbols:  getattr, varsize, and regsize.  These occur in lines between 802 and 845 .

The include reads as follows:
    include \buildx64\macros64\macros64.inc

Has anyone else encountered this?

Mark Allyn




hutch--

 :biggrin:

Mark,

You did not read the post where you downloaded it from, rename the "buildx64" directory to "masm32" and use the line "    include \masm32\macros64\macros64.inc and it should find the include file.

markallyn

Hutch,

Thank you. That also answers a number of other questions I didn't ask!  Quite efficient.

Mark

markallyn

Good mornint, Hutch and everyone,

OK.  I renamed the directory as masm32 and ran the following program.
Quote
option casemap:none
include \masm32\include64\win64.inc
include \masm32\macros64\macros64.inc
include \masm32\include64\msvcrt.inc

includelib \masm32\include64\msvcrt.lib

.data
frmt1  BYTE "%s",0
msg1  BYTE "Darn it!  You can't mix c rt with windows",0

.code
main  PROC
sub  rsp, 30h
mov rcx, offset frmt1
mov  rdx, offset msg1
call  vc__cprintf
add  rsp, 30h
ret
main  ENDP
END

...and I get the same errors as mentioned in my original post.  Without the include macros line, the program assemble, links, and runs flawlessly. 

So, other suggestions?

Thanks again for the help.

Mark Allyn

markallyn

Hutch and all,

Furthermore, if I replace all my include and includelib statements with just a single "include \masm32\include64\masm64rt.inc" , everything works fine! 

As the incomparable Marvin Gaye memorably sang:  "What's goin on..."

Thanks,
Mark Allyn

hutch--

Mark,

Once you get used to how the project works, its a good idea to actually have a look at masm64rt.inc to see how it works. ML64 comes with no runtime at all and does not handle procedures correctly without a stackframe macro so you really need the macro file, just to get anything going.

With code like this,

    mov rcx, offset frmt1
    mov  rdx, offset msg1

you are better to use

    lea rcx, frmt1
    lea rdx, msg1


as OFFSET is not properly supported in 64 bit MASM.

markallyn

Hutch,

Yes, I am still on the learning curve, probably close to the origin!

Thanks for the info regarding OFFSET.  Is ADDR supported?

In a more recent version of this little program I used your INVOKE macro with ADDR and it ran perfectly.  I am half betting that you're going to tell me that ADDR is also a Macro!

Thanks,
Mark


hutch--

The ADDR notation is a component of the macro that "invoke" calls as is the capacity to use quoted string data in "invoke" calls. 64 bit MASM is basically an inhouse assembler that Microsoft need for their own purposes but it still retains the ancient macro engine which is an old pig but powerful enough if you can work around its bugs.

If you need an address put into a memory variable, there is a simple macro "ptr$()".

    ptr$ MACRO mem
      lea rax, mem
      EXITM <rax>
    ENDM

This allows you to use code like this.

  LOCAL ptrvar  :QWORD
  LOCAL buffer[64]:BYTE
...............
  mov ptrvar, ptr$(buffer)    ; store buffer address in QWORD pointer

You can do this manually with no problems.

  lea rax, var
  mov ptxt, rax

I use the macro form when writing high level code like API functions or library procedures as OS based code can be complex and messy and it de-clutters the interface where you are writing code.