Skip to content

Commit 4ed8c95

Browse files
committed
Move core and host to libable_misc
1 parent c735b3c commit 4ed8c95

13 files changed

+214
-90
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
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
2+
SRCS=edge.c node.c port.c link.c wire.c task.c
3+
HDRS=edge.h node.h port.h link.h wire.h task.h able.h
44

55
.include "config.mk"
66

README

-82
Original file line numberDiff line numberDiff line change
@@ -53,88 +53,6 @@ ISC-style license
5353

5454
DETAILS
5555

56-
Virtual Machine
57-
58-
i
59-
p
60-
c...
61-
...d
62-
r...
63-
64-
i 8 bits instruction
65-
p 64 bits program counter
66-
d 64 bits ... linear data-stack
67-
c 64 bits ... linear call-stack
68-
r 64 bits ... registers
69-
70-
8 bit unencoded instructions
71-
72-
Byte addressed memory with auto-alignment and auto-framing
73-
74-
General-purpose registers OR base+offset address registers
75-
76-
Standard Instruction Set
77-
78-
00 ; 08* r! 10 push 18 +
79-
01 ex 09* r@ 11 pop 19 -
80-
02+ name ; 0A* @r 12 lshift 1A *
81-
03+ name 0B* !r 13 ashift 1B /mod
82-
83-
04+ if 0C* @r+ 14 not 1C drop
84-
05+ -if 0D* !r+ 15 and 1D dup
85-
06+ next 0E* -@r 16 or 1E over
86-
07+ lit 0F* -!r 17 xor 1F swap
87-
88-
c20 ; c28* r! h30 ; h38* r!
89-
c21 ex c29* r@ h31 ex h39* r@
90-
c22+ name ; c2A* @r h32+ name ; h3A* @r
91-
c23+ name c2B* !r h33+ name h3B* !r
92-
93-
c24+ if c2C* @r+ h34+ if h3C* @r+
94-
c25+ -if c2D* !r+ h35+ -if h3D* !r+
95-
c26+ next c2E* -@r h36+ next h3E* -@r
96-
c27+ lit c2F* -!r h37+ lit h3F* -!r
97-
98-
d40 ; d48* r! 50 i@ 58 rshift
99-
d41 ex d49* r@ 51 i! 59 u<
100-
d42+ name ; d4A* @r 52 = 5A u*
101-
d43+ name d4B* !r 53 < 5B u/mod
102-
103-
d44+ if d4C* @r+ 54 negate 5C nip
104-
d45+ -if d4D* !r+ 55 abs 5D tuck
105-
d46+ next d4E* -@r 56 min 5E rot
106-
d47+ lit d4F* -!r 57 max 5F -rot
107-
108-
60 68 70 78
109-
61 69 71 79
110-
62 6A 72 7A
111-
63 6B 73 7B
112-
113-
64 6C 74 7C
114-
65 6D 75 7D
115-
66 6E 76 7E
116-
67 6F 77 7F
117-
118-
Extended Instruction Set
119-
120-
80 wait 88 90 98
121-
81 clip 89 91 99
122-
82 recv 8A 92 9A
123-
83 send 8B 93 9B
124-
125-
84 8C 94 9C
126-
85 8D 95 9D
127-
86 8E 96 9E
128-
87 8F 97 9F
129-
130-
w = 32 bit default
131-
c = 8 bit variant
132-
h = 16 bit variant
133-
d = 64 bit variant
134-
135-
+ followed by n bit immediate where n is w, c, h or d
136-
* followed by 8 bit register
137-
13856
Virtual Network
13957

14058
Messages

able.h

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
#include "node.h"
33
#include "port.h"
44
#include "link.h"
5-
#include "core.h"
6-
#include "host.h"
75
#include "wire.h"
86
#include "task.h"

misc/.gitignore

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

misc/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.

misc/Makefile

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

misc/README

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

misc/config.mk.def

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PREFIX?=/usr/local
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

core.c misc/core.c

File renamed without changes.

core.h misc/core.h

File renamed without changes.

host.c misc/host.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include <stdatomic.h>
2-
#include "edge.h"
32
#include <pthread.h>
4-
#include "node.h"
5-
#include "port.h"
6-
#include "link.h"
3+
#include <able/able.h>
74
#include "core.h"
85
#include "host.h"
96

host.h misc/host.h

File renamed without changes.

misc/misc.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "core.h"
2+
#include "host.h"

0 commit comments

Comments
 (0)