From 464ac2c877396d26b4b3acddaef27be0ff8287c6 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Mon, 23 Nov 2020 20:19:42 +0100 Subject: [PATCH] folder layout changed, README updated --- README.md | 52 ++++++++++++++++++- asm.pyc | Bin 15950 -> 0 bytes multiply_test.txt => tests/multiply_test.txt | 0 pow_test.txt => tests/pow_test.txt | 0 test.asmTron => tronScript/test.asmTron | Bin 5 files changed, 50 insertions(+), 2 deletions(-) delete mode 100644 asm.pyc rename multiply_test.txt => tests/multiply_test.txt (100%) rename pow_test.txt => tests/pow_test.txt (100%) rename test.asmTron => tronScript/test.asmTron (100%) diff --git a/README.md b/README.md index 985ef57..a1b7ea4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ asmTron is a compiler / emulator for a 12-bit cpu (4-bit opcodes, 8-bit adresses), that I started building in Minecraft. I never finished the Minecraft-Build, but this emulator is fully functional and even has integrated debugging capabilities. -This programm is optimized for a very specific terminal-size and a global variable has to be changed to switch between Windows / Linux compatability. +This programm is optimized for a very specific terminal-size and a global variable has to be changed to switch between Windows / Linux compatability. ### asm.py The emulator / debugger... @@ -13,7 +13,55 @@ This compiler compiles from 'tronScript' to a binary save-state of the emulator. I forget, what the difference between normal and beta is... ### mima.py -A variation of asm.py to emulate a MiMa (minimal machine). +A variation of asm.py to emulate a MiMa (minimal machine). No, the compiler can not compile for this architecture. ### asmCust.py Does not work (I think...) + + +## TronScript +tronScript is a stupid assembly-like low level language for my asmTron emulator + + +Available Commands: + +newVar [var] - Initializes new var; not needed most of the time: + Compiler automatically initializes new vars when used +jumpMark [jumpMark name] - Sets an JumpMark to jump to using the "jump" command +jump [jumpMark name] - Jumps to an JumpMark +getVarAddress [var A] [var B] - Saves [var A]'s memory-address into [var B] +getArrayAddress [array] [index] [var] - Saves [array][[index]]'s memory-adress into [var] +exec [func name] - Executes function with name [func name] +setVar [var] [value] - Sets var [var] to [value] (decimal) +setVar [var] b[value] - Sets var [var] to [value] (binary) +setArrayIndex [array] [index] [value] - Sets [array][[index]] to [value] (decimal) +setArrayIndex [array] [index] b[value] - Sets [array][[index]] to [value] (binary) +getArrayIndex [array] [index] [var] - Stores the content of [array][[index]] into var [var] +copyVar [var A] [var B] - Copies to value of [var A] to [var B] (B=A) +write [var] - Writes value of [var] to console +read [var] - Reads input from console into [var] +add [var A] [var B] [var OUT] - Adds [var A] + [var B] = [var OUT] +subtract [var A] [var B] [var OUT] - Subtracts [var A] - [var B] = [var OUT] +if [var A] [??] [var B] [cmd] [pars] - ?? = [==,!=,>,<,>=,<=] if clause is true, + executes [cmd] with [pars] +for [goal] [counter] [step] [cmd] [pars]- Sets [counter] = 0; Executes [cmd] with [pars] and + adds [step] to [counter], until [goal]==[counter] +:[asm] v#[var] - Executes [asm]-assembler command with par [var] +:[asm] d#[par] - Executes [asm]-assembler command with par [par] (decimal) +:[asm] b#[par] - Executes [asm]-assembler command with par [par] (binary) +:[asm] - - Executes [asm]-assembler command with par b#00000000 / d#0 +:[asm] ~ - Executes [asm]-assembler command with par b#11111111 / d#255 +shellcode [code] - Executes binary code [code] +nop - Nothing; sleep one cycle +halt - Stops execution of program; automatically added to the end of + your program if not present + +function [funcName] { - Defines function [funcName] with code [funcCode] + [funcCode line 1] ! Every function can only have one instance at a time: + [funcCode line 2] ! A function shall not call itself and a sub function shall + [funcCode line 3] ! not call any of its root functions !!! + . ! If you need this functionality, implement it in assembly... + . + . Why is that so? This is a stupid compiler, which does not use + [funcCode line n] a stack to return from functions, but a function-specific variable +} to store the jump-back-address... :P diff --git a/asm.pyc b/asm.pyc deleted file mode 100644 index 2e4c5a611b1d68ad831e45d2791135d1c88daef6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15950 zcmcgzd3an`b-!;Ujdoj`JyPQ3IZkYO8Out%B#z=(v206@Eh{4#nGwQ_=01;}Je%Gd z*^*-e#R*F&Yg;H?C}C@%6k1XWEo&NsUIiPD)`%q`vH9YZ}cdo@v&4^sbm?pRMHCD zBP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