System calls concept for Sea16.

There would be a dedicated syscall #xx instruction that would take an 8-bit immediate selecting a specific system call. Could be modified in a number of ways if >256 are needed. First input and the output are in the A register, all following inputs are on the stack.

Math

abs

input

number

output

absolute value of number

Strings (handles)

There are flexible Python-like strings that don't need a static-sized memory buffer like C strings. Instead of pointers they use numeric handles. There are an arbitrary, reasonable limit on handle count, and probably storage, and a failed string allocation returns a handle of zero.

v_strnew

input

output

new string handle

Allocates a new string handle pointing to an empty string and returns it in A, or returns zero if no string handles are available.

v_strdup

input

string to duplicate

output

new string handle

Allocates a new string handle pointing to a copy of the same data as another string handle, and returns it in A, or returns zero if no handles are available.

v_strlen

input

string handle

output

length in characters

Calculates a string length.

v_strfree

input

string handle

output

Deallocates a string handle and marks it free for use. No operation if input handle is zero.

v_strcmp

input

string1, string2

output

zero if strings match, nonzero if they don't

Same as C strcmp.

v_strcasecmp

input

string1, string2

output

zero if strings match, nonzero if they don't (case insensitive)

Same as C strcasecmp.

v_strcpy

input

destination string, source string

output

Copies one string's data into another.

v_strcat

input

destination string, source string

output

Adds a string onto the end of another string.

v_strslice

input

string, start, end

output

new string handle

Same as string[start:end] in Python. Allocates a string that's a substring of another string.

v_strslice_start

input

string, start

output

new string handle

Same as string[start:] in Python. Allocates a string that's a substring of another string.

v_strslice_end

input

string, end

output

new string handle

Same as string[:end] in Python. Allocates a string that's a substring of another string.

None: Sea16 syscalls (last edited 2018-11-09 06:20:29 by NovaSquirrel)