64-Bit Compile Error (language type must be specified)

I am using the 64-bit version of the Visual C++ 7.1 libraries and build tools and I am receiving an error when compiling the assembly files which I have been unable to fix and am hoping that somebody will be able to tell me how to fix. The ML64.EXE compiler will not accept .586p or .model. I believe the language type needs to be in the PROC statement.

ml64.exe /c /Cx ".\asm\MD4_asm.asm"

Microsoft (R) Macro Assembler (AMD64) Version 8.00.40121

Copyright (C) Microsoft Corporation.All rights reserved.

Assembling: .\asm\MD4_asm.asm

.\asm\MD4_asm.asm(1) : error A2008: syntax error : .

.\asm\MD4_asm.asm(2) : error A2008: syntax error : .model

.\asm\MD4_asm.asm(178) : error A2119: language type must be specified

.\asm\MD4_asm.asm(180) : error A2008: syntax error : pusha

.\asm\MD4_asm.asm(238) : error A2008: syntax error : popa

NMAKE : fatal error U1077: 'ml64.exe' : return code '0x1'

Stop.

Line 1-2

.586p

.modelflat, C

Lines 178-183

MD4_Add_p5PROCPUBLIC, _this:DWORD, _Data:DWORD, _nLength:DWORD

pusha

__thistextequ<[esp+36]>; different offset due to pusha

__Datatextequ<[esp+40]>

__nLengthtextequ<[esp+44]>

[4641 byte] By [CyberGuy] at [2007-12-16]
# 1
the x64 assembler (ML64) does not accept many of the older x86 directives. All CPU model directives are not allowed as they dont make sense for 64bit code. Also, the model is now FLAT all the time as we dont need to worry about segmented memory. Also, be forwarned that the PROC/INVOKE directives currently do not automatically generate unwind directives...
RobertSanchez at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2

I userstand that, but even if I take out the .586p and .model flat, C, I still get the language type must be specified error.

CyberGuy at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3

there is no language types for x64 :-)

it was likely a bug that you got this error in the past. we have newer versions of the assembler which will not emit this error under ml64.

X64 only supports 1 calling convention for microsoft windows which is the x64 calling convention (hibred of fastcall). Thus, there is no language type to specify.

Also, pusha is not a valid opcode for 64bit processors.

I have this code...which assembles fine. if it doesnt work for you then you need an updated assembler.

.code

MD4_Add_p5 PROC PUBLIC, _this:DWORD, _nLength:DWORD

__this textequ <[esp+36]> ; different offset due to pusha
__nLength textequ <[esp+44]>
push rax

MD4_Add_p5 endp

end

RobertSanchez at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 4
Forget all x86 assembler diretives your mentioned. Don't use 3DNOW and MMX only SSE ( it's not debuggable under VS 2005 Whidbey ). All is fastcall to 4'th parameter ( after 4Th param you can call param directly from stack ):

;RAX Volatile Return value register.
;RCX Volatile First integer argument.
;RDX Volatile Second integer argument.
;R8 Volatile Third integer argument.
;R9 Volatile Fourth integer argument.
;R10:R11 Volatile Must be preserved as required by caller; used in syscall/sysret instructions.
;R12:R15 Nonvolatile Must be preserved by called function.
;RDI Nonvolatile Must be preserved by called function.
;RSI Nonvolatile Must be preserved by called function.
;RBX Nonvolatile Must be preserved by called function.
;RBP Nonvolatile Can be used as a frame pointer. Must be preserved by called function.
;RSP Nonvolatile Stack Pointer.
;XMM0 Volatile First FP argument.
;XMM1 Volatile Second FP argument.
;XMM2 Volatile Third FP argument.
;XMM3 Volatile Fourth FP argument.
;XMM4:XMM5 Volatile Must be preserved as required by caller.
;XMM6:XMM15 Nonvolatile Must be preserved as required by called function.
look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp

Project template:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Garfield 2005 - 2008
;
; History: 07/2005 initial development
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

include Include.inc

_CONST SEGMENT PARA 'CONST'
; const goes here
_CONST ENDS

_DATA SEGMENT PARA 'DATA'
; data here
_DATA ENDS

_TEXT SEGMENT PARA 'CODE'

;calling RCX, RDX, R8, R9
; pData -> RCX
; nSize -> RDX
; pData2 -> R8
; pData3 -> R9
; nCount -> Stack

ALIGN 16
PUBLIC Function
Function PROC pData: PTR, nSize: QWORD, pData2, pData3, nCount: WORD
PUSH RDI
PUSH RSI
PUSH RBX

; you can directly
MOV RBX, nCount

@END:
POP RBX
POP RSI
POP RDI
RET
Function ENDP

_TEXT ENDS
END
As i already posted plain asm optimization gives you under x64 only 5-15 percent speed advantage coz the x64 compiler generates heavy SSE-SSE2 code:
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=69060

I would only code in C coz the compiler uses SSE for you. C is much more readable than ASM.

Bye
Martin

maddinthegreat at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...