Author Topic: Trouble with file length under Win64  (Read 3690 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1805
    • EditMasm
Re: Trouble with file length under Win64
« Reply #30 on: February 13, 2021, 06:52:40 PM »
Quote
you're right. It was my thought error.
No!,if the error is here,this one is given by the modified msvcrt.
In 32 and 64 bits,the printf function (used by vc_printf) pass it's argument by values not by adress.
It is the vc_printf function who is wrong.
The sample(s) i have posted,use  the printf function and you can verify this.

Quote
printf PROTO cproto :XMASM , :VARARG
;cproto is c in 32 bits and fastcall in 64
Fa is a musical note to play with CL

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8497
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Trouble with file length under Win64
« Reply #31 on: February 13, 2021, 07:52:01 PM »
Yves,

If you bothered to look in the 32 bit "msvcrt.inc" file you would see how its done properly.

  ; ------------------------------------------
  ; prototypes for EXPORT msvcrt functions
  ; ------------------------------------------

    c_msvcrt typedef PROTO C :VARARG
........
    externdef _imp__printf:PTR c_msvcrt
    crt_printf equ <_imp__printf>

Calling the function still requires passing the right arguments to it.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TouEnMasm

  • Member
  • *****
  • Posts: 1805
    • EditMasm
Re: Trouble with file length under Win64
« Reply #32 on: February 13, 2021, 08:18:04 PM »

In the given sample in 64 bits,value is definad as follow:
Quote
Value              dq -1                 ; number to print
uint64_format      db "%I64u", 0         ; unsigned long long

using the official msvcrt and printf to show value,write it like that
Quote
invoke     printf, addr uint64_format,value,value            ;not addr value

Where is the error ?

Fa is a musical note to play with CL

Vortex

  • Member
  • *****
  • Posts: 2583
Re: Trouble with file length under Win64
« Reply #33 on: February 13, 2021, 08:43:40 PM »

using the official msvcrt and printf to show value,write it like that
Quote
invoke     printf, addr uint64_format,value,value            ;not addr value

Where is the error ?

That the correct way. Mentioned already in my message :

http://masm32.com/board/index.php?topic=9186.msg100864#msg100864

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Trouble with file length under Win64
« Reply #34 on: February 13, 2021, 08:46:08 PM »
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc ; ## builds in 32- or 64-bit mode with UAsm, ML, AsmC ##
MyQword dq 12345678901234567890
Init ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
  jinvoke crt_printf, Chr$("The value is %I64u"), MyQword
  Inkey Chr$(13, 10, 10, "This program was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format.")
EndOfCode

Code: [Select]
The value is 12345678901234567890

This program was assembled with ml64 in 64-bit format.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8497
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Trouble with file length under Win64
« Reply #35 on: February 13, 2021, 08:49:01 PM »
This is the correct prototype for 64 bit MASM.

externdef __imp_printf:PPROC
vc_printf equ <__imp_printf>

If Yves wants to use the C library, it involves any extra overhead from doing so. In 64 bit MASM the libraries DO NOT HAVE the linker argument count that the 32 bit versions have.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: