diff --git a/.clang-format b/.clang-format new file mode 100755 index 0000000..08958a8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,15 @@ +#BasedOnStyle: None +AlignTrailingComments: true +BreakBeforeBraces: Allman +ColumnLimit: 0 +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PointerBindsToType: false +SpacesBeforeTrailingComments: 1 +TabWidth: 4 +UseTab: Never + +AlignArrayOfStructures: Right +SpaceBeforeSquareBrackets: false diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..c155c8d --- /dev/null +++ b/.gitignore @@ -0,0 +1,70 @@ +# ---> C +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex +eipaasm +eipaasm_debug +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +#EIPA specific +*.eipa +!test*.eipa +*.eipaimg + +#Code editor +.vscode/* +.idea/* +compile_commands.json +.cache/* +.#* +*.*~ + +#Code analysis +softwipe*.* \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..82b7936 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +CC := clang +CFLAGS := -Wall -Wextra +SRC_DIR := src +HEADER_DIR := header +BUILD_DIR := build +LIBS := +OBJECT_FILES := $(patsubst %.c, %.o, $(wildcard $(SRC_DIR)/*.c)) +HEADER_FILES := $(wildcard $(HEADER_DIR)/*.h) +OBJECT_FILES := $(patsubst $(SRC_DIR)/%, $(BUILD_DIR)/%, $(OBJECT_FILES)) +MAIN_EXE_NAME := eipaemulator + +all build/eipaemulator: $(OBJECT_FILES) + $(CC) $(CFLAGS) $^ $(LIBS) -o $(BUILD_DIR)/$(MAIN_EXE_NAME) + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(HEADER_FILES) + @mkdir -p $(BUILD_DIR) + $(CC) -c $(CFLAGS) $(patsubst %.h,,$^) -o $@ + +clean: + rm -r $(BUILD_DIR) diff --git a/build/eipaemulator b/build/eipaemulator new file mode 100755 index 0000000..d408ffa Binary files /dev/null and b/build/eipaemulator differ diff --git a/design.txt b/design.txt new file mode 100755 index 0000000..35e6114 --- /dev/null +++ b/design.txt @@ -0,0 +1,24 @@ +Instructions: + INP 0b0001 | +Adress + OUT 0b0010 | +Adress + LDA 0b0011 | +Adress + STA 0b0100 | +Adress + INC 0b0101 | no Adress + DEC 0b0110 | no Adress + JPP 0b0111 | +Adress/Label + JPZ 0b1000 | +Adress/Label + JPN 0b1001 | +Adress/Label + JPU 0b1010 | +Adress/Label + EOJ 0b1011 | no Adress + +Instruction format, [] means optional: + instruction [mem_adress]; [Comment] + +Memory: + 32 Bit Data with + 28 Bit Adresess-> 24Mb Memory + +Instruction Layout: + XXXXYYYYYYYYYYYYYYYYYYYYYYYYYYYY + X: Instruction Opcode (4bit) + Y: Memory Adress (28bit) diff --git a/src/main.c b/src/main.c new file mode 100755 index 0000000..682c079 --- /dev/null +++ b/src/main.c @@ -0,0 +1,41 @@ +// This is a part of the EIPA Platform + +// Read an EIPA image and print it out in Binary form + +#include +#include + +#define MAX_MEMORY 268435456 + +void print_target_code(__uint32_t *target_code) +{ + int instruction_index = 0; + while (target_code[instruction_index] != 0) + { + int i = 0; + for (i = (sizeof(target_code[instruction_index]) * 8) - 1; i >= 0; i--) + { + putchar(target_code[instruction_index] & (1u << i) ? '1' : '0'); + } + printf("\n"); + instruction_index++; + } +} + +int main(int argc, char const *argv[]) +{ + if(argc < 2) + { + printf("Specify input file\n"); + } + FILE *input = fopen(argv[1], "r"); + if(input == NULL) return -1; + + __uint32_t *target_code = malloc(MAX_MEMORY*sizeof(target_code)); + + fread(target_code, sizeof(target_code), MAX_MEMORY, input); + + print_target_code(target_code); + + return 0; +}