Shl eax, cl EAX = EAX * ( 2 to the power of CL ) Printf_s( "3 times 2 to the power of 5 is %d\n", \ This program writes the power2 function with inline assembly code: // Power2_inline_asm.c (The MODEL directive, available in MASM and some other assemblers, also allows you to access stack arguments and local stack variables by name.) Example C and C++ function arguments are usually passed on the stack, so this version of the power2 function accesses its arguments by their positions on the stack. Since it's written as a separate assembler file, the function requires separate assembly and link steps. Mov ebp, esp Move ESP into EBP so we can refer Command line: ml /c /Cx /W3 /WX power2.asm As a separate assembler file, the function might look like this: power2.asm The function, called power2, receives two parameters, multiplying the first parameter by 2 to the power of the second parameter. The following examples compare a function first written for a separate assembler and then rewritten for the inline assembler. If you write a function with inline assembly code, it's easy to pass arguments to the function and return a value from it. For similar functionality in 圆4 or ARM64 code, use compiler intrinsics. Inline assembly is only available for x86 targets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |