Skip to content

Commit 2fb74e2

Browse files
committed
new file sharing
1 parent 9ecf006 commit 2fb74e2

File tree

7 files changed

+108
-73
lines changed

7 files changed

+108
-73
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/instructions.md

Lines changed: 48 additions & 49 deletions
Large diffs are not rendered by default.

docs/syscalls.md

Lines changed: 25 additions & 22 deletions
Large diffs are not rendered by default.

docs/tmp.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# MVM Standard Library Table
2+
3+
This table lists the functions currently implemented in the MVM standard library. All functions use the stack for
4+
arguments and return values.
5+
6+
| Module | Function Name | Description | Argument 1 (F1) | Argument 2 (F2) | Argument 3 (F3) | Return Value(s) (Stack) | Notes |
7+
|--------------|-------------------|---------------------------------------------------------------------|----------------------------------|--------------------------------------|-----------------|----------------------------------------------|------------------------------------------------------------------------------|
8+
| `strings` | `strlen` | Returns the length of a string. | String Address (Memory Address) | - | - | Length (Long) | Excludes the null terminator. |
9+
| | `strcat` | Concatenates two strings. | String1 Address (Memory Address) | String2 Address (Memory Address) | - | Concatenated String Address (Memory Address) | Allocates memory for the concatenated string. |
10+
| | `strcpy` | Copies a string from one location to another. | Source Address (Memory Address) | Destination Address (Memory Address) | - | Destination Address (Memory Address) | Allocates memory for the copied string. The source string remains unchanged. |
11+
| | `strcmp` | Compares two strings lexicographically. | String1 Address (Memory Address) | String2 Address (Memory Address) | - | Result (0 or 1) | Returns 1 if strings are equal; 0 otherwise. |
12+
| | `asciiToInt` | Converts an ASCII character to its integer representation. | Character Code (Long) | - | - | Integer Value (Long) | Returns -1 if the input is not a valid ASCII character. |
13+
| | `findFirstString` | Finds the index of the first occurrence of a character in a string. | String Address (Memory Address) | Character Code (Long) | - | Index (Long) | Returns -1 if the character is not found. |
14+
| `arrays` | `create` | Creates a new array. | Size (Long) | Data Type (RegisterDataType code) | - | Array Base Address (Long) | Data Type code: 0=Byte, 1=Short, 2=Int, 3=Long, 4=Float, 5=Double. |
15+
| | `get` | Gets an element from an array. | Array Address (Long) | Index (Long) | - | Element Value (Long) | Performs bounds checking. |
16+
| | `size` | Returns the size of an array | Array Address (Long) | Index (Long) | Value (Long) | - | Performs bounds checking. |
17+
| | `append` | Adds a new element to the end of an array | Array Address (Long) | - | - | Length (Long) | - |
18+
| `math` | `sqrt` | Calculates the square root of a number. | Number (Long) | - | - | Result (Long) | Returns 0 if the input is negative. |
19+
| | `pow` | Raises a number to a power. | Base (Long) | Exponent (Long) | - | Result (Long) | Returns 0 on error. |
20+
| | `min` | Returns the minimum of two values. | Value 1 (Long) | Value 2 (Long) | - | Minimum Value (Long) | - |
21+
| | `max` | Returns the maximum of two values. | Value 1 (Long) | Value 2 (Long) | - | Maximum Value (Long) | - |
22+
| | `inc` | Increments a value by 1. | Value (Long) | - | - | Incremented Value (Long) | - |
23+
| | `dec` | Decrements a value by 1. | Value (Long) | - | - | Decremented Value (Long) | - |
24+
| | `neg` | Negates a value. | Value (Long) | - | - | Negated Value (Long) | - |
25+
| | `sq` | Squares a value. | Value (Long) | - | - | Squared Value (Long) | - |
26+
| `io` | `println` | Prints a string to the console with a newline. | String Address (Memory Address) | - | - | - | The string must be null-terminated. |
27+
| | `readln` | Reads a line from standard input. | - | - | - | String Address (Memory Address) | Allocates memory for the string. |
28+
| `conversion` | `asciiToInt` | Converts an ASCII character to an integer. | Character Code (Long) | - | - | Integer Value (Long) | Returns -1 if the input is not a valid ASCII character. |
29+
| | `strtoint` | Converts a string to a Long. | String Address (Memory Address) | - | - | Integer Value (Long) | Returns 0 on error. |
30+
| | `findFirstString` | Finds the index of the first occurrence of a character in a string. | String Address (Memory Address) | Character Code (Long) | - | Index (Long) | Returns -1 if the character is not found. |
31+

src/main/kotlin/kilb/Klib.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Klib(val vm: Vm) {
1212
"strings.strcat" -> Strings(vm).strcat()
1313
"strings.strcpy" -> Strings(vm).strcpy()
1414
"strings.strlen" -> Strings(vm).strlen()
15-
"println" -> println(vm.helpers.readRegisterString(RegisterType.F1))
15+
"io.println" -> println(vm.helpers.readRegisterString(RegisterType.F1))
1616

1717

1818
"strings.cheekyfloat" -> cheekyFloat()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
STR F1 "Hello, World!"
2+
call println

0 commit comments

Comments
 (0)