Thread: X64 inline asm
View Single Post
  #7  
Old 04-09-2010, 10:56
Fyyre's Avatar
Fyyre Fyyre is offline
Fyyre
 
Join Date: Dec 2009
Location: 0°N 0°E / 0°N 0°E / 0; 0
Posts: 259
Rept. Given: 75
Rept. Rcvd 85 Times in 38 Posts
Thanks Given: 141
Thanks Rcvd at 335 Times in 113 Posts
Fyyre Reputation: 85
Quote:
Originally Posted by jump View Post
Very interesting news. I have read everywhere that inline assmbler isnt possible on x64 architecture.
Could you show us correct syntax for inline assembler which will Intel C++ Compiler accept ?

--
Jump
It is virtually the same as MSVC:

__asm mov rbx, rax;

or

__asm
{
...
}

emit format is:

__asm __emit 0xCC;

sample function:

Code:
__declspec(naked) int __fastcall strcmpW(const wchar_t *s1, const wchar_t *s2)
{
	__asm {
	push rdi
	push rsi
	mov rdi, rdx
	mov rsi, rcx
	or rcx, -1
	xor rax, rax
	repne scasw
	not rcx
	mov rdi, rdx
	repe cmpsw
	xor rdx, rdx
	mov ax, [rsi - 2]
	mov dx, [rdi - 2]
	sub rax, rdx
	pop rsi
	pop rdi
	ret
	}
}
Reply With Quote
The Following 2 Users Gave Reputation+1 to Fyyre For This Useful Post:
jump (04-09-2010)
The Following User Says Thank You to Fyyre For This Useful Post:
Indigo (07-19-2019)