I have a C programme as follows:
#include<stdio.h>
int sum(int n)
{
int ret, i;
ret = 0;
for(i = 0; i < n; i++){
ret = ret + i;
}
return ret;
}
int main(void)
{
int n , s;
n = 7 + 1;
s = sum(n);
return 0;
}
After compiling, it's like:
global _sum
.text
_sum:
mov r44,sp
pushr r56
pushr r60
mov r56,0
mov r60,r56
jmp L5
L2:
add r56,r60
L3:
add r60,1
L5:
mov r24,r44
add r24,16
mov r24,[r24]
cmp r60,r24
jlt 6
jp 8
jmp L2
mov r40,r56
L1:
popr r60
popr r56
mov sp,r44
ret
global _main
_main:
start:
mov r44,sp
sub sp,8
mov r24,r44
add r24,-4+4
mov r20,8
mov [r24],r20
mov r24,r44
add r24,-4+4
mov r24,[r24]
pushr r24
pushr r44
call _sum
popr r44
add sp,4
mov r20,r44
add r20,-8+4
mov [r20],r40
mov r40,0
L7:
mov sp,r44
ret
Then, when i use nasm to assemble it, something wrong happened:
sum.asm:1: fatal: preprocessor directive `%rotate' not yet implemented
It tured out to be OK when I change it as follows:
[global _sum]
or:
;global _sum
My nasm version is 0.98, and I've changed some instructions.
I really don't know what to do.