Click here to Skip to main content
15,908,013 members
Home / Discussions / Hardware & Devices
   

Hardware & Devices

 
GeneralRe: Building c# pc remote control? Pin
Goalie352-Apr-08 19:11
Goalie352-Apr-08 19:11 
GeneralRe: Building c# pc remote control? Pin
Matthew Butler3-Apr-08 2:57
Matthew Butler3-Apr-08 2:57 
GeneralMonitor blur Pin
Mekong River31-Mar-08 17:19
Mekong River31-Mar-08 17:19 
GeneralRe: Monitor blur Pin
Sebastian Schneider2-Apr-08 5:00
Sebastian Schneider2-Apr-08 5:00 
GeneralRe: Monitor blur Pin
Mekong River3-Apr-08 0:11
Mekong River3-Apr-08 0:11 
GeneralRe: Monitor blur Pin
Dave Kreskowiak3-Apr-08 3:47
mveDave Kreskowiak3-Apr-08 3:47 
General_asm code Pin
ForNow31-Mar-08 14:33
ForNow31-Mar-08 14:33 
GeneralUsing and Preserving Registers in Inline Assembly Pin
Randor 1-Apr-08 16:42
professional Randor 1-Apr-08 16:42 
You do not need to worry about preserving eax, ebx, ecx, edx, esi, or edi registers with the recent versions of Microsoft Visual Studio. The compiler will generate code around your __asm blocks. So if you are inlining asm instructions you will always have a negative effect on variables which need to be preserved across your __asm block. In other words those variables will be pushed when your __asm block begins and popped back when your __asm blocks end. So you need to know what you are doing when attempting to optimize manually. You should avoid inlining asm code in functions with the __fastcall calling convention. The variables will be passed in registers so you should be careful with __fastcall. Or just avoid it altogether.

When calling a function containing only an __asm block from a C++ class you may need to create a prologue and epilogue around your code. If you don't it may result in your stack being corrupted. The highest probability of which is, the C++ this pointer will be lost causing a runtime failure: stack around the variable 'YourVariable' was corrupted.

A function which contains only an inline asm block should look something like:

__declspec(naked) int YourFunction(volatile long *)
{
	__asm
	{
		push ebp;
		mov ebp, esp;
		sub esp, __LOCAL_SIZE;
		//Your asm code here
		mov esp, ebp;
		pop ebp;
		ret;
      }
}


Note the __LOCAL_SIZE symbol. Which you can read about here:
http://msdn2.microsoft.com/en-us/library/aa273416(VS.60).aspx[^]

When writing inline assembly mixed with C/C++ code within the same function you also need to preserve the stack pointer registers esp, and ebp.

Here is the MSDN about inline assembly you can read more there.

http://msdn2.microsoft.com/en-us/library/4ks26t93(VS.80).aspx[^]

Best Wishes,
-David Delaune
GeneralRe: Using and Preserving Registers in Inline Assembly Pin
ForNow1-Apr-08 19:41
ForNow1-Apr-08 19:41 
GeneralAnything special prlouge __fastcall with _asm Pin
ForNow3-Apr-08 6:16
ForNow3-Apr-08 6:16 
GeneralRe: Anything special prlouge __fastcall with _asm Pin
Randor 7-Apr-08 17:37
professional Randor 7-Apr-08 17:37 
GeneralRe: Anything special prlouge __fastcall with _asm Pin
ForNow7-Apr-08 23:03
ForNow7-Apr-08 23:03 
GeneralRe: Using and Preserving Registers in Inline Assembly Pin
bob169726-Apr-08 7:39
bob169726-Apr-08 7:39 
GeneralRe: Using and Preserving Registers in Inline Assembly Pin
Randor 7-Apr-08 17:58
professional Randor 7-Apr-08 17:58 
GeneralRe: Using and Preserving Registers in Inline Assembly Pin
bob169728-Apr-08 3:29
bob169728-Apr-08 3:29 
QuestionWrite a function that will return the 5th element from the end ( not from the head of the list) in a singly linked list of integers, in one pass Pin
beyondjjw27-Mar-08 14:46
beyondjjw27-Mar-08 14:46 
GeneralRe: Write a function that will return the 5th ... Pin
Matthew Butler28-Mar-08 4:06
Matthew Butler28-Mar-08 4:06 
GeneralRe: Write a function that will return the 5th element from the end ( not from the head of the list) in a singly linked list of integers, in one pass Pin
Gary R. Wheeler29-Mar-08 0:28
Gary R. Wheeler29-Mar-08 0:28 
GeneralRe: Write a function that will return the 5th element from the end ( not from the head of the list) in a singly linked list of integers, in one pass Pin
Trollslayer3-Apr-08 12:38
mentorTrollslayer3-Apr-08 12:38 
GeneralDrive backup/transfer software Pin
hairy_hats27-Mar-08 6:27
hairy_hats27-Mar-08 6:27 
GeneralRe: Drive backup/transfer software Pin
Jörgen Andersson27-Mar-08 12:06
professionalJörgen Andersson27-Mar-08 12:06 
GeneralRe: Drive backup/transfer software Pin
hairy_hats28-Mar-08 0:14
hairy_hats28-Mar-08 0:14 
GeneralRe: Drive backup/transfer software Pin
code-frog28-Mar-08 3:54
professionalcode-frog28-Mar-08 3:54 
GeneralRe: Drive backup/transfer software Pin
hairy_hats29-Mar-08 15:11
hairy_hats29-Mar-08 15:11 
GeneralNDIS Driver Development Pin
Eakalavya25-Mar-08 22:40
Eakalavya25-Mar-08 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.