-
Notifications
You must be signed in to change notification settings - Fork 0
/
c.cpp
70 lines (49 loc) · 1.15 KB
/
c.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//Copied from The Art of 64-bit Assembly by Randall Hyde
// https://www.randallhyde.com/#Main
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
extern "C"
{
void asmMain( void );
char *getTitle( void );
int readLine( char *dest, int maxLen );
};
int readLine( char *dest, int maxLen )
{
char *result = fgets( dest, maxLen, stdin );
if( result != NULL )
{
int len = strlen( result );
if( len > 0 )
{
dest[ len - 1 ] = 0;
}
return len;
}
return -1;
}
int main(void)
{
try
{
char *title = getTitle();
printf( "Calling %s:\n", title );
clock_t start = clock();
asmMain();
clock_t end = clock();
double elapsed_time = (end-start)/(double)CLOCKS_PER_SEC ;
printf("\n asmMain took %f time to run\n", elapsed_time);
printf( "%s terminated\n", title );
}
catch(...)
{
printf
(
"Exception occurred during program execution\n"
"Abnormal program termination.\n"
);
}
}