inline assembly function

I am looking for a possibility to create an inline assembly function. The hole function, not just inline assembly in a function. (IDE: Microsoft Visual C++ 2008 Express Edition).
If tried the following code, but it doesn't work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int my_func(unsigned char a);
__asm {
   PUBLIC my_func
   _TEXT SEGMENT
   my_func PROC
   mov eax, byte ptr 8[ebp]
   cmp eax, 6
   je L1
   inc eax
L1:
   ret 0
   my_func ENDP
   _TEXT ENDS
}

What do I have to correct?
Digging back in my memory- I remember something called naked functions.
There is info on how to use them in the Visual c++ help (or you can find the info
on msdn http://msdn.microsoft.com/en-us/library/21d5kd3a(VS.80).aspx
Thank you very much! This is exactly what I needed.
But now another problem popped up and I couldn't find any solutions with google or in the msdn library.
I need to shift right and shift left a variable in my inline assembler.
Visual C++ uses __aullshr. The compiler says undefined reference to __aullshr, but I can't find its definition. Do you maybe know where I can find it, becaus I doubt my own __aullshr would be as fast as the original?

EDIT:
Maybe I was just tired... here the solution for anybody who can use it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__inline __declspec(naked) unsigned long long shl64(unsigned long long a){
 __asm {
  push ebp
  mov ebp, esp
  sub esp, __LOCAL_SIZE
  mov eax, DWORD PTR 8[ebp]
  mov edx, DWORD PTR 8[ebp+4]
  shl eax, 1
  rcl edx, 1
  mov esp, ebp
  pop ebp
  ret
 }
}
__inline __declspec(naked) unsigned long long shr64(unsigned long long a){
 __asm {
  push ebp
  mov ebp, esp
  sub esp, __LOCAL_SIZE
  mov eax, DWORD PTR 8[ebp]
  mov edx, DWORD PTR 8[ebp+4]
  shr edx, 1
  rcr eax, 1
  mov esp, ebp
  pop ebp
  ret
 }
}
Last edited on
Topic archived. No new replies allowed.