Skip to content

Commit 902ba1b

Browse files
committed
Initial commit
0 parents  commit 902ba1b

22 files changed

+1791
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
libable.a
2+
config.mk
3+
*.o
4+
*~

LICENSE

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright (c) 2015 Mark Smith <[email protected]>
2+
Copyright (c) 2015 Ryan Siddle <[email protected]>
3+
Copyright (c) 2015 Merj Ltd
4+
5+
Permission to use, copy, modify, and distribute this software for any purpose
6+
with or without fee is hereby granted, provided that the above copyright notice
7+
and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
13+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
15+
THIS SOFTWARE.

Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
LIB?=able
2+
SRCS=edge.c node.c port.c link.c core.c host.c wire.c task.c
3+
HDRS=edge.h node.h port.h link.h core.h host.h wire.h task.h able.h
4+
5+
.include "config.mk"
6+
7+
OBJS+=${SRCS:N*.h:R:S/$/.o/}
8+
9+
.PHONY: build clean install uninstall
10+
11+
build: lib${LIB}.a
12+
13+
clean:
14+
-rm -vf ${OBJS} lib${LIB}.a
15+
16+
install: lib${LIB}.a
17+
@mkdir -p ${LIBDIR}
18+
install -m 0644 lib${LIB}.a ${LIBDIR}/lib${LIB}.a
19+
@mkdir -p ${INCDIR}/${LIB}
20+
.for HDR in ${HDRS}
21+
cp ${HDR} ${INCDIR}/${LIB}/${HDR}
22+
.endfor
23+
24+
uninstall:
25+
-rm -vf ${LIBDIR}/lib${LIB}.a
26+
-rm -vrf ${INCDIR}/${LIB}
27+
28+
lib${LIB}.a: ${OBJS}
29+
@rm -vf lib${LIB}.a
30+
${AR} ${ARFLAGS} lib${LIB}.a ${OBJS}
31+
${RANLIB} lib${LIB}.a

README

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
WELCOME TO ABLE!
2+
3+
libable implements an efficient, portable and secure general-purpose virtual
4+
machine and virtual network as a library
5+
6+
GETTING STARTED
7+
8+
BSD Make and Clang are required to build and install libable
9+
10+
Building and installing on OpenBSD
11+
12+
$ cp config.mk.def config.mk
13+
$ make install
14+
...
15+
$
16+
17+
Building and installing on Ubuntu
18+
19+
# apt install bmake clang
20+
...
21+
# exit
22+
$ cp config.mk.def config.mk
23+
$ bmake -DCOMPAT_LINUX install
24+
...
25+
$
26+
27+
Building and installing on macOS
28+
29+
# brew install bmake
30+
...
31+
# exit
32+
$ cp config.mk.def config.mk
33+
$ bmake -DCOMPAT_MACOS install
34+
...
35+
$
36+
37+
GETTING INVOLVED
38+
39+
Contact Details
40+
41+
Find us online at ablevm.org or email us at [email protected]
42+
43+
Code of Conduct
44+
45+
Respect each other and please don't spam
46+
47+
LICENSE
48+
49+
ISC-style license
50+
51+
DETAILS
52+
53+
Virtual Machine
54+
55+
i
56+
...d d1 p
57+
d0 c0 c...
58+
r...
59+
60+
i 8 bits instruction
61+
p 64 bits program counter
62+
d0 64 bits circular data-stack
63+
d1 64 bits
64+
d 64 bits * 32 (Wraps)
65+
c0 64 bits circular call-stack
66+
c 64 bits * 32 (Wraps)
67+
r 64 bits * 32 (Wraps) registers
68+
69+
8 bit unencoded instructions
70+
71+
Byte addressed memory with auto-alignment and auto-framing
72+
73+
32 general-purpose registers OR 16 paired address registers
74+
75+
Standard Instruction Set
76+
77+
00 ; 08* r! 10 push 18 +
78+
01 ex 09* r@ 11 pop 19 -
79+
02+ name ; 0A* @r 12 lshift 1A *
80+
03+ name 0B* !r 13 ashift 1B /mod
81+
82+
04+ if 0C* @r+ 14 not 1C drop
83+
05+ -if 0D* !r+ 15 and 1D dup
84+
06+ next 0E* -@r 16 or 1E over
85+
07+ lit 0F* -!r 17 xor 1F swap
86+
87+
c20 ; c28* r! h30 ; h38* r!
88+
c21 ex c29* r@ h31 ex h39* r@
89+
c22+ name ; c2A* @r h32+ name ; h3A* @r
90+
c23+ name c2B* !r h33+ name h3B* !r
91+
92+
c24+ if c2C* @r+ h34+ if h3C* @r+
93+
c25+ -if c2D* !r+ h35+ -if h3D* !r+
94+
c26+ next c2E* -@r h36+ next h3E* -@r
95+
c27+ lit c2F* -!r h37+ lit h3F* -!r
96+
97+
d40 ; d48* r! 50 i@ 58 rshift
98+
d41 ex d49* r@ 51 i! 59 u<
99+
d42+ name ; d4A* @r 52 = 5A u*
100+
d43+ name d4B* !r 53 < 5B u/mod
101+
102+
d44+ if d4C* @r+ 54 negate 5C nip
103+
d45+ -if d4D* !r+ 55 abs 5D tuck
104+
d46+ next d4E* -@r 56 min 5E rot
105+
d47+ lit d4F* -!r 57 max 5F -rot
106+
107+
60 68 70 78
108+
61 69 71 79
109+
62 6A 72 7A
110+
63 6B 73 7B
111+
112+
64 6C 74 7C
113+
65 6D 75 7D
114+
66 6E 76 7E
115+
67 6F 77 7F
116+
117+
Extended Instruction Set
118+
119+
80 wait 88 90 98
120+
81 clip 89 91 99
121+
82 recv 8A 92 9A
122+
83 send 8B 93 9B
123+
124+
84 8C 94 9C
125+
85 8D 95 9D
126+
86 8E 96 9E
127+
87 8F 97 9F
128+
129+
w = 32 bit default
130+
c = 8 bit variant
131+
h = 16 bit variant
132+
d = 64 bit variant
133+
134+
+ followed by n bit immediate where n is w, c, h or d
135+
* followed by 8 bit register
136+
137+
Virtual Network
138+
139+
Messages
140+
141+
-40 16 bits sent bytes
142+
-30 16 bits body bytes
143+
-20 32 bits mark
144+
00 body
145+
146+
64 KiB - 8 byte header maximum single deliverable message

able.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "edge.h"
2+
#include "node.h"
3+
#include "port.h"
4+
#include "link.h"
5+
#include "core.h"
6+
#include "host.h"
7+
#include "wire.h"
8+
#include "task.h"

config.mk.def

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PREFIX?=/usr/local/able
2+
BINDIR=${PREFIX}/bin
3+
INCDIR=${PREFIX}/include
4+
LIBDIR=${PREFIX}/lib
5+
MANDIR=${PREFIX}/man
6+
7+
CC=clang
8+
CFLAGS=-I${INCDIR} -g -O2 -std=c11 -pedantic -Wall -Wno-zero-length-array -Wno-gnu-label-as-value -Wno-gnu-designator -Wno-gnu-empty-struct
9+
10+
.ifdef DEBUG
11+
CFLAGS+=-DDEBUG=${DEBUG}
12+
.endif
13+
14+
.ifdef COMPAT_LINUX
15+
CFLAGS+=-DABLE_COMPAT_LINUX -D_GNU_SOURCE
16+
.endif
17+
.ifdef COMPAT_MACOS
18+
CFLAGS+=-DABLE_COMPAT_MACOS
19+
.endif
20+
21+
AR=ar
22+
ARFLAGS=rc
23+
24+
RANLIB=ranlib

0 commit comments

Comments
 (0)