昨天我去翻ccsdn,发现了一个叫brain**的语言
然后我去搜它,结果……
我发现了Esolang Wiki
上面的编程语言……总之就是很奇怪(
我找到了这样一个语言,代码由空格、Tab和换行符组成:whitespace
我去搜它的编译器,找到了一个在线版本
https://vii5ard.github.io/whitespace/
我用它写了自己的第一段Esolang,但是……
它不是“Hello,world!”,而是一个能循环输出“e”的程序
这是它的代码:
复制代码什么也没看到?看不懂?没关系,我也看不懂,这是它的汇编版本:
复制代码
现在来看,汇编是不是简单多了
然后我去搜它,结果……

我发现了Esolang Wiki
上面的编程语言……总之就是很奇怪(
我找到了这样一个语言,代码由空格、Tab和换行符组成:whitespace

我去搜它的编译器,找到了一个在线版本
https://vii5ard.github.io/whitespace/

我用它写了自己的第一段Esolang,但是……
它不是“Hello,world!”,而是一个能循环输出“e”的程序
这是它的代码:
- label_1:
- push 101
- printc
- jmp label_1
- end
现在来看,汇编是不是简单多了

brainfk:指大脑的健身cao(大雾
还是没看懂(悲),我是贵物
挺羡慕你们,还有时间来鼓捣这种东西。现在临近中考,都基本没时间了(
有没有人和我一样在补作业
咏e≠咏鹅
嘿嘿
嘿嘿
装13性 +10000000000000
可读性 -∞

可读性 -∞

开心的阿诺 发表于 2023-2-4 17:49
brainf uck后继有人 lol
https://www.mcbbs.net/thread-1356614-1-1.html
这是whitespace写的brain**编译器

wsseieiei 发表于 2023-2-4 18:00
这是whitespace写的brain**编译器
自己写的吗 ∑(°Д°;
开心的阿诺 发表于 2023-2-4 18:01
自己写的吗 ∑(°Д°;
不是
是whitespace编译器自带的样例
证明了whitespace是图灵完备的语言(
这是汇编,whitespace可以和汇编互转:
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Read input until enter
- ;; start from address 100
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- push '%'
- printc
- push ' '
- printc
- push 100 ; start filling data
- .readLoop:
- dup
- readc ; read char
- dup
- retrieve ; retrieve last from heap
- dup
- push '\n'
- sub
- jz .loopEnd ; end loop if enter
- dup
- push '>' ; Check if '>'
- sub
- jz .incPP
- dup
- push '<'
- sub
- jz .incPP
- dup
- push '+'
- sub
- jz .incPP
- dup
- push '-'
- sub
- jz .incPP
- dup
- push '.'
- sub
- jz .incPP
- dup
- push ','
- sub
- jz .incPP
- dup
- push '['
- sub
- jz .incPP
- dup
- push ']'
- sub
- jz .incPP
- drop
- jmp .readLoop
- .incPP:
- drop
- push 1 ; increase program pointer
- add
- jmp .readLoop
- .loopEnd:
- drop
- dup
- push 0 ; replace newline with 0
- store
- push 1
- add ; increase pointer (new SP start in heap)
- push 100 ; push PP
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Run the stored program
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .runLoop:
- ; get the instruction @PP
- dup
- retrieve
- ; break execution when instruction == 0
- dup
- jz .endProgram
- ; check if instruction +
- .ifInc:
- dup
- push '+'
- sub
- jz .instInc
- jmp .ifDec
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction +
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instInc:
- drop
- copy 1
- dup
- retrieve
- push 1
- add
- store
- jmp .runLoopContinue
- ; check if instruction -
- .ifDec:
- dup
- push '-'
- sub
- jz .instDec
- jmp .ifShr
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction -
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instDec:
- drop
- copy 1
- dup
- retrieve
- push 1
- sub
- store
- jmp .runLoopContinue
- ; check if instruction >
- .ifShr:
- dup
- push '>'
- sub
- jz .instShr
- jmp .ifShl
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction >
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instShr:
- drop
- swap
- push 1
- add
- swap
- jmp .runLoopContinue
- ; check if instruction <
- .ifShl:
- dup
- push '<'
- sub
- jz .instShl
- jmp .ifPrnt
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction <
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instShl:
- drop
- swap
- push 1
- sub
- swap
- jmp .runLoopContinue
- ; check if instruction .
- .ifPrnt:
- dup
- push '.'
- sub
- jz .instPrnt
- jmp .ifRead
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction .
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instPrnt:
- drop
- copy 1
- retrieve
- printc
- jmp .runLoopContinue
- ; check if instruction ,
- .ifRead:
- dup
- push ','
- sub
- jz .instRead
- jmp .ifLoopFwd
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction ,
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instRead:
- drop
- copy 1
- readc
- jmp .runLoopContinue
- ; check if instruction [
- .ifLoopFwd:
- dup
- push '['
- sub
- jz .instLoopFwd
- jmp .ifLoopBwd
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction [
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .instLoopFwd:
- drop
- ; get data from heap
- copy 1
- retrieve
- ; continue only when heap value is non-zero
- jz .noFwdLoop ; do not continue if *SP == 0
- jmp .runLoopContinue
- .noFwdLoop:
- push 1 ; bracket count
- .skipFwd:
- ; break when found matching bracket
- dup
- jz .skipFwdEnd
- ; increase PP
- swap
- push 1
- add
- swap
- ; get next instruction
- copy 1
- retrieve
- ; exit when end program
- dup
- jz .endProgram ; end program if no matching ] found
- ; check if next instruction is a [
- dup
- push '['
- sub
- jz .incBracketCount
- jmp .checkIfEndBracket
-
- .incBracketCount:
- drop
- push 1
- add
- jmp .skipFwd
- .checkIfEndBracket:
- push ']'
- sub
- jz .decBracketCount
- jmp .skipFwd
- .decBracketCount:
- push 1
- sub
- jmp .skipFwd
- .skipFwdEnd:
- drop
- jmp .runLoopContinue
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Instruction ]
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .ifLoopBwd:
- dup
- push ']'
- sub
- jz .instLoopBwd
- jmp .runLoopContinue
- ; run instruction ]
- .instLoopBwd:
- drop
- ; get data from heap
- copy 1
- retrieve
- ; continue only when heap value is zero
- jz .runLoopContinue ; do not loop back if *SP == 0
- ; start looping back
- push -1 ; bracket count
- .skipBwd:
- ; break when found matching bracket
- dup
- jz .skipBwdEnd
- ; decrease PP
- swap
- push 1
- sub
- swap
- ; get previous instruction
- copy 1
- retrieve
- ; exit when end program
- dup
- jz .endProgram ; end program if no matching ] found
- ; check if next instruction is a [
- dup
- push '['
- sub
- jz .incBracketCountBwd
- jmp .checkIfEndBracketBwd
-
- .incBracketCountBwd:
- drop
- push 1
- add
- jmp .skipBwd
- .checkIfEndBracketBwd:
- push ']'
- sub
- jz .decBracketCountBwd
- jmp .skipBwd
- .decBracketCountBwd:
- push 1
- sub
- jmp .skipBwd
- .skipBwdEnd:
- drop
- jmp .runLoopContinue
- .runLoopContinue:
- push 1
- add ; increase PP
- jmp .runLoop ; continue with run
- .endProgram:
- end
乐啊,但我不会汇编
fun fact:
1. brain**其实就是一个图灵机(
2. 蓝鸡喜欢在他的解密里塞Esolang
1. brain**其实就是一个图灵机(
2. 蓝鸡喜欢在他的解密里塞Esolang
inuEbisu 发表于 2023-2-4 18:21
fun fact:
1. brain**其实就是一个图灵机(
2. 蓝鸡喜欢在他的解密里塞Esolang
明白了,那个schematic文件最下面一层是个esolang是吧(
写代码的人看得懂这是啥吗
