I have to write some asm("code") in C using CodeBlocks. I need to increment input value 'a' by one and then power the result like this a * a * a. Where incrementing and power value a*a is easy, the another power powers the result of previous power. For ex. 2 * 2=4 then 4 * 4=16 My current code:
#include <stdio.h>
#include <stdlib.h>
int main(){
short int a,b;
scanf("%hu",&a);
asm("mov %1, %%ax\n\t"
"inc %%ax\n"
"mul %%ax\n"
"mov %%ax, %0"
:"=r" (a)
:"r" (a), "r" (b)
);
printf("%d\n", a);
return 0;
}