File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ SRC =as4.c
2+ EXE =as4
3+ EXTRACFLAGS =-lm
4+ EXTRALDFLAGS =-lm
5+ export SRC
6+ export EXE
7+ export EXTRACFLAGS
8+ export EXTRALDFLAGS
9+
10+ all : debug
11+
12+
13+ fast : phony
14+ $(MAKE ) -f Makefile.fast.gcc
15+
16+ debug : phony
17+ $(MAKE ) -f Makefile.dev.gcc
18+
19+ # docs:
20+ # rm -f docs.html
21+ # doxygen
22+ # ln -s html/index.html docs.html
23+
24+ clean :
25+ rm -rf $(SRC:.c=.gcno ) $(SRC:.c=.gcda ) $(SRC:.c=.gcov ) $(SRC:.c=.o )
26+ rm -rf html gmon.out docs.html $(EXE ) * .dyn * .dpi * .lock * .stackdump * .db
27+
28+ phony :
29+ true
Original file line number Diff line number Diff line change 1+ CC=gcc
2+ DEVFLAGS=-std=c99 -ggdb3 -pg -O0 -Wall -Wextra -pedantic -Wdeclaration-after-statement \
3+ -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes \
4+ -Wno-missing-braces -Wno-missing-field-initializers -Wformat=2 \
5+ -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith \
6+ -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline \
7+ -Wundef -Wnested-externs -Wcast-qual -Wunreachable-code \
8+ -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \
9+ -Wold-style-definition -Wwrite-strings \
10+ -fno-omit-frame-pointer -ffloat-store -fno-common -fstrict-aliasing \
11+ -fprofile-arcs -ftest-coverage -Wp,-D_FORTIFY_SOURCE=2 \
12+ -Winit-self -Wpacked -Wmissing-declarations -Wmissing-format-attribute \
13+ -Wmissing-noreturn -Wnested-externs -Wsign-compare -Wunsafe-loop-optimizations \
14+ -Werror-implicit-function-declaration -Wmissing-include-dirs -Wmissing-field-initializers \
15+ -Wvolatile-register-var -Wdisabled-optimization -Wsign-conversion \
16+ -Wno-long-long -Winvalid-pch -Wlogical-op -Wunused-result -Wdisabled-optimization
17+ CFLAGS=$(DEVFLAGS) $(EXTRACFLAGS) -c
18+ LDFLAGS=$(DEVFLAGS) $(EXTRALDFLAGS) -lgcov
19+ OBJ=$(SRC:.c=.o)
20+
21+ all: $(SRC) $(EXE)
22+
23+ $(EXE): $(OBJ)
24+ $(CC) $(OBJ) -o $@ $(LDFLAGS)
25+
26+ %.o: %.c
27+ $(CC) $(CFLAGS) $< -o $@
Original file line number Diff line number Diff line change 1+ CC=gcc
2+ FASTFLAGS=-O3 -s -march=native -fomit-frame-pointer -pipe -Wdisabled-optimization
3+ CFLAGS=$(FASTFLAGS) $(EXTRACFLAGS) -c
4+ LDFLAGS=$(FASTFLAGS) $(EXTRALDFLAGS)
5+ OBJ=$(SRC:.c=.o)
6+
7+ all: $(SRC) $(EXE)
8+
9+ $(EXE): $(OBJ)
10+ $(CC) $(OBJ) -o $@ $(LDFLAGS)
11+
12+ %.o: %.c
13+ $(CC) $(CFLAGS) $< -o $@
Original file line number Diff line number Diff line change 1+ # CPU Assembler
2+ The assembler for the Nibble Knowledge CPU
Original file line number Diff line number Diff line change 1+ #include "as4.h"
2+
3+ int main (int argc , char * * argv )
4+ {
5+ if (argc < 3 )
6+ {
7+ help ();
8+ return 0 ;
9+ }
10+ else
11+ {
12+ FILE * input ;
13+ FILE * output ;
14+ char * line = NULL ;
15+ ssize_t linelen = -1 ;
16+ size_t len = 0 ;
17+
18+ input = fopen (argv [1 ], "r" );
19+ if (input == NULL )
20+ {
21+ perror ("Could not open input file" );
22+ return 1 ;
23+ }
24+
25+ output = fopen (argv [2 ], "w" );
26+ if (output == NULL )
27+ {
28+ perror ("Could not open output file" );
29+ return 2 ;
30+ }
31+
32+ linelen = getline (& line , & len , input );
33+ while (linelen > -1 )
34+ {
35+ puts (line );
36+ linelen = getline (& line , & len , input );
37+ }
38+
39+ }
40+
41+ }
42+
43+ void help (void )
44+ {
45+ puts ("This is the low level assembler for the Nibble Knowledge 4-bit computer" );
46+ puts ("" );
47+ puts ("Usage: as4 input output" );
48+
49+ }
Original file line number Diff line number Diff line change 1+ #define _GNU_SOURCE
2+ #include <stdio.h>
3+ #include <stdlib.h>
4+
5+ void help (void );
You can’t perform that action at this time.
0 commit comments