From 94d6cb4fa084d6b4416198c32555a9d129b292ce Mon Sep 17 00:00:00 2001 From: Takym <15681312+Takym@users.noreply.github.com> Date: Mon, 4 Mar 2024 06:15:05 +0900 Subject: [PATCH] BinFuck v0.0.0.3 --- BinFuck/BinFuck.csx | 34 ++++++++++++++++++++++++---------- BinFuck/README.md | 4 +++- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/BinFuck/BinFuck.csx b/BinFuck/BinFuck.csx index 069eea0..1c9f572 100644 --- a/BinFuck/BinFuck.csx +++ b/BinFuck/BinFuck.csx @@ -1,6 +1,6 @@ /////// // ////// The BinFuck Interpreter /// -///// Copyright (C) 2020-2023 Takym. //// +///// Copyright (C) 2020-2024 Takym. //// //// ///// /// distributed under the MIT License. ////// // /////// @@ -9,7 +9,7 @@ #r "System.Console" using static System.Console; -string version = "0.0.0.2"; +string version = "0.0.0.3"; if (Args.Count == 0) { ShowUsage(); @@ -171,7 +171,13 @@ public class Runner _memory[_stack_point] = funcid; break; case '@': // Call a function - this.Run(_funcs[unchecked((int)(_memory[_stack_point] / _funcs.Count))]); + int funcCount = _funcs.Count; + if (funcCount > 0) { + int funcIdx = unchecked((int)(_memory[_stack_point])); + if (funcIdx < funcCount) { + this.Run(_funcs[funcIdx]); + } + } break; case '.': // Clear memory _memory[_stack_point] = 0; @@ -211,15 +217,14 @@ public class Runner } break; case 'D': // Dump the runner information - WriteLine("Functions:"); - for (int j = 0; j < _funcs.Count; ++j) { - WriteLine("#{0}#", j); - WriteLine(_funcs[j]); - WriteLine(); - } + WriteLine("Encoding: {0}", _enc.EncodingName); + WriteLine("Memory Size: {0}", _memory.Length); + WriteLine("Memory Type: {0}", _memory[0].GetType()); WriteLine("Stack Point: {0}", _stack_point); WriteLine("Do Subtract: {0}", _do_subtract); - goto case 'd'; + WriteLine("Use the \'d\' instruction to dump the memory."); + WriteLine("Use the \'_\' instruction to dump the list of functions."); + break; case 'd': // Dump the memory Write("Memory:"); for (int j = 0; j < _memory.Length; ++j) { @@ -228,6 +233,15 @@ public class Runner } Write("{0:X16} ", _memory[j]); } + WriteLine(); + break; + case '_': // Dump the list of functions + WriteLine("Functions:"); + for (int j = 0; j < _funcs.Count; ++j) { + WriteLine("#{0}#", j); + WriteLine(_funcs[j]); + WriteLine(); + } break; case '+': // Increment unchecked { ++_memory[_stack_point]; } diff --git a/BinFuck/README.md b/BinFuck/README.md index fecccbc..efb28c4 100644 --- a/BinFuck/README.md +++ b/BinFuck/README.md @@ -1,5 +1,5 @@ # The BinFuck Interpreter -Copyright (C) 2020-2023 Takym. +Copyright (C) 2020-2024 Takym. [日本語](#概要) @@ -8,6 +8,7 @@ BinFuck is an esoteric programming language. I developed by drawing on [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck). The naming origin is a programming language like machine language (binary). Try `1[>rw<]` in REPL mode! +Use `Dd_` to dump data. ## How to use @@ -39,6 +40,7 @@ BinFuck は難解プログラミング言語です。 [Brainfuck](https://ja.wikipedia.org/wiki/Brainfuck) を参考に開発しました。 機械語(binary)の様なプログラミング言語であるというのが名称の由来です。 REPL モードで `1[>rw<]` を試してみてください。 +内部データを表示するには `Dd_` と入力してください。 ## 使い方