progs/compile_arr.scala
changeset 712 e71eb9ce2373
parent 710 183663740fb7
equal deleted inserted replaced
711:6f3f3dd01786 712:e71eb9ce2373
   450   case '>' => s"ptr := ptr + $n;"
   450   case '>' => s"ptr := ptr + $n;"
   451   case '<' => s"ptr := ptr - $n;"
   451   case '<' => s"ptr := ptr - $n;"
   452   case '0' => s"mem[ptr] := 0;"
   452   case '0' => s"mem[ptr] := 0;"
   453   case '+' => s"mem[ptr] := mem[ptr] + $n;"
   453   case '+' => s"mem[ptr] := mem[ptr] + $n;"
   454   case '-' => s"mem[ptr] := mem[ptr] - $n;"
   454   case '-' => s"mem[ptr] := mem[ptr] - $n;"
   455   case '.' => s"x := mem[ptr]; write x;" 
   455   case '.' => s"x := mem[ptr]; write(x);" 
   456   case '['  => "while (mem[ptr] != 0) do {" * n 
   456   case '['  => "while (mem[ptr] != 0) do {" * n 
   457   case ']'  => "skip};" * n
   457   case ']'  => "skip};" * n
   458   case _ => ""
   458   case _ => ""
   459 }
   459 }
   460 
   460 
   505       -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
   505       -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
   506       >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
   506       >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
   507       +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
   507       +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
   508       ++++++++++++++++++++++++++++++++++++++++++++.[-]<<
   508       ++++++++++++++++++++++++++++++++++++++++++++.[-]<<
   509       <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
   509       <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
   510       [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]"""
   510       [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]
       
   511       [-]++++++++++."""
   511 
   512 
   512 bf_run(bf2, "fibs")
   513 bf_run(bf2, "fibs")
   513 
   514 
   514 // Mandelbrot Set
   515 // Mandelbrot Set
   515 //----------------
   516 //----------------