diff options
author | jonsykkel <jonrevold@gmail.com> | 2021-09-06 03:00:54 +0200 |
---|---|---|
committer | jonsykkel <jonrevold@gmail.com> | 2021-09-06 03:01:27 +0200 |
commit | cbbeb1d7f8b53f396fc1b3b57a54e006e16cd489 (patch) | |
tree | d89cc105166ac84385a5293d32069f65614f0b87 | |
parent | e293ff571835f39084305ef2ce33c51a246d3cfe (diff) | |
download | okeffa-cbbeb1d7f8b53f396fc1b3b57a54e006e16cd489.tar.gz |
galk
-rw-r--r-- | calc/main.c | 52 | ||||
-rw-r--r-- | makefile | 2 |
2 files changed, 51 insertions, 3 deletions
diff --git a/calc/main.c b/calc/main.c index 61ec192..814f8f0 100644 --- a/calc/main.c +++ b/calc/main.c @@ -1,7 +1,55 @@ +#include "os.h" +#include <okeffa/word.h> +#include <okeffa/fz.h> +#include <okeffa/fz_lim.h> +#include <okeffa/fz_basic.h> +#include <okeffa/fz_arith.h> +#include <okeffa/fz_pred.h> +#include <okeffa/fz_bitop.h> +#include <okeffa/fz_shift.h> +#include <okeffa/io.h> #include <stdio.h> +#include <stdlib.h> + +#define WIDTH_MAX 1024 +#define HEIGHT_MAX 64 +#define STACK_SIZE (WIDTH_MAX/WORD_BITNESS*HEIGHT_MAX) + +#define _STR(X) #X +#define STR(X) _STR(X) +#define STACK(I) stack[wordness*I] + +static size_t width; +static size_t height; +static size_t wordness; +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; int main(int argc,char **argv){ - (void)argc; (void)argv; - printf("hi\n"); + if(argc != 3){ + eggog("usage: ffa_calc width height"); + } + + width = strtol(argv[1],0,10); + height = strtol(argv[2],0,10); + + if(!fz_valid_bitness(width)){ + eggog("invalid width: "FZ_VALIDITY_RULE_DOC); + } + + if(width > WIDTH_MAX){ + eggog("max width: "STR(WIDTH_MAX)); + } + + if(height > HEIGHT_MAX){ + eggog("max height: "STR(HEIGHT_MAX)); + } + + wordness = width/WORD_BITNESS; + return 0; } @@ -62,7 +62,7 @@ out := $(bin_dir)/$(out) ifneq ($(run),) run_cmd := @echo "run $(out)" 1>&2 - run_cmd += && ./$(out) + run_cmd += && ./$(out) 256 16 endif ifneq ($(debug),) |