Thread: X64 inline asm
View Single Post
Old 04-22-2010, 21:31
rox rox is offline
Join Date: Dec 2009
Posts: 16
Rept. Given: 1
Rept. Rcvd 2 Times in 2 Posts
Thanks Given: 0
Thanks Rcvd at 2 Times in 2 Posts
rox Reputation: 2
just so you know - MS did not implement inline asm in x64 because it is 'unsafe'. apparently they are very concerned about noobs who have no clue what they are doing. they did same with default values for methods in c# - no such thing there because 'it might confuse programmer'.

regarding inline asm 'black box' theory - is all crap. i made a testcase just to see this, because it even sounds so much unreasonable.

00FD1045  sub         edi,1 
	while(i != 0)
00FD1048  jne         main+22h (0FD1022h) 

	__asm xor ebx, ebx	// should be restored after asm block
00FD104A  xor         ebx,ebx 

	char naughtyNumber[255];
	itoa(a + b, naughtyNumber, 16);
00FD104C  push        10h  
00FD104E  lea         eax,[esp+10h] 
00FD1052  push        eax  
00FD1053  add         esi,ecx 
00FD1055  push        esi  
00FD1056  call        _itoa (0FD7258h) 
00FD105B  add         esp,0Ch
as you see i xored ebx and compiler has no intention to restore it. now maybe i am missing something.. but ebx is non-volatile register - if msvc compiler really did 'black box' tricks then register should be restored.
Reply With Quote
The Following User Says Thank You to rox For This Useful Post:
Indigo (07-19-2019)