This commit is contained in:
anon 2024-07-04 18:13:31 +02:00
parent 1e8489879e
commit 8717aa8ad4
2 changed files with 100 additions and 18 deletions

@ -8,9 +8,12 @@
+ Chad C, C99
+ Flex/Bison
## Train of making
## Train of translation
file -> preprocessor -> as -> link -> exe
NOTE: the compiler front-end should be able to handle the preprocessing someway,
but we are not making our own preprocessor. use Frexx or m4
### implementation
1. flex parsing
2. bison creates partial syntax trees (since we dont optimize, we can render in relatively small chunks because not all that much context is needed)
@ -25,17 +28,30 @@ prefixes:
+ s - signed
+ u - unsigned
sizes:
+ 8
+ 16
+ 32
+ 64
## Syntax
### Macros
+ fuck macros
+ use a preprocessor
### asm
### Asm
+ no ',' argument deliteters
+ optional "[]" argument parenthesizing (?)
### logic
+ optional "[]" argument parenthesizing
### Machine code
```
machine
// literal values
end machine
```
All literal values (string or numeric) is copied as machine code
### Logic
+ only evaulated in _logical blocks_
#### logical blocks
+ if
+ if-then-else-end-if
#### operators
+ =
+ >
@ -47,11 +63,22 @@ prefixes:
+ and
+ or
+ xor
### Functions
```
<qualifyiers>
<type> <name>
<declarations>
begin
<code>
end <type>
```
qualifier:
+ fast -> use the fastcall calling convention
+ ? stack -> place all arguments on the stack
### labels
```C
my_label:
```
### Come back to later
@ -60,18 +87,6 @@ my_label:
+ `extern`
+ `static`
### Assembly Example
```C
program example
begin
if a is 1 then
// ...
else
// ...
end if
end program
```
## LATER
+ DWARF2
+ linker??

67
documentation/xop.eax Normal file

@ -0,0 +1,67 @@
/*
* Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
*
* Xop is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
* And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
* It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
*/
#include <xolatile/xtandard.eax>
fast
procedure highlight
in s32 offset;
in u8 buffer;
s32 byte;
begin
loop
if byte = 0x90 then
fastcall echo_new_line
fastcall terminal_style EFFECT_NORMAL COLOUR_YELLOW
fastcall echo_byte [buffer + offset]
fastcall terminal_style -1 -1
else
fastcall echo_byte [buffer + offset]
end if
inc offset
if offset = size then
break
end if
end loop
end procedure;
unix
program xop
s32 file = -1;
s32 size = 0;
s32 offset = 0;
u8 buffer = NULL;
begin
if argc != 2 then
fatal_failure(1, "xop: xop input")
end if
fastcall file_open [argv + 1] O_RDONLY
mov file rax
fastcall file_size file
mov size rax
fastcall allocate size // ????
mov buffer rax
fastcall fale buffer size
fastcall file_close file
mov file rax
fastcall highlight offset buffer
fastcall echo_new_line
fastcall deallocate buffer
mov buffer rax
exit SUCCESS
end program;