From c66bed3deeea3c5edc16a81ca7d02fe961c16b17 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Fri, 29 Jan 2021 22:29:59 +0100 Subject: [PATCH] Updated READMEs and added comments to compiler.py --- README.md | 2 +- TronScript_README.txt | 6 ++---- compiler.py | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 71f4bf4..a5bc4db 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The emulator / debugger... ### compiler.py / compiler_beta.py This compiler compiles from 'tronScript' to a binary save-state of the emulator. It has been designed with the main priority of being as easy as possible to compile. Usability was ~~maybe~~ impacted by this decisio. -I forgot, what the difference between normal and beta is... +compiler_beta does not work, but contains code to add stack / push / pop functionality to tronScript. More information about tronScript can be found in TronScript_README.txt diff --git a/TronScript_README.txt b/TronScript_README.txt index 71b14ea..e265c54 100644 --- a/TronScript_README.txt +++ b/TronScript_README.txt @@ -3,9 +3,10 @@ tronScript is a stupid and pretty assembly-like low level language for my asmTro Available Commands: -newVar [var] - Initializes new var; not needed most of the time: +newVar [name] - Initializes new var; not needed most of the time: Compiler automatically initializes new vars when used, so this is no longer necessary... +newArray [name] [len] - Initializes a new array with length len. 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] @@ -46,6 +47,3 @@ function [funcName] { - Defines function [funcName] with code } to store the jump-back-address... :P Fun Fact: Pascal used to do a similar thing, which is why you couldn't do recursion in early versions of Pascal. - -Q: There are some command ś that operate on an array. How do I initialize one? -A: Good Question. Do you know, what defines a good question? That you dont have an answer to it... diff --git a/compiler.py b/compiler.py index 7d3b4c3..d2741ae 100644 --- a/compiler.py +++ b/compiler.py @@ -38,6 +38,8 @@ def compile(cmd,par,memAddr): print("Creating array '"+par[0].upper()+"' at memory-space "+padBin(len(varRec)+(2**8)/2)+" - "+padBin(len(varRec)+int(par[1])+(2**8)/2)) for i in range(int(par[1])): varRec["array_"par[0].upper()+"["+i+"]"] = len(varRec)+(2**8)/2 + # Yes, we implement array by just having variables named array_{name}[0] to array_{name}[n]; deal with it! + # (But they mapped into memory like you would expect; so pointer arithmetic should be possible...) elif cmd=="jumpMark": # creates a jumpMark and saves current adress in the DB for later use by the jump-name-replacement print("Creating jumpMark '"+par[0].upper()+"' at memory-address "+padBin(memAddr)) jumpMark[par[0].upper()] = memAddr