Author Topic: macros64 errors  (Read 130 times)

markallyn

  • Member
  • **
  • Posts: 63
macros64 errors
« on: September 26, 2017, 08:18:23 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 4809
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: macros64 errors
« Reply #1 on: September 26, 2017, 10:41:50 AM »
 :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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

markallyn

  • Member
  • **
  • Posts: 63
Re: macros64 errors
« Reply #2 on: September 26, 2017, 10:45:03 AM »
Hutch,

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

Mark

markallyn

  • Member
  • **
  • Posts: 63
Re: macros64 errors
« Reply #3 on: September 26, 2017, 11:57:46 PM »
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

  • Member
  • **
  • Posts: 63
Re: macros64 errors
« Reply #4 on: September 27, 2017, 12:08:53 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 4809
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: macros64 errors
« Reply #5 on: September 27, 2017, 04:27:27 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

markallyn

  • Member
  • **
  • Posts: 63
Re: macros64 errors
« Reply #6 on: September 27, 2017, 06:38:40 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 4809
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: macros64 errors
« Reply #7 on: September 27, 2017, 10:47:20 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin: