Repo init

This commit is contained in:
Jan Potocki
2020-06-22 17:31:00 +02:00
commit 5f9799c55c
11 changed files with 269 additions and 0 deletions
+13
View File
@@ -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
View File
@@ -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}
+16
View File
@@ -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;
}
+30
View File
@@ -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;
}
+35
View File
@@ -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;
}
+8
View File
@@ -0,0 +1,8 @@
.global timestamp
.type timestamp, %function
.text
timestamp:
isb
mrc p15, 0, r0, c9, c13, 0
mov pc, lr
+10
View File
@@ -0,0 +1,10 @@
all: hello
hello: hello.o
ld hello.o -o hello
hello.o: hello.s
as hello.s -o hello.o
clean:
rm hello.o hello
+21
View File
@@ -0,0 +1,21 @@
SYSEXIT = 1
SYSWRITE = 4
STDOUT = 1
.global _start
.data
str: .ascii "Hello world!\n"
str_len = . - str
.text
_start:
mov r7, #SYSWRITE
mov r0, #STDOUT
ldr r1, =str
mov r2, #str_len
swi 0x0
mov r7, #SYSEXIT
mov r0, #0
swi 0x0
+7
View File
@@ -0,0 +1,7 @@
all: mul_arm
mul_arm: mul.s
gcc mul.s -o mul_arm
clean:
rm mul_arm
+103
View File
@@ -0,0 +1,103 @@
SYSEXIT = 1
SYSREAD = 3
SYSWRITE = 4
STDIN = 0
STDOUT = 1
num_length = 256
word_length = 4
buf_length = num_length * 2
num_words = num_length / word_length
buf_words = buf_length / word_length
.global main
.bss
num1: .space num_length
num2: .space num_length
result: .space buf_length
.text
main:
loop:
mov r7, #SYSREAD
mov r0, #STDIN
ldr r1, =num1
mov r2, #buf_length
swi 0x0
cmp r0, #buf_length
blt end
ldr r8, =num1
ldr r9, =num2
ldr r10, =result
eor r0, r0, r0
eor r4, r4, r4
zero:
str r0, [r10, r4, lsl#2]
add r4, r4, #1
cmp r4, #buf_words
blt zero
eor r4, r4, r4
loop1:
eor r11, r11, r11
eor r12, r12, r12
eor r2, r2, r2
eor r5, r5, r5
loop2:
ldr r0, [r8, r4, lsl#2]
ldr r3, [r9, r5, lsl#2]
umull r0, r1, r0, r3
msr apsr_nzcvq, r11
adcs r0, r0, r2
mrs r11, apsr
mov r2, r1
add r6, r4, r5
msr apsr_nzcvq, r12
ldr r1, [r10, r6, lsl#2]
adcs r1, r0, r1
str r1, [r10, r6, lsl#2]
mrs r12, apsr
add r5, r5, #1
cmp r5, #num_words
blt loop2
add r6, r6, #1
msr apsr_nzcvq, r11
adc r2, r2, #0
msr apsr_nzcvq, r12
ldr r1, [r10, r6, lsl#2]
adc r1, r1, r2
str r1, [r10, r6, lsl#2]
add r4, r4, #1
cmp r4, #num_words
blt loop1
mov r7, #SYSWRITE
mov r0, #STDOUT
ldr r1, =result
mov r2, #buf_length
swi 0x0
b loop
end:
mov r7, #SYSEXIT
mov r0, #0
swi 0x0
BIN
View File
Binary file not shown.