Blame


1 6572a112 2022-04-28 op -,+[ Read first character and start outer character reading loop
2 6572a112 2022-04-28 op -[ Skip forward if character is 0
3 6572a112 2022-04-28 op >>++++[>++++++++<-] Set up divisor (32) for division loop
4 6572a112 2022-04-28 op (MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)
5 6572a112 2022-04-28 op <+<-[ Set up dividend (x minus 1) and enter division loop
6 6572a112 2022-04-28 op >+>+>-[>>>] Increase copy and remainder / reduce divisor / Normal case: skip forward
7 6572a112 2022-04-28 op <[[>+<-]>>+>] Special case: move remainder back to divisor and increase quotient
8 6572a112 2022-04-28 op <<<<<- Decrement dividend
9 6572a112 2022-04-28 op ] End division loop
10 6572a112 2022-04-28 op ]>>>[-]+ End skip loop; zero former divisor and reuse space for a flag
11 6572a112 2022-04-28 op >--[-[<->+++[-]]]<[ Zero that flag unless quotient was 2 or 3; zero quotient; check flag
12 6572a112 2022-04-28 op ++++++++++++<[ If flag then set up divisor (13) for second division loop
13 6572a112 2022-04-28 op (MEMORY LAYOUT: zero copy dividend divisor remainder quotient zero zero)
14 6572a112 2022-04-28 op >-[>+>>] Reduce divisor; Normal case: increase remainder
15 6572a112 2022-04-28 op >[+[<+>-]>+>>] Special case: increase remainder / move it back to divisor / increase quotient
16 6572a112 2022-04-28 op <<<<<- Decrease dividend
17 6572a112 2022-04-28 op ] End division loop
18 6572a112 2022-04-28 op >>[<+>-] Add remainder back to divisor to get a useful 13
19 6572a112 2022-04-28 op >[ Skip forward if quotient was 0
20 6572a112 2022-04-28 op -[ Decrement quotient and skip forward if quotient was 1
21 6572a112 2022-04-28 op -<<[-]>> Zero quotient and divisor if quotient was 2
22 6572a112 2022-04-28 op ]<<[<<->>-]>> Zero divisor and subtract 13 from copy if quotient was 1
23 6572a112 2022-04-28 op ]<<[<<+>>-] Zero divisor and add 13 to copy if quotient was 0
24 6572a112 2022-04-28 op ] End outer skip loop (jump to here if ((character minus 1)/32) was not 2 or 3)
25 6572a112 2022-04-28 op <[-] Clear remainder from first division if second division was skipped
26 6572a112 2022-04-28 op <.[-] Output ROT13ed character from copy and clear it
27 6572a112 2022-04-28 op <-,+ Read next character
28 6572a112 2022-04-28 op ] End character reading loop