Login Register






Assembly as a first language? filter_list
Author
Message
RE: Assembly as a first language? #12
Okay so here's an example I just cribbed from Uncle Google:

Spin up Visual c++, create a console project and cut and paste the following code in. Then you can put breakpoints in it and step through it to see what it's doing.

(Puts on flame jacket - yeah I know it's lame as fuck but it's an example of how a total beginner could do it...)

Following code will *work*....

#include <stdio.h>
#include <stdafx.h>

int power2(int num, int power);

int main(void)
{
printf_s("3 times 2 to the power of 5 is %d\n", \
power2(3, 5));
}
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
}

Reply





Messages In This Thread
Assembly as a first language? - by Dr. Keter - 01-11-2017, 01:07 AM
RE: Assembly as a first language? - by meow - 01-11-2017, 01:13 AM
RE: Assembly as a first language? - by Hoss - 01-12-2017, 01:38 AM
RE: Assembly as a first language? - by meow - 01-12-2017, 01:39 AM
RE: Assembly as a first language? - by Hoss - 01-12-2017, 01:42 AM
RE: Assembly as a first language? - by meow - 01-12-2017, 01:44 AM
RE: Assembly as a first language? - by Inori - 01-11-2017, 01:23 AM
RE: Assembly as a first language? - by insidious - 01-11-2017, 08:01 AM
RE: Assembly as a first language? - by Nil - 01-12-2017, 06:27 AM
RE: Assembly as a first language? - by Blink - 01-14-2017, 01:24 AM
RE: Assembly as a first language? - by 0x6f776c - 07-22-2017, 03:33 PM
RE: Assembly as a first language? - by PhargedPhreak - 02-27-2017, 07:39 AM
RE: Assembly as a first language? - by m0dem - 02-27-2017, 03:48 PM
RE: Assembly as a first language? - by Skullmeat - 02-27-2017, 06:04 PM
RE: Assembly as a first language? - by titbang - 08-13-2017, 05:50 AM
RE: Assembly as a first language? - by RubyRose - 08-26-2021, 08:08 PM
RE: Assembly as a first language? - by valentine - 03-12-2022, 07:03 PM
RE: Assembly as a first language? - by Chloris - 05-10-2023, 10:21 PM
RE: Assembly as a first language? - by vekm - 10-07-2023, 06:28 AM
RE: Assembly as a first language? - by anonim6 - 12-06-2023, 05:18 AM
RE: Assembly as a first language? - by asd313as - 12-06-2023, 05:43 AM