Initial commit
This commit is contained in:
commit
3e74914bd8
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
build
|
19
Makefile
Normal file
19
Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
O=build
|
||||
SRCS=$(shell find src -name "*.c" -type f)
|
||||
OBJS=$(SRCS:src/%.c=$(O)/%.o)
|
||||
SRC_DIRS=$(shell find src -type d)
|
||||
DIRS=$(SRC_DIRS:src/%=$(O)/%) $(O)
|
||||
|
||||
all: $(DIRS) $(O)/lisp2
|
||||
|
||||
clean:
|
||||
rm -rf $(O)
|
||||
|
||||
$(DIRS):
|
||||
mkdir -p $@
|
||||
|
||||
$(O)/lisp2: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJS)
|
||||
|
||||
$(O)/%.o: src/%.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
37
doc/binfmt.txt
Normal file
37
doc/binfmt.txt
Normal file
@ -0,0 +1,37 @@
|
||||
0. File header
|
||||
...
|
||||
|
||||
1. Library linkage section:
|
||||
Library entry:
|
||||
| Offset | Field | Description |
|
||||
|--------+-------------+-------------------------------------|
|
||||
| 0x00 | lib_type | 0 - VM library |
|
||||
| | | 1 - Native library |
|
||||
| 0x01 | lib_namelen | Library name length |
|
||||
| 0x02 | lib_name[] | lib_namelen bytes, teminated by NUL |
|
||||
|--------+-------------+-------------------------------------|
|
||||
|
||||
2. External reference section:
|
||||
Entry:
|
||||
| Offset | Field | Description |
|
||||
|--------+-------------+---------------------------------------------------------|
|
||||
| 0x00 | ref_type | 0 - Object symbol |
|
||||
| | | 1 - Bytecode function |
|
||||
| | | 2 - Native function |
|
||||
| 0x01 | ref_flags | |
|
||||
| 0x02 | ref_library | Source library |
|
||||
| 0x03 | ref_namelen | Length of external symbol name |
|
||||
| 0x04 | ref_address | For native functions: effective call address |
|
||||
| | | For VM objects/funcs: entry index in respective section |
|
||||
| 0x0C | ref_name[] | Native function symbol name |
|
||||
|--------+-------------+---------------------------------------------------------|
|
||||
|
||||
3. Functions section:
|
||||
Function entry:
|
||||
| Offset | Field | Description |
|
||||
|--------+-----------+-------------------------------------------------------|
|
||||
| 0x00 | fn_argc | Argument count, 255 means function accepts any number |
|
||||
| 0x01 | fn_flags | |
|
||||
| 0x02 | fn_size | Function bytecode size |
|
||||
| 0x04 | fn_data[] | Binary code chunk of fn_size bytes |
|
||||
|--------+-----------+-------------------------------------------------------|
|
3
doc/bytecode.txt
Normal file
3
doc/bytecode.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Each instruction is 4 bytes
|
||||
|
||||
... TBD ...
|
5
src/main.c
Normal file
5
src/main.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user