Skip to content

Commit

Permalink
BinFuck v0.0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Takym committed Mar 3, 2024
1 parent 632ad6c commit 94d6cb4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
34 changes: 24 additions & 10 deletions BinFuck/BinFuck.csx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/////// //
////// The BinFuck Interpreter ///
///// Copyright (C) 2020-2023 Takym. ////
///// Copyright (C) 2020-2024 Takym. ////
//// /////
/// distributed under the MIT License. //////
// ///////
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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]; }
Expand Down
4 changes: 3 additions & 1 deletion BinFuck/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The BinFuck Interpreter
Copyright (C) 2020-2023 Takym.
Copyright (C) 2020-2024 Takym.

[日本語](#概要)

Expand All @@ -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

Expand Down Expand Up @@ -39,6 +40,7 @@ BinFuck は難解プログラミング言語です。
[Brainfuck](https://ja.wikipedia.org/wiki/Brainfuck) を参考に開発しました。
機械語(binary)の様なプログラミング言語であるというのが名称の由来です。
REPL モードで `1[>rw<]` を試してみてください。
内部データを表示するには `Dd_` と入力してください。

## 使い方

Expand Down

0 comments on commit 94d6cb4

Please sign in to comment.