works only in POSIX enviroment !
make
run the examples
./run.sh example/primes_generator.kws
So what's all about?
You may be woundering.
This project is all you need to Develop, Deploy, and Run anything and everywhere !
The project is consisted of 3 main parts:
- -Capable of runing generated Kwork Assembly code
- -Capable of translating high level Kwork programming language to Kwork machine code
- -Which is completly virtualy ran by Kwork Virtual CPU
Basicly a C program which emulates work of the real CPU on low level. Uses Kworker assembly code (.kw) and executes it continnusly. Has a multithreading which is built upon rapidly changing Kwork vitural CPU instruction pointer between all threads and preserving the state of the register. Also supports thread locking
A relativly high level programing language that generates Kwork assembly code which is later assebled to Kwork CPU machine code. Consists of Kwork compiler and Kwork assembler
Fully emulated operation system with simple file system and with console ui. Emulates hardware.
- Hardware emulation
- Standart input device
- Standart output device
- Storage device
- Timer device
- signals
- Kernel
- Memory managment
- File system
- Program execution
- Signals handling
- User space
- Compiler
- basic expressions support
- floating numbers math and support
- string literals support
- static type checks
- compile time checks
- compile time execution
- preprocessor
- optimization
- functions
- loops
- conditional statements
- basic input and output
- arrays
- pointers
- bitwise operations
- structs
- static memory
- dynamic memory
- Assembler
- All operations supported
- threading and locks
- floating point numbers support
- basic math and jump instuctions
- bitwise instructions
- pointers
- basic system calls
- stack
Kwork lang is multiplatform static JET compiled programming language with dynamic data types and every variable is static and global in the specific frame. There is NO semicolons so only one command can be in the line (does not include nested calls ex function calls params).
Every program must start with main
function declaration following by end
keyword at the end of the frame
function main
… your code
end
every key word is caps sensitive
Existing features: • Variable declaration let value_type lvalue = rvalue if value_type is not present used default type, word. rValue can be const/var/array/immutable string/expression
1. let adress String = “Hello world\n"
2. let a = b
3. let word a = [20][20]
4. let double D = b*b-(4*a*c)
lValue can be array subscription/memory dereferencing/one char letter/function call and all together
1. let a[2] = 1337
2. let a[B]….[Bn] = 69
3. let @(lvalue) = 101
4. let D = “This language is trash\a\n”
5. let root = CALL sqrt{25,2}
• loops loops can be for loop
1. for lvalue=rvalue;rvalue;rvalue
{
…. Your code
}
First rvalue is starting value Second rvalue is expression which is true or false 1/0 Third rvalue is increment
for a=0;a<10;a++
{
….. do smt
}
• putc
puts char from var to stdout argument rvalue
• put
puts number from var to stdout argument rvalue
• branches
- if statement computes rvalue expression executes if true (any value >0)
if a<b
{
…your code
}
- else if statement computes rvalue only if previous if or else if frame failed
else if a>=b
{
…your code
}
- else statement executed only if all others if or else if frames failed
else
{
….your code here
}
• input
reads from stdin to variable
• functions declaration
function return_type “Name_of_you function” (var_type_1 arg1,var_type_2 arg2,…,var_type_n argN)
…your code
return rvalue
functions are required to have a prototype at the begining of the file
prototype return_type “Name_of_you function” (var_type_1 arg1,var_type_2 arg2,…,var_type_n argN)
• data types
{andress(for anything that points to memory), word (just int or long), doulbe(for floating point numbers) }
• data casts
{a}
to cast expression to adress {w}
to cast expression to word type {f}
to cast expression to double data type
• rvalue expression CALL “your function name” {rvalue1,rvalue2,…,rvalueN} Will call a function with parameters o binary operands
- supports all basic math operations + * - / %
let a = (b%10)*(10/3+(5-7))
- supports all basic bitwise operations && || ^ >> <<
&& - >binary and
|| -> binary or
^ ->binary XOR
-> bit shift right
<< -> bit shift left
- logical operations < > <= >=
o unary operations 4. ++ -- @ # !
! -> bit inverse
++ -> increment value by one
-- -> decrement value by one
@ -> dereference the pointer
#-> get a pointer
• Comments
// your comment Pointer can be any value even the const let @(10) = 3010
this line would change the 10th assembly instruction to the instruction of summing acc with the assembly instruction.
to include a lib use the following line at the header of the file
#include strings.kwh
Lets make self-modifying code great again. In this language as you can see basically no checks on what you do with memory so quite easy to shoot yourself in the foot 😊 Best of luck !!