forked from starnakin/IronGOLEM
Compare commits
No commits in common. "4bd9f50bd431ffbe07132c0f700265d7c3e17027" and "470b97446b6a864dc829f77d899195eaa506501b" have entirely different histories.
4bd9f50bd4
...
470b97446b
@ -26,7 +26,11 @@ define HEADER_SIZE = 5;
|
|||||||
🗿 Is used to check invalid write
|
🗿 Is used to check invalid write
|
||||||
🗿 If a case doesn't equal to 0 it is an invalid write
|
🗿 If a case doesn't equal to 0 it is an invalid write
|
||||||
|
|
||||||
enum LOCATION_INITIALISED, LOCATION_USED, LOCATION_SIZE, LOCATION_PREV, LOCATION_NEXT;
|
define LOCATION_INITIALISED = 0;
|
||||||
|
define LOCATION_USED = 1;
|
||||||
|
define LOCATION_SIZE = 2;
|
||||||
|
define LOCATION_PREV = 3;
|
||||||
|
define LOCATION_NEXT = 4;
|
||||||
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
|
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
|
||||||
|
|
||||||
galloc_setup_header(ptr, used, size, next_block, prev_block)
|
galloc_setup_header(ptr, used, size, next_block, prev_block)
|
||||||
|
@ -89,8 +89,6 @@ geadline2(prompt, text)
|
|||||||
esccode('D');
|
esccode('D');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == '\n') {
|
|
||||||
return buf;
|
|
||||||
} else {
|
} else {
|
||||||
size = size + 1;
|
size = size + 1;
|
||||||
if (size >= capacity) {
|
if (size >= capacity) {
|
||||||
@ -117,11 +115,16 @@ geadline2(prompt, text)
|
|||||||
esccode('D');
|
esccode('D');
|
||||||
}
|
}
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
|
if (c == '\n')
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
geadline(prompt) => geadline2(prompt, NULL);
|
geadline(prompt)
|
||||||
|
{
|
||||||
|
geadline2(prompt, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
esccode(c)
|
esccode(c)
|
||||||
{
|
{
|
||||||
|
12
src/strchri.🗿
Normal file
12
src/strchri.🗿
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
strchri(str, c)
|
||||||
|
{
|
||||||
|
local i = 0;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if ([str + i] == c)
|
||||||
|
return (i);
|
||||||
|
if ([str + i] == 0)
|
||||||
|
return (0 - 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
7
test.sh
7
test.sh
@ -6,12 +6,7 @@ tester()
|
|||||||
cat src/*.🗿 tests/$val.🗿 tests/test.🗿 >tmp.🗿
|
cat src/*.🗿 tests/$val.🗿 tests/test.🗿 >tmp.🗿
|
||||||
golemc tmp.🗿 > tmp.asm
|
golemc tmp.🗿 > tmp.asm
|
||||||
orgaasm tmp.asm tmp.rom
|
orgaasm tmp.asm tmp.rom
|
||||||
if [ -f tests/$val.input ]
|
orgaemu tmp.rom
|
||||||
then
|
|
||||||
orgaemu tmp.rom < tests/$val.input
|
|
||||||
else
|
|
||||||
orgaemu tmp.rom
|
|
||||||
fi
|
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
yo
|
|
||||||
bozo
|
|
||||||
z[Dbo[C[C[Co
|
|
@ -1,18 +0,0 @@
|
|||||||
main()
|
|
||||||
{
|
|
||||||
local ptr;
|
|
||||||
|
|
||||||
name = "geadline";
|
|
||||||
|
|
||||||
ptr = geadline("");
|
|
||||||
test_str(ptr, "yo", "");
|
|
||||||
|
|
||||||
ptr = geadline("");
|
|
||||||
test_str(ptr, "bozo", "");
|
|
||||||
|
|
||||||
ptr = geadline("");
|
|
||||||
test_str(ptr, "bozo", "arrow");
|
|
||||||
|
|
||||||
ptr = geadline("");
|
|
||||||
test_num(ptr, 0, "");
|
|
||||||
}
|
|
8
tests/strchri.🗿
Normal file
8
tests/strchri.🗿
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
main()
|
||||||
|
{
|
||||||
|
name = "strchri";
|
||||||
|
|
||||||
|
test_num(strchri("bozoman", 'm'), 4, "");
|
||||||
|
test_num(strchri("bozoman", 'v'), 0 - 1, "");
|
||||||
|
test_num(strchri("", 'v'), 0 - 1, "");
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
# STRCAT
|
|
||||||
Strcat (string concatenate) is a function that takes two chars lists as a parameter and write the second at this end of the first (like strcat in C)
|
|
||||||
|
|
||||||
## params
|
|
||||||
1. chars list
|
|
||||||
2. chars list
|
|
||||||
|
|
||||||
## example
|
|
||||||
```
|
|
||||||
strcat("y", "o") "y" => "yo"
|
|
||||||
strcat("y", "") "y" => "y"
|
|
||||||
strcat("", "o") "" => "o"
|
|
||||||
strcat("hello ", "world!") => "hello world!"
|
|
||||||
```
|
|
@ -1,14 +0,0 @@
|
|||||||
# STRCPY
|
|
||||||
Strcpy (string copy) is a function that takes two chars lists as a parameter and write the second in the first (like strcpy in C)
|
|
||||||
|
|
||||||
## params
|
|
||||||
1. chars list
|
|
||||||
2. chars list
|
|
||||||
|
|
||||||
## example
|
|
||||||
```
|
|
||||||
strcpy("y", "o") "y" => "o"
|
|
||||||
strcpy("y", "") "y" => ""
|
|
||||||
strcpy("", "o") "" => "o"
|
|
||||||
strcpy("hello ", "world!") => "world!"
|
|
||||||
```
|
|
@ -1,16 +0,0 @@
|
|||||||
# STRLEN
|
|
||||||
Strlen (string length) is a function that takes an chars list as a parameter and return an length (like strlen in C)
|
|
||||||
|
|
||||||
## params
|
|
||||||
1. char list
|
|
||||||
|
|
||||||
## return
|
|
||||||
number
|
|
||||||
|
|
||||||
## example
|
|
||||||
```
|
|
||||||
strlen("ab") => 2
|
|
||||||
strlen(NULL) => 0
|
|
||||||
strlen("") => 0
|
|
||||||
strlen("j'ai les cramptés") => 17
|
|
||||||
```
|
|
Loading…
Reference in New Issue
Block a user