Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

[RESOLVED] File Extension ".S"

$
0
0
I'm trying to build a 64-bit library called libffi using MSVC. It contains a bunch of 'C' files and another file with the extension .S whose file contents seem to be mostly assembler - but with certain 'C' traits, such as #defines / #includes etc. The file contents look something like this:-

Code:

#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
       
/* Constants for ffi_call_win64 */       
#define STACK 0
#define PREP_ARGS_FN 32
#define ECIF 40
#define CIF_BYTES 48
#define CIF_FLAGS 56
#define RVALUE 64
#define FN 72

/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
                  extended_cif *ecif, unsigned bytes, unsigned flags,
                  unsigned *rvalue, void (*fn)());
 */

#ifdef _MSC_VER
PUBLIC        ffi_call_win64

EXTRN        __chkstk:NEAR
EXTRN        ffi_closure_win64_inner:NEAR

_TEXT        SEGMENT

;;; ffi_closure_win64 will be called with these registers set:
;;;    rax points to 'closure'
;;;    r11 contains a bit mask that specifies which of the
;;;    first four parameters are float or double
;;;
;;; It must move the parameters passed in registers to their stack location,
;;; call ffi_closure_win64_inner for the actual work, then return the result.
;;;
ffi_closure_win64 PROC FRAME
        ;; copy register arguments onto stack
        test        r11, 1
        jne        first_is_float       
        mov        QWORD PTR [rsp+8], rcx
        jmp        second
first_is_float:
        movlpd        QWORD PTR [rsp+8], xmm0

second:
        test        r11, 2
        jne        second_is_float       
        mov        QWORD PTR [rsp+16], rdx
        jmp        third
second_is_float:
        movlpd        QWORD PTR [rsp+16], xmm1

third:
        test        r11, 4
        jne        third_is_float       
        mov        QWORD PTR [rsp+24], r8
        jmp        fourth
third_is_float:
        movlpd        QWORD PTR [rsp+24], xmm2

// tons of other stuff

#endif

As you can see, the presence of #ifdef _MSC_VER creates the impression that it should be buildable with MSVC - but if I add it to a VS2015 project, VS2015 doesn't even seem to recognise it (clicking 'Properties' for the file simply says Does not participate in build).

I tried changing the file extension to .c but that didn't help either. I just got loads of compiler errors - starting with error C2061: syntax error: identifier 'ffi_call_win64' which occurs at the line I've indicated in blue.

What am I doing wrong :confused:

[Edit...] I think I'm starting to understand what's wrong... where I see the text:- Does not participate in build, I realised later that it's an entry in a drop-down list. If I go back to my previous compiler (VS2005) the relevant entry in that list box says:- Microsoft Macro Assembler. However, that option isn't present with VS2015 (Community Edition). Is the Macro Assembler an additional tool that I need to install separately? Or is assembly language just not supported in the Community Edition?

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images