در زیر براتون برنامه ای رو آماده کردم که یک عدد رو به توان عدد دیگه میرسونه و این تابع رو با استفاده از کد اسمبلی در محیط سی پلاس پلاس قرار دادم و در محیط ویژوال استادیو ورژن 10 تست و اجرا شد.
کد:
// test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int power2( int num, int power );
int main( void )
{
cout<< "3 times 2 to the power of 5 is "<< power2( 3, 5) ;
getch();
return 0;
}
int power2( int num, int power )
{
__asm
{
mov eax, num ; Get first argument
mov ecx, power ; Get second argument
shl eax, cl ; EAX = EAX * ( 2 to the power of CL )
}
// Return with result in EAX
}