Brainfuck Disassembly (Pythone)

Source: Internet
Author: User

GlobalCSGlobalIPGlobalss#GlobalSPGlobalDSGlobalBPGlobalTabGlobal  out#cs='++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++. +++.>++.<<+++++++++++++++.>.+++.------.--------. >+.>.'IP=0SS=[] #sp=0DS=[]BP=0Tab=0 out=[]def tab_ (): I=Tab Stab="'     whilei >0: Stab+='\ t'I-=1    returnstabdef Push (var):    GlobalSS Ss.append (var) def pop ():GlobalSSreturnSs.pop () def op_inc_val ():GlobalIP Count=0     whileTrue:op=Cs[ip] IP= IP +1        ifOP = ='+': Count= Count +1        Else:             Breakprint tab_ ()+'ds[%d] + =%d'%(BP, Count) def op_dec_val ():GlobalIP Count=0     whileTrue:op=Cs[ip] IP= IP +1        ifOP = ='-': Count= Count +1        Else:             Breakprint tab_ ()+'ds[%d]-=%d'%(BP, Count) def OP_INC_DP ():Globalbp BP= BP +1def OP_DEC_DP ():Globalbp BP= BP-1def op_jmp_fwd ():Globaltab Print tab_ ()+'While ds[%d]:'%(BP) tab= tab +1def op_jmp_bck ():Globaltab TAB= Tab-1def op_out (): Print tab_ ()+'Putchar (ds[%d])'%(BP) def op_in (): Print tab_ ()+'GetChar'End=Len (CS) whileIP <End:op=Cs[ip] IP= IP +1    ifOP = ='+': IP= IP-1op_inc_val () IP= IP-1elif op=='-': IP= IP-1op_dec_val () IP= IP-1elif op=='>': OP_INC_DP () elif op=='<': OP_DEC_DP () elif op=='[': Op_jmp_fwd () elif op==']': Op_jmp_bck () elif op=='.': Op_out () elif op==',': op_in ()Else: Print'Invalid opcode'         Break

Brainfuck Disassembly (Pythone)

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.