Wydanie R2020.05.1

This commit is contained in:
Jan Potocki
2020-05-09 22:17:22 +02:00
parent 8f4d0e843f
commit 0ba84bef75
11 changed files with 339 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
all: fibb_32 fibb_64 second
fibb_32: fibb_c.c fibb32.s timestamp32.s
gcc -m32 fibb32.s timestamp32.s fibb_c.c -o fibb_32
fibb_64: fibb_c.c fibb64.s timestamp64.s
gcc -no-pie fibb64.s timestamp64.s fibb_c.c -o fibb_64
second: second.c timestamp32.s
gcc -m32 timestamp32.s second.c -o second
clean:
rm fibb_32 fibb_64 second
+43
View File
@@ -0,0 +1,43 @@
# Jan Potocki 2020
.global fibb
# Segment kodu
.text
fibb:
push %ebp
mov %esp, %ebp
push %ebx
cmpl $0, 8(%ebp)
je zero
cmpl $1, 8(%ebp)
je jeden
movl 8(%ebp), %edx
dec %edx
push %edx
call fibb
pop %edx
mov %eax, %ebx
dec %edx
push %edx
call fibb
add $4, %esp
add %ebx, %eax
jmp wyjscie
zero:
mov $0, %eax
jmp wyjscie
jeden:
mov $1, %eax
wyjscie:
pop %ebx
pop %ebp
ret
+40
View File
@@ -0,0 +1,40 @@
# Jan Potocki 2020
.global fibb
# Segment kodu
.text
fibb:
push %rbp
mov %rsp, %rbp
push %rbx
cmp $0, %rdi
je zero
cmp $1, %rdi
je jeden
dec %rdi
push %rdi
call fibb
pop %rdi
mov %rax, %rbx
dec %rdi
call fibb
add %rbx, %rax
jmp wyjscie
zero:
mov $0, %rax
jmp wyjscie
jeden:
mov $1, %rax
wyjscie:
pop %rbx
pop %rbp
ret
+21
View File
@@ -0,0 +1,21 @@
#include <stdio.h>
unsigned long fibb(unsigned long n);
unsigned long long timestamp();
int main()
{
unsigned long term, result;
unsigned long long tstamp1, tstamp2;
scanf("%lu", &term);
tstamp1 = timestamp();
result = fibb(term);
tstamp2 = timestamp();
printf("%lu\n", result);
printf("Cycles: %llu\n", tstamp2-tstamp1);
return 0;
}
+20
View File
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <unistd.h>
// Jan Potocki 2020
unsigned long long timestamp();
int main()
{
unsigned long long tstamp1, tstamp2;
tstamp1 = timestamp();
sleep(1);
tstamp2 = timestamp();
printf("Cycles: %llu\n", tstamp2 - tstamp1);
return 0;
}
+13
View File
@@ -0,0 +1,13 @@
# Jan Potocki 2020
.global timestamp
# Segment kodu
.text
timestamp:
xor %eax, %eax
cpuid
rdtsc
ret
+16
View File
@@ -0,0 +1,16 @@
# Jan Potocki 2020
.global timestamp
# Segment kodu
.text
timestamp:
xor %rax, %rax
cpuid
rdtsc
shl $32, %rdx
or %rdx, %rax
ret