Advertisement
imk0tter

Untitled

Jul 21st, 2011
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. push input into cell 0
  2. ,      
  3.                      
  4. copy from cell 0 into cell 1 and 2 then move from 2 to 0
  5. [->+>+<<]>>[<<+>>-]>
  6.  
  7. push 10 into cell 3
  8. ++++++++++
  9.  
  10. push 10 into cell 4 and 5
  11. [>++++++++++[>++++++++++
  12.  
  13. push 10 into cell 6 and 7 and multiply giving 100000 in cell 7
  14. [>++++++++++[>++++++++++<-]<-]<-]<-]
  15.  
  16. move data from cell 7 into cell 3
  17. >>>>[<<<<+>>>>-]
  18.  
  19. point to cell 3
  20. <<<<
  21.  
  22. copy data from cell 3 to 4 and 5 then move from 5 to 3
  23. [->+>+<<]>>[<<+>>-]
  24.  
  25. reserve variable space
  26. >>+>>>>>>>>>>
  27.  
  28. fill cell 20 through 26 with 1s and reserve a 0 at cell 27 for {ref}
  29. >>>+>+>+>+>+>+>+>>
  30.  
  31. push 6 into cell 28 which represents the current power iteration
  32. ++++++
  33.  
  34. start main loop                                                                        
  35. [
  36.        point to cell 14 and set cell 14 aka baseflag to 1
  37.        <<<<<<<<<<<<<<[-]+
  38.      
  39.        start position loop
  40.        [
  41.  
  42.                point to cell 1 aka v1{2}
  43.                <<<<<<<<<<<<<
  44.  
  45.                copy v1{2} to cell 9 aka v1c
  46.                [->>>>>>>>+<<<<<<<<]
  47.              
  48.                point to cell 4 aka v2{2}
  49.                >>>    
  50.              
  51.                copy from v2{2} to cell 10 aka v2c
  52.                [->>>>>>+<<<<<<]
  53.              
  54.                copy v2{1} to v2{2} and cell 5 then move from cell 5 to v2{1}
  55.                <[->+>+<<]>>[<<+>>-]
  56.              
  57.                point to cell 9
  58.                >>>>
  59.              
  60.                if v1c is nonzero enter loop
  61.                [
  62.                        if both v1c and v2c are nonzero subtract 1 from v1c and v2c and add 1
  63.                        to cell 12 then move then point to cell 11
  64.                        >[-<->>>+<]
  65.              
  66.                        move the pointer back one cell pointing to cell 9 if cell 10 was nonzero
  67.                        and pointing to cell 8 otherwise              
  68.                        <<
  69.                ]
  70.  
  71.                move the pointer back one cell and look for a 1 signaling that the pointer
  72.                is in cell 7 rather than 8 and if so move it ahead to 8 to resynch            
  73.                <[>]                                                  
  74.                                                              
  75.                move what's left from v1c to v1{2}                                            
  76.                >[-<<<<<<<<+>>>>>>>>]
  77.              
  78.                clear v2c
  79.                >[-]
  80.              
  81.                add 1 to cell 13 aka basebuff which represents the current position tally
  82.                then point to divvbuff
  83.                >>>+<
  84.              
  85.                subtract divbuff from v2{2}
  86.                [-<<<<<<<<->>>>>>>>]
  87.              
  88.                point to divbuff
  89.                <<<<<<<<
  90.              
  91.                if v2{2} isn't empty subtract 1 from basebuff and clear v2{2} and set baseflag to 0
  92.                [[-]>>>>>>>>>->-<<<<<<<<<<]
  93.              
  94.                copy v2{1} to v2{2}                                                            
  95.                <[->+>+<<]>>[<<+>>-]
  96.              
  97.                if base flag is 0 end loop
  98.                >>>>>>>>>
  99.              
  100.                end position loop
  101.        ]
  102.      
  103.        move basebuff to cell 15 aka basebuffr and cell 16 aka basebuffr2
  104.        <[->>+>+<<<]>>
  105.      
  106.        add 1 to basebuffr
  107.        +
  108.      
  109.        [
  110.                subtract 1 from basebuffr and point to cell 26
  111.                ->>>>>>>>>>>
  112.      
  113.                from cell 26 search back to the first empty memory cell which would be
  114.                cell 19 aka r2 on the first iteration and then add 1 to the cell behind it
  115.                being r1 on the first iteration
  116.                [<]<+
  117.      
  118.                move 2 cells ahead of r1 on the first iteration and search ahead to the
  119.                first empty cell which will be cell 27 aka {ref} and then point back to
  120.                cell 15 aka basebuffr
  121.                >>[>]<<<<<<<<<<<<
  122.        ]      
  123.                                                                              
  124.        point back to cell 26 and search back to find the first empty memory cell
  125.        being r2 on the first iteration and empty the cell infront of it
  126.        >>>>>>>>>>>[<]>[-]
  127.      
  128.        point to the cell ahead of the recently emptied cell and search forward
  129.        for the next empty cell which would be {ref}
  130.        >[>]
  131.      
  132.        point to cell 16 aka basebuffr2
  133.        <<<<<<<<<<<
  134.      
  135.        [
  136.                if cell 16 isn't empty then move to v2{2} and clear it
  137.                -<<<<<<<<<<<<[-]
  138.      
  139.                copy v2{1} to v2{2} and point to v2{2}
  140.                <[->+>+<<]>>[<<+>>-]<
  141.      
  142.                add the contents of v2{2} to cell 17 aka v1neg
  143.                [->>>>>>>>>>>>>+<<<<<<<<<<<<<]
  144.      
  145.                repeat until basebuffr2 is empty
  146.                >>>>>>>>>>>>
  147.              
  148.                end loop and point to cell 17
  149.        ]>
  150.      
  151.        subtract v1neg from v1{1}
  152.        [-<<<<<<<<<<<<<<<<<->>>>>>>>>>>>>>>>>]
  153.      
  154.        clear v1{2}
  155.        <<<<<<<<<<<<<<<<[-]    
  156.      
  157.        copy v1{1} to v1{2}
  158.        <[->+>+<<]>>[<<+>>-]>>
  159.      
  160.        subtract 1 from v2{1}
  161.        <-
  162.      
  163.        if v2{1} isn't empty then start the loop
  164.        [
  165.      
  166.                add 1 back to v2{2} and divide it by 10
  167.                +>[-]<[>>++++++++++[-<<->>]<+<]
  168.        ]
  169.      
  170.        copy v2{1} to v2{2}
  171.        >[->+<<+>]>[-<+>]
  172.      
  173.        subtract 1 from cell 28
  174.        >>>>>>>>>>>>>>>>>>>>>>>-
  175. ]
  176.  
  177. point to cell 16 and empty
  178. <<<<<<<<<<<<[-]
  179.  
  180. multiply 6 by 8 into cell 17 and subtract by 1
  181. ++++++[->++++++++<]>-
  182.  
  183. add 47 to r1 through r6
  184. [->+>+>+>+>+>+<<<<<<]
  185.  
  186. print r1 through r6
  187. >.>.>.>.>.>.
  188.  
  189. clear all variables and point back to cell 0
  190. >>>[-]<<<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement