Visual Brainf*ck JS

Brainf*ckという プログラミング言語の動作を、視覚的に分かりやすいように実装しました。
This is an implementation to be easy to understand visually whose a programming language is named Brainf*ck.

使い方

「Ex.1 3x Loop」ボタンを押して下さい。3回ループのサンプルコードがSourceに読み込まれます。
「Poke」ボタンを押して下さい。SourceのコードをProgramに書き込みます。
Runボタンを押して下さい。Programのコードが実行されます。

How to use

Please push the "Ex. 1 3x Loop" button. Example code of 3 times loop will be loaded to Source.
Push the "Poke" button. It pokes the code in Source into Program.
Push the "Run" button. The code in Program section will be executed.

Interpreter

Source

Program

pc: prg[pc]:

Memory

ptr: mem[ptr]:

stdin history

stdout

Operation Buttons

Run Delay(ms) 1 upto 10000
Memory Size 20 upto 10000

説明

Source

コードを編集するところです。ここのコードは実行されません。
Ex.1 3x Loop
3回ループのサンプルコードがSourceに読み込まれます。0番地をループカウンタにして、1番地で2✕3を計算します。
Poke
SourceのコードをProgramに書き込みます。
Peek
ProgramのコードをSourceに読み戻します。
Save
コードをブラウザに保存します。
Load
ブラウザに保存されたコードを読み込みます。
Clear
編集領域を空にします。

Program

実行されるコードです。
pc
プログラムカウンター。次に実行されるコマンドの位置です。
prg[pc]
プログラムカウンターの位置にあるコマンドです。
Idx
コマンドの位置です。
Cmd
コマンドです。

Memory

メモリーです。見やすさのために大きさを20にしています。
ptr
ポインターです。
mem[ptr]
ポインターが指すメモリーのデータです。
Adr
メモリーアドレスです。
Dat
データです。
Chr
データに当たるASCII文字です。

stdin history

入力した文字の履歴です。

stdout

出力です。

Operation Buttons

Brainf*ck Interpreterを操作するボタンです。
Run
コードを実行します。
Abort
実行を中断します。Runによる実行中でなければ、このボタンは働きません。
Step
pcを1つ進めて、その位置のCmdを実行します。Loopの最中では、対応する角括弧を探します。
Rerun
AbortまたはStepの途中からコードを実行します。
Reset
pcやptr、memを初期化します。
Clear
コードや、pc、ptr、memを初期化します。
< > + - [ ] , .
現在のpcの位置に該当するCmdを足して、実行します。「]」を足した後はStepを押し、Loopを戻る操作をして下さい。
Run Delay(ms)
Runによる実行で、Cmdを1つ実行した後に待機する時間を指定します。変化を見やすくするためです。1から10000の間が指定できます。
Memory Size
Memory Sizeを指定します。20から10000の間が指定できます。

Reference

Source

The edit area for code. You cannot execute code in this area.
Ex.1 3x Loop
Loads Example code, 3 times loop, to the Source. The code calculates 2 times 3 in address 1 by address 0 as a loop counter.
Poke
Pokes the code in Srouce into Program.
Peek
Peeks the code in Program into Source.
Save
Save code to browser.
Load
Load code saved in browser.
Clear
Clear the edit area.

Program

Code to execute.
pc
Program counter. Position of command to be executed next.
prg[pc]
Pointed command by the program counter.
Idx
Index of commands.
Cmd
Commands

Memory

The memory. The size is 20 to be good for view.
ptr
The pointer
mem[ptr]
The data pointed by pointer.
Adr
The address
Dat
The data
Chr
Ascii characters of the data value.

stdin history

History of input characters.

stdout

The outputs

Operation Buttons

The operation buttons for Brainf*ck Interpreter.
Run
Run the code.
Abort
Abort execution. This button works while executing by run button only.
Step
Advances program counter one step and execute command at the program counter is pointing. In a loop, it searches other square bracket to be paired.
Rerun
Rerun the code in the process of Abort or Step.
Reset
Initialize pc, ptr and mem.
Clear
Initialize Program, pc, ptr and mem.
< > + - [ ] , .
Adding the commadn at position of program counter, then execute it. After "]" button pushed, push the Step button to go back the loop.
Run Delay(ms)
Sets wait time after execution one command by Run button. This is to watch good. You can set 1 up to 10000.
Memory Size
Sets Memory Size. You can set 1 up to 10000.

About

Repository

https://github.com/quwahara/VisualBrainfuckJs/tree/master

Author

Mitsuaki Kuwahara (twitter: @quwahara, github: quwahara, FB: mitsuaki.kuwahara)

License

The MIT License (MIT) Copyright (c) 2015 Mitsuaki Kuwahara Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.