Add Damn Simple Code

2025-06-16 16:02:48 +01:00
parent da48a9657e
commit 35cd5929f3
+69
@@ -0,0 +1,69 @@
# DSC: Damn Simple Code
- This is a concept doc for the DSC programming language
- None of this is final and may change at any time, this is just a concept to figure out how a simple programming language could be implemented at a level that is just above assembly
## Type System
- as this is a very basic langauge, all variables will be of type int for now.
- statics have a constant size decided at compile time and are stored in a static memory region at the start of the compiled
binary
- constants will be stored in the same way as statics, however consts are immutable.
## Variables
- variables will use the general purpose registers within the CPU to store data.
- this means up to 8 variables can be declared in a given method with the current architecture.
- it may be worth changing this to 16 later on.
## Syntax
```dsc
// Function calls
Proc main(param1, param2, param3): // does something random
// you can invoke assembly methods.
// this is useful for operations where writing code at the lowest level is preferable
// !!! Warning !!! - this is equivalent to embedding assembly within the current function
// this may mess with registers so ensure you know what the ASM is doing.
Call @init;
var0 = param1 + param2;
push(var0);
var1 = pop();
If (var0 == var1):
Return;
Else:
var3 = var2 | var3;
Return;
EndIf
EndProc
// declare a constant. this can be an int, string, bool etc and is immutable.
// the type is inferred from the value
Const message = "Hello World!"
// statics are declared similarly however they are mutable
Static err_flag = False;
// Assembly blocks can be used when it's inconvenient to write higher level code
Asm:
// set up the stack
@stack 0x10000
@init
LDA @stack
MOV MDR, BPR
MOV MDR, SPR
RET
EndAsm
```