Repo init
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
all: fibb_arm fibb_ccnt sec_ccnt
|
||||
|
||||
fibb_arm: fibb_c.c fibb.s
|
||||
gcc fibb.s fibb_c.c -o fibb_arm
|
||||
|
||||
fibb_ccnt: fibb_ccnt.c fibb.s timestamp.s
|
||||
gcc fibb.s timestamp.s fibb_ccnt.c -o fibb_ccnt
|
||||
|
||||
sec_ccnt: sec_ccnt.c timestamp.s
|
||||
gcc sec_ccnt.c timestamp.s -o sec_ccnt
|
||||
|
||||
clean:
|
||||
rm fibb_arm fibb_ccnt sec_ccnt
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
.global fibb
|
||||
.type fibb, %function
|
||||
|
||||
.text
|
||||
fibb:
|
||||
push {r4, lr}
|
||||
|
||||
cmp r0, #0
|
||||
moveq r0, #0
|
||||
popeq {r4, pc}
|
||||
|
||||
cmp r0, #1
|
||||
moveq r0, #1
|
||||
popeq {r4, pc}
|
||||
|
||||
sub r0, r0, #1
|
||||
push {r0}
|
||||
bl fibb
|
||||
mov r4, r0
|
||||
pop {r0}
|
||||
|
||||
sub r0, r0, #1
|
||||
bl fibb
|
||||
add r0, r0, r4
|
||||
|
||||
pop {r4, pc}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// Jan Potocki 2020
|
||||
|
||||
unsigned long fibb(unsigned long n);
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned long term, result;
|
||||
|
||||
scanf("%lu", &term);
|
||||
result = fibb(term);
|
||||
printf("%lu\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// Jan Potocki 2020
|
||||
|
||||
unsigned long fibb(unsigned long n);
|
||||
unsigned long timestamp();
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned long term, result;
|
||||
unsigned long tstamp1, tstamp2;
|
||||
|
||||
scanf("%lu", &term);
|
||||
tstamp1 = timestamp();
|
||||
result = fibb(term);
|
||||
tstamp2 = timestamp();
|
||||
|
||||
printf("%lu\n", result);
|
||||
|
||||
if(tstamp2 > tstamp1)
|
||||
{
|
||||
printf("Cycles: %lu\n", tstamp2-tstamp1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Cycles: invalid measure\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
// Jan Potocki 2020
|
||||
|
||||
unsigned long timestamp();
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned long tstamp1, tstamp2;
|
||||
|
||||
tstamp1 = timestamp();
|
||||
|
||||
// Tego z jakiegos powodu nie mozna zrobic za pomoca sleep(1)...
|
||||
// ...cykle nie sa zliczane prawidlowo - wiec goraca petla
|
||||
clock_t t;
|
||||
do
|
||||
{
|
||||
t = clock();
|
||||
}
|
||||
while(t < CLOCKS_PER_SEC);
|
||||
|
||||
tstamp2 = timestamp();
|
||||
|
||||
if(tstamp2 > tstamp1)
|
||||
{
|
||||
printf("Cycles: %lu\n", tstamp2-tstamp1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Cycles: invalid measure\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
.global timestamp
|
||||
.type timestamp, %function
|
||||
|
||||
.text
|
||||
timestamp:
|
||||
isb
|
||||
mrc p15, 0, r0, c9, c13, 0
|
||||
mov pc, lr
|
||||
Reference in New Issue
Block a user