Brainfunk: Porovnání verzí

Z ZděchovNET
Skočit na navigaci Skočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 1: Řádek 1:
=Overview=
==Overview==


Brainfunk is derivative of [[Brainfuck]] language with aims to:
Brainfunk is derivative of [[Brainfuck]] language with aims to:
* Unify cell pointer and cell increment and decrement operations to single + and - operations. Remove > and < operations.
* Unify cell pointer and cell value increment and decrement operations to single + and - operations. Remove > and < operations.
* Introduce fast copy instruction usable between all address spaces.
* Introduce fast copy instruction usable between all address spaces.
* Allow macro definition for custom symbol definition and code reduction
* Allow to read/write program space
* Support multiple I/O ports for additional hardware addressing
* Enable brainfuck compatible mode
* Allow absolute integer constants


==Commands==
{| class="wikitable"
{| class="wikitable"
!Command
! Command
!Description
! Description
|-
|-
| style="text-align:center"| <code><nowiki>+</nowiki></code>
| style="text-align:center"| <code><nowiki>^</nowiki></code>
| Increment value
| Increment selected object
|-
|-
| style="text-align:center"| <code><nowiki>-</nowiki></code>
| style="text-align:center"| <code><nowiki><</nowiki></code>
| Decrement value
| Decrement selected object
|-
|-
| style="text-align:center"| <code>[</code>
| style="text-align:center"| <code>(</code>
| Jump past the matching <code>]</code> if the value is 0
| Jump past the matching <code>)</code> if the object value is zero
|-
|-
| style="text-align:center"| <code>]</code>
| style="text-align:center"| <code>)</code>
| Jump back to the matching <code>[</code> if the value is nonzero
| Jump back to the matching <code>(</code> if the object value is nonzero
|-
|-
| style="text-align:center"| <code><nowiki>#</nowiki></code>
| style="text-align:center"| <code><nowiki>_</nowiki></code>
| No operation, clear object selection index
| Switch value to memory space
|-
|-
| style="text-align:center"| <code><nowiki>&</nowiki></code>
| style="text-align:center"| <code><nowiki>$</nowiki></code>
| Increment object selection index
| Switch value to pointer space
|-
| style="text-align:center"| <code><nowiki>~</nowiki></code>
| Copy value from previous selected object to current selected object
|-
| style="text-align:center"| <code><nowiki>:</nowiki></code>
| Start macro, first symbol to the right is new defined symbol
|-
| style="text-align:center"| <code>;</code>
| End macro started by :
|}

{| class="wikitable"
|+ Object table
! Index
! Description
|-
| 0 || A - Accumulator
|-
| 1 || DP - Data pointer
|-
| 2 || (DP) - Data value
|-
| 3 || IP - Interface pointer
|-
| 4 || (IP) - Interface value
|-
| 5 || PC - Program counter
|-
| 6 || PP - Program pointer
|-
| 7 || (PP) - Program value
|-
| 8 || SP - Stack pointer
|-
| 9 || (SP) - Stack value
|}

{| class="wikitable"
|+ Port address table
! Address
! Description
|-
| 0 || Null
|-
| 1 || Standard input
|-
| 2 || Standard output
|-
| 3 || Delay [ms]
|-
| 4 || Sound [Hz]
|}

==Macros==

{| class="wikitable"
! Brainfuck
! Brainfunk
|-
| style="text-align:center"| <code><nowiki>+</nowiki></code>
|
|-
| style="text-align:center"| <code><nowiki><</nowiki></code>
| Decrement selected object
|-
| style="text-align:center"| <code>(</code>
| Jump past the matching <code>)</code> if the object value is zero
|-
| style="text-align:center"| <code>)</code>
| Jump back to the matching <code>(</code> if the object value is nonzero
|-
| style="text-align:center"| <code><nowiki>_</nowiki></code>
| No operation, clear object selection index
|-
|-
| style="text-align:center"| <code><nowiki>$</nowiki></code>
| style="text-align:center"| <code><nowiki>$</nowiki></code>
| Increment object selection index
| Switch value to I/O space
|-
| style="text-align:center"| <code><nowiki>~</nowiki></code>
| Copy value from previous selected object to current selected object
|-
|-
| style="text-align:center"| <code><nowiki>@</nowiki></code>
| style="text-align:center"| <code><nowiki>:</nowiki></code>
| Start macro, first symbol to the right is new defined symbol
| Switch value to accumulator space
|-
|-
| style="text-align:center"| <code>%</code>
| style="text-align:center"| <code>;</code>
| End macro started by :
| Copy from previous memory space to current space
|}
|}


=Brainfuck comparison=
==Brainfuck comparison==


{| class="wikitable"
{| class="wikitable"
Řádek 70: Řádek 152:
| Swap value || <code>>[-]<<[->>+<<]>[-<+>]>[-<+>]</code> || <code>#@%&++@#%&-#@%&-@#%&++#@%&-@#%</code>
| Swap value || <code>>[-]<<[->>+<<]>[-<+>]>[-<+>]</code> || <code>#@%&++@#%&-#@%&-@#%&++#@%&-@#%</code>
|}
|}



[[Kategorie:Programování]]
[[Kategorie:Programování]]

Verze z 16. 7. 2012, 11:50

Overview

Brainfunk is derivative of Brainfuck language with aims to:

  • Unify cell pointer and cell value increment and decrement operations to single + and - operations. Remove > and < operations.
  • Introduce fast copy instruction usable between all address spaces.
  • Allow macro definition for custom symbol definition and code reduction
  • Allow to read/write program space
  • Support multiple I/O ports for additional hardware addressing
  • Enable brainfuck compatible mode
  • Allow absolute integer constants

Commands

Command Description
^ Increment selected object
< Decrement selected object
( Jump past the matching ) if the object value is zero
) Jump back to the matching ( if the object value is nonzero
_ No operation, clear object selection index
$ Increment object selection index
~ Copy value from previous selected object to current selected object
: Start macro, first symbol to the right is new defined symbol
; End macro started by :
Object table
Index Description
0 A - Accumulator
1 DP - Data pointer
2 (DP) - Data value
3 IP - Interface pointer
4 (IP) - Interface value
5 PC - Program counter
6 PP - Program pointer
7 (PP) - Program value
8 SP - Stack pointer
9 (SP) - Stack value
Port address table
Address Description
0 Null
1 Standard input
2 Standard output
3 Delay [ms]
4 Sound [Hz]

Macros

Brainfuck Brainfunk
+
< Decrement selected object
( Jump past the matching ) if the object value is zero
) Jump back to the matching ( if the object value is nonzero
_ No operation, clear object selection index
$ Increment object selection index
~ Copy value from previous selected object to current selected object
: Start macro, first symbol to the right is new defined symbol
; End macro started by :

Brainfuck comparison

Description Brainfuck Brainfunk
Increment value + #+
Decrement value - #-
Move the pointer to the right < &+
Move the pointer to the left > &-
Write cell to output . #$%
Read input to cell , $#%
Skip loop if cell is zero [ [
Loop back if cell is nonzero ] ]
Cat ,[.,] $#%[$%#%]
Clear value [-] #[-]
Move value >[-]<[->+<] &+#[-]&-#[-&+#+&-#]
Copy value >[-]>[-]<<[->+>+<<]>>[-<<+>>] #@%&+@#%
Swap value >[-]<<[->>+<<]>[-<+>]>[-<+>] #@%&++@#%&-#@%&-@#%&++#@%&-@#%