summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-09-06 03:58:04 +0200
committerjonsykkel <jonrevold@gmail.com>2021-09-06 03:58:04 +0200
commit6d72913849ea278f7ea0e95c5c635967fbb472f3 (patch)
tree4eebf768f104541c6b6234330a431f2d712f690b
parent6c4db939da11ec68d5be5ad77979846a42a04635 (diff)
downloadokeffa-6d72913849ea278f7ea0e95c5c635967fbb472f3.tar.gz
vork
-rw-r--r--calc/main.c45
-rw-r--r--calc/os.c8
-rw-r--r--calc/os.h2
-rw-r--r--makefile7
4 files changed, 41 insertions, 21 deletions
diff --git a/calc/main.c b/calc/main.c
index 3359d35..af25e9e 100644
--- a/calc/main.c
+++ b/calc/main.c
@@ -15,35 +15,48 @@
#define _STR(X) #X
#define STR(X) _STR(X)
-#define STACK(I) stack[wordness*I]
+#define STACK(I) stack[fl*(I)]
-static size_t width;
-static size_t height;
-static size_t wordness;
+static size_t bitness;
+static size_t fl; //wordness, fz len
static word_t stack[STACK_SIZE];
-static wbool_t flag;
-static size_t pos;
-static size_t quote_lev;
-static size_t comm_lev;
-static size_t cond_lev;
+static size_t sh; //stack height
+static size_t sp = 0; //stack ptr
+static wbool_t flag = 0; //carry/borrow
+static size_t pos = 0;
+static size_t quote_lev = 0;
+static size_t comm_lev = 0;
+static size_t cond_lev = 0;
+
+static void zap(void){
+ for(size_t x = 0;x < sh;x++){
+ fz_clear(&STACK(x),fl);
+ }
+ sp = 0;
+ flag = 0;
+}
+
+static void e(char const *str){
+ eggog("pos: %zu: %s",pos,str);
+}
int main(int argc,char **argv){
if(argc != 3){
- eggog("usage: ffa_calc width height");
+ eggog("usage: ffa_calc bitness stack_height");
}
- width = strtol(argv[1],0,10);
- height = strtol(argv[2],0,10);
+ bitness = strtol(argv[1],0,10);
+ sh = strtol(argv[2],0,10);
- if(!fz_valid_bitness(width)){
- eggog("invalid width: "FZ_VALIDITY_RULE_DOC);
+ if(!fz_valid_bitness(bitness)){
+ eggog("invalid bitness: "FZ_VALIDITY_RULE_DOC);
}
- if(width/IRON_BYTEBITS*height > STACK_SIZE){
+ if(bitness/IRON_BYTEBITS*sh > STACK_SIZE){
eggog("max stack size: "STR(STACK_SIZE));
}
- wordness = width/WORD_BITNESS;
+ fl = bitness/WORD_BITNESS;
return 0;
}
diff --git a/calc/os.c b/calc/os.c
index cba2871..7d3bd8a 100644
--- a/calc/os.c
+++ b/calc/os.c
@@ -1,6 +1,7 @@
#include "os.h"
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#define SAD EXIT_FAILURE
@@ -18,8 +19,11 @@ void write_nl(void){
fputc('\n',stdout);
}
-void eggog(char const *str){
- fputs(str,stderr);
+void eggog(char const *fmt,...){
+ va_list args;
+ va_start(args,fmt);
+ vfprintf(stderr,fmt,args);
+ va_end(args);
write_nl();
exit(SAD);
}
diff --git a/calc/os.h b/calc/os.h
index f780e06..1f49fc5 100644
--- a/calc/os.h
+++ b/calc/os.h
@@ -6,7 +6,7 @@
char read_char (void);
void write_char (char c);
void write_nl (void);
-void eggog (char const *str);
+void eggog (char const *fmt,...);
#endif
diff --git a/makefile b/makefile
index 336468d..e635033 100644
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
#version static 5
-out_name := okeffa
+out_name := ffa_calc
build := static64
inc_dir := inc
tmp_dir := tmp
@@ -26,14 +26,17 @@ endif
ifeq ($(build),static64)
CFLAGS += -O3 -DNDEBUG
+ out_name := okeffa
out := lib$(out_name)64.a
lib := lib$(out_name).a
else ifeq ($(build),static32)
CFLAGS += -O3 -m32 -DNDEBUG
+ out_name := okeffa
out := lib$(out_name)32.a
lib := lib$(out_name).a
else ifeq ($(build),static64d)
CFLAGS += -g
+ out_name := okeffa
out := lib$(out_name)64d.a
lib := lib$(out_name)d.a
else ifeq ($(build),debug)
@@ -46,7 +49,7 @@ else ifeq ($(build),release)
src_dir += calc
CFLAGS += -O3
link = $(dlink)
- out := $(bin)
+ out := $(out_name)
else ifeq ($(build),analyze)
src_dir += calc
CC := clang