我不是wzx
昨天我去翻ccsdn,发现了一个叫brain**的语言
然后我去搜它,结果……

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


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



我用它写了自己的第一段Esolang,但是……
它不是“Hello,world!”,而是一个能循环输出“e”的程序
这是它的代码:

  1.   
  2.                                       
  3.         
  4.   





复制代码
什么也没看到?看不懂?没关系,我也看不懂,这是它的汇编版本:
  1. label_1:
  2.         push 101
  3.         printc
  4.         jmp label_1
  5.         end
复制代码

现在来看,汇编是不是简单多了


LinGCar
brainfk:指大脑的健身cao(大雾

DarkLiam
还是没看懂(悲),我是贵物

骰出的名字
挺羡慕你们,还有时间来鼓捣这种东西。现在临近中考,都基本没时间了(

苦行生
有没有人和我一样在补作业

Qhxss
咏e≠咏鹅
嘿嘿

MoonCakeMC
装13性 +10000000000000
可读性 -∞

开心的阿诺
本帖最后由 开心的阿诺 于 2023-2-4 17:51 编辑

brainf uck后继有人 lol
https://www.mcbbs.net/thread-1356614-1-1.html

我不是wzx
开心的阿诺 发表于 2023-2-4 17:49
brainf uck后继有人 lol
https://www.mcbbs.net/thread-1356614-1-1.html

这是whitespace写的brain**编译器
  1.                              
  2.        
  3.                   
  4.        
  5.                                  

  6.   

  7.        
  8.           
  9.                          
  10.                       
  11.                  
  12.                 

  13.                                              
  14.                  
  15.                   

  16.                                       
  17.                  
  18.                   

  19.                                      
  20.                  
  21.                   

  22.                                      
  23.                  
  24.                   

  25.                                       
  26.                  
  27.                   

  28.                                
  29.                  
  30.                   

  31.                                              
  32.                  
  33.                   

  34.                                              
  35.                  
  36.                   






  37.            


  38.           
  39.           



  40.          



  41.    
  42.                            
  43.                                           

  44.                  

  45.                          

  46.                    

  47.                   

  48.                                      
  49.                  
  50.                           


  51.                        

  52.                    


  53.                  

  54.                                   
  55.                             

  56.           

  57.                          

  58.                                      
  59.                  
  60.                           


  61.                   

  62.                    


  63.                  

  64.                                   
  65.                                    

  66.           

  67.                     

  68.                                              
  69.                  
  70.                                  


  71.                   

  72.                           



  73.                   
  74.             
  75.        

  76.           

  77.                     

  78.                                       
  79.                  
  80.                                  


  81.                          

  82.                           



  83.                   
  84.                    
  85.        

  86.           

  87.                            

  88.                                       
  89.                  
  90.                                         


  91.             

  92.                                  


  93.                  
  94.                                
  95.   

  96.           

  97.               

  98.                                
  99.                  
  100.                            


  101.                    

  102.                     


  103.                  
  104.        
  105.          

  106.           

  107.                      

  108.                                              
  109.                  
  110.                                   


  111.                    

  112.                            


  113.                  
  114.                        
  115.                                   


  116.           

  117.                            
  118.           

  119.                             


  120.                                          

  121.                   
  122.             
  123.                           
  124.                          

  125.                    

  126.                                              
  127.                  
  128.                            


  129.                          

  130.                     


  131.           
  132.           

  133.                           

  134.                            
  135.                                             
  136.                  
  137.                                    


  138.                           

  139.                             
  140.           
  141.                  

  142.                           

  143.                                   




  144.           

  145.                      

  146.                                              
  147.                  
  148.                                          


  149.           

  150.                                   


  151.                  
  152.                        
  153.                    
  154.                  

  155.                             


  156.                                          

  157.                   
  158.                    
  159.                           
  160.                          

  161.                    

  162.                                              
  163.                  
  164.                                           


  165.                                        

  166.                                    


  167.           
  168.           

  169.                           

  170.                                          
  171.                                             
  172.                  
  173.                       


  174.                           

  175.                
  176.           
  177.                  

  178.                           

  179.                                   




  180.           

  181.             
  182.           
  183.           

  184.                

  185.             



复制代码



开心的阿诺
wsseieiei 发表于 2023-2-4 18:00
这是whitespace写的brain**编译器

自己写的吗 ∑(°Д°;

我不是wzx
开心的阿诺 发表于 2023-2-4 18:01
自己写的吗 ∑(°Д°;

不是
是whitespace编译器自带的样例
证明了whitespace是图灵完备的语言(
这是汇编,whitespace可以和汇编互转:
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; Read input until enter
  3. ;; start from address 100
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5.         push '%'
  6.         printc
  7.         push ' '
  8.         printc
  9.         push 100        ; start filling data
  10. .readLoop:
  11.         dup
  12.         readc                ; read char
  13.         dup
  14.         retrieve        ; retrieve last from heap

  15.         dup
  16.         push '\n'
  17.         sub
  18.         jz .loopEnd        ; end loop if enter

  19.         dup
  20.         push '>'        ; Check if '>'
  21.         sub
  22.         jz .incPP

  23.         dup
  24.         push '<'
  25.         sub
  26.         jz .incPP

  27.         dup
  28.         push '+'
  29.         sub
  30.         jz .incPP

  31.         dup
  32.         push '-'
  33.         sub
  34.         jz .incPP

  35.         dup
  36.         push '.'
  37.         sub
  38.         jz .incPP

  39.         dup
  40.         push ','
  41.         sub
  42.         jz .incPP

  43.         dup
  44.         push '['
  45.         sub
  46.         jz .incPP

  47.         dup
  48.         push ']'
  49.         sub
  50.         jz .incPP

  51.         drop
  52.         jmp .readLoop       
  53. .incPP:
  54.         drop
  55.         push 1                ; increase program pointer
  56.         add
  57.         jmp .readLoop
  58. .loopEnd:
  59.     drop
  60.         dup
  61.         push 0                ; replace newline with 0
  62.         store

  63.     push 1
  64.     add                        ; increase pointer (new SP start in heap)

  65.     push 100    ; push PP

  66. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  67. ;; Run the stored program
  68. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  69. .runLoop:

  70. ; get the instruction @PP
  71.     dup
  72.     retrieve

  73. ; break execution when instruction == 0
  74.         dup
  75.         jz .endProgram

  76. ; check if instruction +
  77. .ifInc:
  78.     dup
  79.     push '+'
  80.     sub
  81.         jz .instInc
  82.     jmp .ifDec

  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. ;; Instruction +
  85. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  86. .instInc:
  87.     drop
  88.         copy 1
  89.     dup
  90.     retrieve
  91.     push 1
  92.     add
  93.     store
  94.     jmp .runLoopContinue

  95. ; check if instruction -
  96. .ifDec:
  97.     dup
  98.     push '-'
  99.     sub
  100.     jz .instDec
  101.     jmp .ifShr

  102. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  103. ;; Instruction -
  104. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  105. .instDec:
  106.     drop
  107.     copy 1
  108.     dup
  109.     retrieve
  110.     push 1
  111.     sub
  112.     store
  113.     jmp .runLoopContinue

  114. ; check if instruction >
  115. .ifShr:
  116.     dup
  117.     push '>'
  118.     sub
  119.     jz .instShr
  120.     jmp .ifShl

  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;; Instruction >
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  124. .instShr:
  125.         drop
  126.     swap
  127.     push 1
  128.     add
  129.     swap
  130.     jmp .runLoopContinue

  131. ; check if instruction <       
  132. .ifShl:
  133.     dup
  134.     push '<'
  135.     sub
  136.     jz .instShl
  137.     jmp .ifPrnt

  138. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  139. ;; Instruction <
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  141. .instShl:
  142.         drop
  143.     swap
  144.     push 1
  145.     sub
  146.     swap
  147.     jmp .runLoopContinue

  148. ; check if instruction .
  149. .ifPrnt:
  150.     dup
  151.     push '.'
  152.     sub
  153.     jz .instPrnt
  154.     jmp .ifRead

  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156. ;; Instruction .
  157. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  158. .instPrnt:
  159.     drop
  160.     copy 1
  161.     retrieve
  162.     printc
  163.     jmp .runLoopContinue

  164. ; check if instruction ,
  165. .ifRead:
  166.     dup
  167.     push ','
  168.     sub
  169.     jz .instRead
  170.     jmp .ifLoopFwd

  171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  172. ;; Instruction ,
  173. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  174. .instRead:
  175.     drop
  176.     copy 1
  177.     readc
  178.     jmp .runLoopContinue

  179. ; check if instruction [
  180. .ifLoopFwd:
  181.     dup
  182.     push '['
  183.     sub
  184.     jz .instLoopFwd
  185.     jmp .ifLoopBwd

  186. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  187. ;; Instruction [
  188. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  189. .instLoopFwd:
  190.         drop

  191. ; get data from heap
  192.     copy 1
  193.     retrieve

  194. ; continue only when heap value is non-zero
  195.     jz .noFwdLoop                ; do not continue if *SP == 0
  196.     jmp .runLoopContinue

  197. .noFwdLoop:
  198.     push 1                                ; bracket count

  199. .skipFwd:
  200. ; break when found matching bracket
  201.     dup
  202.     jz .skipFwdEnd

  203. ; increase PP
  204.     swap
  205.     push 1
  206.     add
  207.     swap

  208. ; get next instruction
  209.     copy 1
  210.     retrieve

  211. ; exit when end program
  212.     dup
  213.     jz .endProgram ; end program if no matching ] found

  214. ; check if next instruction is a [
  215.     dup
  216.     push '['
  217.     sub
  218.     jz .incBracketCount
  219.     jmp .checkIfEndBracket
  220.    
  221. .incBracketCount:
  222.     drop
  223.     push 1
  224.     add
  225.     jmp .skipFwd

  226. .checkIfEndBracket:
  227.     push ']'
  228.     sub
  229.     jz .decBracketCount
  230.     jmp .skipFwd

  231. .decBracketCount:
  232.     push 1
  233.     sub
  234.     jmp .skipFwd


  235. .skipFwdEnd:
  236.     drop
  237.     jmp .runLoopContinue

  238. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  239. ;; Instruction ]
  240. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  241. .ifLoopBwd:
  242.     dup
  243.     push ']'
  244.     sub
  245.     jz .instLoopBwd
  246.     jmp .runLoopContinue

  247. ; run instruction ]
  248. .instLoopBwd:
  249.     drop

  250. ; get data from heap
  251.     copy 1
  252.     retrieve

  253. ; continue only when heap value is zero
  254.     jz .runLoopContinue                ; do not loop back if *SP == 0

  255. ; start looping back
  256.     push -1                                ; bracket count

  257. .skipBwd:
  258. ; break when found matching bracket
  259.     dup
  260.     jz .skipBwdEnd

  261. ; decrease PP
  262.     swap
  263.     push 1
  264.     sub
  265.     swap

  266. ; get previous instruction
  267.     copy 1
  268.     retrieve

  269. ; exit when end program
  270.     dup
  271.     jz .endProgram ; end program if no matching ] found

  272. ; check if next instruction is a [
  273.     dup
  274.     push '['
  275.     sub
  276.     jz .incBracketCountBwd
  277.     jmp .checkIfEndBracketBwd
  278.    
  279. .incBracketCountBwd:
  280.     drop
  281.     push 1
  282.     add
  283.     jmp .skipBwd

  284. .checkIfEndBracketBwd:
  285.     push ']'
  286.     sub
  287.     jz .decBracketCountBwd
  288.     jmp .skipBwd

  289. .decBracketCountBwd:
  290.     push 1
  291.     sub
  292.     jmp .skipBwd

  293. .skipBwdEnd:
  294.     drop
  295.     jmp .runLoopContinue

  296. .runLoopContinue:
  297.     push 1
  298.     add                        ; increase PP
  299.     jmp .runLoop        ; continue with run
  300. .endProgram:       
  301.     end
复制代码



cms_cmss005
乐啊,但我不会汇编

inuEbisu
fun fact:
1. brain**其实就是一个图灵机(
2. 蓝鸡喜欢在他的解密里塞Esolang

我不是wzx
inuEbisu 发表于 2023-2-4 18:21
fun fact:
1. brain**其实就是一个图灵机(
2. 蓝鸡喜欢在他的解密里塞Esolang

明白了,那个schematic文件最下面一层是个esolang是吧(

inuEbisu
wsseieiei 发表于 2023-2-4 18:23
明白了,那个schematic文件最下面一层是个esolang是吧(

还真是(
是Piet

zwb_dwz
wsseieiei 发表于 2023-2-4 18:00
这是whitespace写的brain**编译器

逆天

『南南』
写代码的人看得懂这是啥吗

小竹awa
。。编程大佬吗?到底怎么学得那么厉害的?哪学的呢?

WisW
『南南』 发表于 2023-2-4 22:15
写代码的人看得懂这是啥吗

他把101扔到了内存(ascii编码的e)
然后打印了一下
然后跳到了程序开始
最后那个end可以理解成换行符

对了其实汇编比这个复杂


这是汇编的hello world(我没记错应该是x86)

对了楼主长文本折叠下吧


我不是wzx
『南南』 发表于 2023-2-4 22:15
写代码的人看得懂这是啥吗

编译器打开文件后会显示颜色的,虽然还是看不懂

CEllenvia
可還行,這個應該不是彙編,而是 BASIC。

WIAIHE
阅读方法:用鼠标选中这些代码

第一页 上一页 下一页 最后一页