关于AT&T汇编与系统调用的问题
1.这是一个作业.
2.这是题目:
Writing an assembly program, like 'time', to record the executing time of other
process (usually its child process, use fork to create). 'int 0x80' is recommended to use
the system call.
$ mytimer ls -lR
1m2.560s
Requirement:
1. The program should run under Linux, BSD, UNIX etc. POSIX-based
operating systems.
2. AT&T assembly language style is required. ( different from Intel assembly
language style )
3. Don't use command, eg. 'time' 'date', etc., directly in the program by
system().
3.不是求作业答案的,只要给一个系统调用参数是struct的汇编调用例子.
4.我的想法是用gettimeofday完成.
5.这是我用C试写的
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
int main(){
struct timeval start,end;
gettimeofday(&start,NULL);
char str[50];
scanf("%[^\n]",str);
system(str);
gettimeofday(&end,NULL);
double time = end.tv_sec-start.tv_sec+(end.tv_usec-start.tv_usec)/1000000.0;
printf("time:%.3f\n",time);
return 0;
}
谢谢