50 lines
1.1 KiB
Plaintext
50 lines
1.1 KiB
Plaintext
// Characters
|
|
|
|
char(a) // hex(00 00 00 00 00 00 00 41) - in case of little-endian machines (in memory: 0x4100000000000000)
|
|
char(á) // this leads to the utf8 characters - implying source code text is utf8 too as we care nothing for parsing encodings...
|
|
|
|
// Strings
|
|
|
|
// Strings are stored similarily with the zero-terminator included and stored in 4byte groups of data padded up with zeroes.
|
|
// Then to constitute a string, we also push the number of characters - as seen below (including the terminator, for optimizations)
|
|
|
|
"one"
|
|
/*
|
|
0xone0
|
|
0x0004
|
|
*/
|
|
|
|
"alma"
|
|
/*
|
|
0xalma
|
|
0x0000
|
|
0x5
|
|
*/"
|
|
|
|
// But to not only work on the stack, we can store a string into session storage
|
|
"word_name" gen_str // -> session storage
|
|
|
|
// Strings have operations on them, prefixed with "str" and they expect a string on stack otherwise you are in trouble.
|
|
|
|
"abc" "df" str+
|
|
/*
|
|
abc0
|
|
0004
|
|
df00
|
|
0003
|
|
*/
|
|
|
|
// TODO: implement as C builtin instead.. but doable this way
|
|
:builtin str+ @off1 @mod1 @
|
|
dup
|
|
7 + 4 /
|
|
strcon@off1(_) // (_) means to pop and put to variable while, (.) means peek and put in var
|
|
dup
|
|
4 %
|
|
strcon@mod1(_)
|
|
strcon@off1
|
|
popat
|
|
|
|
+
|
|
;
|