how to call a function called 'add' in ml64

Paul Moore 1 Reputation point
2025-04-23T19:08:10.48+00:00

How can I write assembler code that

  • defines, uses and maybe exports a function called, say, add
  • call out to a function called, say, add

This is not a problem for masm32 as all functions are really called _func , ie _add

But x64 calling convention retains the function snames

nasm can do this but as far as I can see ml64 cannot

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,912 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 121.3K Reputation points
    2025-04-23T19:38:39.92+00:00

    Try to use the ALIAS directive:

    .code
    
    ALIAS <add> = <myAdd>
    
    myAdd proc
    
        mov rax, rcx
        add rax, rdx
    
        ret
    
    myAdd endp
    
    end
    
    extern "C" int add( int a, int b );
    
    . . .
    
    int x = add( 10, 20 ); // result: 30
    

  2. Anton Demetri 0 Reputation points
    2025-04-24T07:47:14.5233333+00:00
    Swift
    
    0 comments No comments

Your answer