Exetools  

Go Back   Exetools > General > x64 OS

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2010, 23:10
jump jump is offline
VIP
 
Join Date: Jan 2009
Posts: 305
Rept. Given: 84
Rept. Rcvd 51 Times in 26 Posts
Thanks Given: 24
Thanks Rcvd at 41 Times in 27 Posts
jump Reputation: 51
Quote:
Originally Posted by Fyyre View Post
Hi all,

I discovered this for myself recently, and wanted to share. If this is already well known, disregard =)

The Intel C/C++ compiler add-on for Visual Studio will allow you to still use inline assembly language on the X64 platform. The syntax and such is close enough to MSVC that modifications needed to code to compile existing code with the Intel compiler are minimal at best, IMO.

-Fyyre
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
Reply With Quote
The Following User Says Thank You to jump For This Useful Post:
Indigo (07-19-2019)
  #2  
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: 296
Rept. Given: 106
Rept. Rcvd 94 Times in 44 Posts
Thanks Given: 204
Thanks Rcvd at 406 Times in 131 Posts
Fyyre Reputation: 94
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)
  #3  
Old 04-09-2010, 16:08
jump jump is offline
VIP
 
Join Date: Jan 2009
Posts: 305
Rept. Given: 84
Rept. Rcvd 51 Times in 26 Posts
Thanks Given: 24
Thanks Rcvd at 41 Times in 27 Posts
jump Reputation: 51
So if i understand correct, the inline assmbler have to be also x64 not x86,right?
So you cant tak source with inline x86 assembler and think it will be compileable for x64 architecture. You have to rewrite it, right?

--
Jump
Reply With Quote
The Following User Says Thank You to jump For This Useful Post:
Indigo (07-19-2019)
  #4  
Old 04-11-2010, 15:32
Fyyre's Avatar
Fyyre Fyyre is offline
Fyyre
 
Join Date: Dec 2009
Location: 0°N 0°E / 0°N 0°E / 0; 0
Posts: 296
Rept. Given: 106
Rept. Rcvd 94 Times in 44 Posts
Thanks Given: 204
Thanks Rcvd at 406 Times in 131 Posts
Fyyre Reputation: 94
x86 or x64 depends upon your project (like Av0id said above).

Regarding re-writing of code, how big of task depends on the code itself...

i.e. the above strcmpW function, he only require change of registers from e*x to r*x....

AFAIK the calling covention always __fastcall on X64, more simple than x86 assembly, imo.

-Fyyre

Quote:
Originally Posted by jump View Post
So if i understand correct, the inline assmbler have to be also x64 not x86,right?
So you cant tak source with inline x86 assembler and think it will be compileable for x64 architecture. You have to rewrite it, right?
Jump
Reply With Quote
The Following User Says Thank You to Fyyre For This Useful Post:
Indigo (07-19-2019)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inline patche hp3 Source Code 3 06-04-2021 14:48
How to inline x64 asm in vs2017 ? Mahmoudnia General Discussion 25 07-22-2018 01:04
Inline Patching MaRKuS-DJM General Discussion 1 01-24-2004 23:03


All times are GMT +8. The time now is 19:37.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )