Compare commits
No commits in common. "dev" and "Klyvets" have entirely different histories.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"user": "borysr",
|
||||
"email": "borysr@gmail.com",
|
||||
"user": "vladk",
|
||||
"email": "vladk@gmail.com",
|
||||
"remotes": [
|
||||
{
|
||||
"name": "r",
|
||||
|
@ -8,7 +8,7 @@
|
|||
"domain": "qstack.pl",
|
||||
"port": "3000",
|
||||
"token_name": "t",
|
||||
"token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06",
|
||||
"token": "72758cfb9fd9ca44e11325e42e2a07def1316511",
|
||||
"group": "1i-2023",
|
||||
"project": "homework"
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,81 +0,0 @@
|
|||
|
||||
ARCH=riscv64-unknown-elf
|
||||
GNU_DIR=$(HOME)/riscv/riscv/
|
||||
GNU_BIN=$(GNU_DIR)/bin
|
||||
|
||||
|
||||
CC=$(GNU_BIN)/$(ARCH)-gcc
|
||||
CXX=$(GNU_BIN)/$(ARCH)-g++
|
||||
AS=$(GNU_BIN)/$(ARCH)-as
|
||||
LD=$(GNU_BIN)/$(ARCH)-ld
|
||||
OBJCOPY=$(GNU_BIN)/$(ARCH)-objcopy
|
||||
OBJDUMP=$(GNU_BIN)/$(ARCH)-objdump
|
||||
SIZE=$(GNU_BIN)/$(ARCH)-size
|
||||
AR=$(GNU_BIN)/$(ARCH)-ar
|
||||
RANLIB=$(GNU_BIN)/$(ARCH)-ranlib
|
||||
|
||||
|
||||
CFLAGS+=-ffreestanding
|
||||
CFLAGS+=-fno-pic
|
||||
CFLAGS+=-march=rv32i -mabi=ilp32
|
||||
CFLAGS+= -g
|
||||
|
||||
|
||||
LDFLAGS+=-nostdlib
|
||||
LDFLAGS+=-Wl,-Ttext=0x00000000
|
||||
|
||||
# see: https://github.com/riscv/riscv-gcc/issues/120
|
||||
#LDFLAGS+=-Wl,--no-relax
|
||||
|
||||
|
||||
|
||||
ASFLAGS+=$(CFLAGS)
|
||||
CXXFLAGS+=$(CFLAGS)
|
||||
|
||||
CLEAN_DIRS=$(SUBDIRS:%=clean-%)
|
||||
ALL_DIRS=$(SUBDIRS:%=all-%)
|
||||
|
||||
OBJDUMPFLAGS+=-Mnumeric,no-aliases
|
||||
|
||||
.PHONY: all clean world $(CLEAN_DIRS) $(ALL_DIRS)
|
||||
|
||||
|
||||
%.bin : %
|
||||
$(OBJCOPY) $< -O binary $@
|
||||
|
||||
%.lst : %
|
||||
$(OBJDUMP) $(OBJDUMPFLAGS) -dr --disassemble-all $< > $<.lst
|
||||
|
||||
% : %.o
|
||||
$(LINK.cc) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
||||
$(SIZE) -x -A $@
|
||||
|
||||
%.s: %.c
|
||||
$(COMPILE.c) -S -o $@ $<
|
||||
|
||||
%.s: %.cc
|
||||
$(COMPILE.cc) -S -o $@ $<
|
||||
|
||||
%.o: %.c
|
||||
$(COMPILE.c) -o $@ $<
|
||||
|
||||
%.o: %.cc
|
||||
$(COMPILE.cc) -o $@ $<
|
||||
|
||||
%.srec: %
|
||||
$(OBJCOPY) $< -O srec $@
|
||||
|
||||
|
||||
|
||||
|
||||
all:: $(ALL_DIRS)
|
||||
|
||||
clean:: $(CLEAN_DIRS)
|
||||
|
||||
$(ALL_DIRS)::
|
||||
$(MAKE) -C $(@:all-%=%) all
|
||||
|
||||
$(CLEAN_DIRS)::
|
||||
$(MAKE) -C $(@:clean-%=%) clean
|
||||
|
||||
world:: clean all
|
|
@ -1,42 +0,0 @@
|
|||
.text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
|
||||
_start:
|
||||
# Initialize global pointer
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
|
||||
li sp, 0x1fff0
|
||||
|
||||
# Clear the bss segment
|
||||
la a0, __bss_start
|
||||
la a1, __BSS_END__
|
||||
|
||||
clear_bss:
|
||||
bgeu a0, a1, finish_bss
|
||||
sb x0, 0(a0)
|
||||
addi a0, a0, 1
|
||||
beq x0, x0, clear_bss
|
||||
finish_bss:
|
||||
|
||||
nop //!
|
||||
|
||||
call main
|
||||
|
||||
nop //!
|
||||
|
||||
# abort execution here
|
||||
ebreak
|
||||
|
||||
.section .rodata
|
||||
alfabet:
|
||||
.string "abcdefghijklmnopqrstuwxyz"
|
||||
slowo:
|
||||
|
||||
.section .data
|
||||
wynik:
|
||||
.string "mpabi"
|
||||
.space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0
|
|
@ -1,39 +0,0 @@
|
|||
.text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
|
||||
_start:
|
||||
# Initialize global pointer
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
|
||||
# Initialize stack pointer from linker script symbol
|
||||
la sp, __stack_top
|
||||
|
||||
# Clear the BSS segment
|
||||
la a0, __bss_start
|
||||
la a1, __bss_end
|
||||
|
||||
clear_bss:
|
||||
bgeu a0, a1, finish_bss
|
||||
sb x0, 0(a0)
|
||||
addi a0, a0, 1
|
||||
j clear_bss
|
||||
finish_bss:
|
||||
|
||||
call main
|
||||
|
||||
ebreak
|
||||
|
||||
.section .rodata
|
||||
|
||||
alfabet:
|
||||
.string "abcdefghijklmnopqrstuwxyz"
|
||||
slowo:
|
||||
|
||||
.section .data
|
||||
wynik:
|
||||
.string "mpabi"
|
||||
.space 26 # rezerwuje 26 bajtów dla wyniku, zainicjowane na 0
|
Binary file not shown.
152
cpp/_rvmain.cpp
152
cpp/_rvmain.cpp
|
@ -7,157 +7,15 @@ int strlen(char *s) {
|
|||
return p - s;
|
||||
}
|
||||
|
||||
|
||||
void strcpy(char *s, char *t)
|
||||
{
|
||||
while (*s++ = *t++);
|
||||
}
|
||||
#define ALLOCSIZE 10000
|
||||
|
||||
static char allocbuf[ALLOCSIZE];
|
||||
static char *allocp = allocbuf;
|
||||
|
||||
char *alloc(int n)
|
||||
{
|
||||
|
||||
if (n % 4 != 0) {
|
||||
n += 4 - (n % 4);
|
||||
}
|
||||
|
||||
|
||||
if (allocbuf + ALLOCSIZE - allocp >= n) {
|
||||
allocp += n;
|
||||
return allocp - n;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// def. model danych
|
||||
|
||||
//pre processor
|
||||
#define LEN (8+2)*10
|
||||
|
||||
struct model {
|
||||
char * str;
|
||||
uint32_t len ;
|
||||
};
|
||||
|
||||
|
||||
//alg
|
||||
// prosta implementacji func. z bibl. std. strok przy uzyciu gpt3.5
|
||||
//
|
||||
|
||||
#define NULL ((void*) 0)
|
||||
|
||||
//
|
||||
// Funkcja pomocnicza do sprawdzania, czy znak jest wśród delimiterów
|
||||
bool is_delim(char c, const char *delims) {
|
||||
while (*delims) {
|
||||
if (c == *delims) {
|
||||
return true;
|
||||
}
|
||||
delims++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Najprostsza implementacja funkcji strtok
|
||||
char *simple_strtok(char *str, const char *delims) {
|
||||
static char *static_str = (char *) NULL; // Przechowuje wskaźnik do bieżącej pozycji w ciągu
|
||||
|
||||
// Jeśli przekazano nowy ciąg, zaktualizuj static_str
|
||||
if (str == NULL) {
|
||||
return (char *) NULL; // str nie wskazuje na zdanie !!!
|
||||
}
|
||||
static_str = str;
|
||||
|
||||
// " .,mpabi"
|
||||
// ^
|
||||
|
||||
// Pomiń początkowe delimitery
|
||||
while (*static_str && is_delim(*static_str, delims)) {
|
||||
static_str++;
|
||||
}
|
||||
|
||||
// Jeśli doszliśmy do końca ciągu, zwróć NULL
|
||||
if (*static_str == '\0') {
|
||||
return (char *) NULL;
|
||||
}
|
||||
|
||||
// Zapisz początek tokenu
|
||||
char *token_start = static_str;
|
||||
|
||||
// Znajdź koniec tokenu
|
||||
while (*static_str && !is_delim(*static_str, delims)) {
|
||||
static_str++;
|
||||
}
|
||||
|
||||
// Jeśli znaleziono delimitery, zamień je na '\0' i zaktualizuj static_str
|
||||
if (*static_str) {
|
||||
*static_str = '\0';
|
||||
static_str++;
|
||||
}
|
||||
|
||||
// Zwróć początek tokenu
|
||||
return token_start;
|
||||
}
|
||||
|
||||
char buf[100];
|
||||
struct model * p = (struct model *) buf; //p[1]
|
||||
////func alg
|
||||
//in: ptr to date
|
||||
//return: count of words
|
||||
int alg (const char * ptr) {
|
||||
|
||||
char bufer[ALLOCSIZE];
|
||||
strcpy(bufer, (char *)ptr);
|
||||
|
||||
const char *delims = " ,.!?:;\n\t";
|
||||
|
||||
int8_t count = 0;
|
||||
|
||||
char *token = simple_strtok(bufer, delims);
|
||||
|
||||
while (token != (char *)NULL) {
|
||||
|
||||
p[count].str = token;
|
||||
p[count].len = strlen(token);
|
||||
|
||||
token = simple_strtok((char *)NULL, delims);
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int main () {
|
||||
|
||||
char *str = "If wantered relation no surprise of all";
|
||||
char *ptr1 = "Vladyslav";
|
||||
char *ptr2 = "Klyvets";
|
||||
|
||||
alg(str);
|
||||
asm ("nop");
|
||||
int8_t name = strlen(ptr1);
|
||||
int8_t surname = strlen(ptr2);
|
||||
int8_t all = name + surname;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// wynik tego kodu:
|
||||
// p[0].str = If
|
||||
// p[0].len = 2
|
||||
|
||||
// p[1].str = wantered
|
||||
// p[1].len = 8
|
||||
|
||||
// p[2].str = relation
|
||||
// p[2].len = 8
|
||||
|
||||
// p[3].str = no
|
||||
// p[3].len = 2
|
||||
|
||||
// p[4].str = surprise
|
||||
// p[4].len = 8
|
||||
|
||||
// p[5].str = of
|
||||
// p[5].len = 2
|
||||
|
||||
// p[6].str = all
|
||||
// p[6].len = 3
|
||||
|
|
Binary file not shown.
|
@ -1,43 +0,0 @@
|
|||
MEMORY
|
||||
{
|
||||
RAM (wx) : ORIGIN = 0x0, LENGTH = 128K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
} > RAM
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data*)
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
} > RAM
|
||||
|
||||
/* Add stack at the end of RAM */
|
||||
. = ALIGN(4);
|
||||
_end = .;
|
||||
PROVIDE(end = .);
|
||||
|
||||
/* Define stack size and location */
|
||||
_stack_size = 0x4000; /* Example stack size: 16KB */
|
||||
_stack_end = ORIGIN(RAM) + LENGTH(RAM); /* End of RAM */
|
||||
_stack_start = _stack_end - _stack_size; /* Calculate start of the stack */
|
||||
.stack (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = . + _stack_size;
|
||||
. = ALIGN(4);
|
||||
_sp = .;
|
||||
} > RAM
|
||||
|
||||
PROVIDE(__stack = _sp);
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/* Linker script for a system with 128KB RAM starting at 0x10000 */
|
||||
MEMORY
|
||||
{
|
||||
RAM (wx) : ORIGIN = 0x0000, LENGTH = 128K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Place code and readonly data at the beginning of RAM */
|
||||
.text :
|
||||
{
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
} > RAM
|
||||
|
||||
/* Place initialized data right after the .text section */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.data*)
|
||||
} > RAM
|
||||
|
||||
/* Uninitialized data (BSS) follows initialized data */
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
} > RAM
|
||||
|
||||
/* Define heap start right after bss */
|
||||
. = ALIGN(4);
|
||||
__heap_start = .;
|
||||
PROVIDE(heap_start = __heap_start);
|
||||
|
||||
/* Leave space for the heap by not explicitly defining its end */
|
||||
/* The heap grows towards the stack */
|
||||
|
||||
/* Reserve space for the stack at the end of RAM */
|
||||
/* Let's say we want a 16KB stack */
|
||||
. = ALIGN(4);
|
||||
__stack_size = 16K; /* Size of the stack */
|
||||
__stack_top = ORIGIN(RAM) + LENGTH(RAM); /* Top of the stack */
|
||||
__stack_start = __stack_top - __stack_size; /* Start of the stack */
|
||||
.stack (NOLOAD) :
|
||||
{
|
||||
. = __stack_start;
|
||||
. += __stack_size; /* Allocate space for the stack */
|
||||
. = ALIGN(4);
|
||||
} > RAM
|
||||
|
||||
PROVIDE(__stack = __stack_top);
|
||||
PROVIDE(stack_top = __stack_top);
|
||||
PROVIDE(stack_start = __stack_start);
|
||||
|
||||
/* Heap end is dynamically located at the start of the stack */
|
||||
__heap_end = __stack_start;
|
||||
PROVIDE(heap_end = __heap_end);
|
||||
|
||||
/* End of RAM usage */
|
||||
. = ALIGN(4);
|
||||
_end = .;
|
||||
PROVIDE(end = _end);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
MEMORY
|
||||
{
|
||||
RAM (wx) : ORIGIN = 0x10000, LENGTH = 128K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text : { *(.text*) } > RAM
|
||||
.rodata : { *(.rodata*) } > RAM
|
||||
.data : { *(.data*) } > RAM
|
||||
.bss : { *(.bss*) } > RAM
|
||||
_end = .; /* Definiuje koniec sekcji danych, może być używane do określenia rozmiaru sterty */
|
||||
}
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -6,15 +6,15 @@ import os
|
|||
from datetime import datetime
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"user": "borysr",
|
||||
"email": "borysr@gmail.com",
|
||||
"user": "vladk",
|
||||
"email": "vladk@gmail.com",
|
||||
"remotes": [{
|
||||
"name": "r", # Zaktualizowano z "default" na "mpabi"
|
||||
"protocol": "http",
|
||||
"domain": "qstack.pl",
|
||||
"port": "3000",
|
||||
"token_name": "t",
|
||||
"token": "8ee3f1b7980197aeceadee3cf4d980f817d44f06",
|
||||
"token": "72758cfb9fd9ca44e11325e42e2a07def1316511",
|
||||
"group": "1i-2023",
|
||||
"project": "homework"
|
||||
}]
|
Loading…
Reference in New Issue