Share
Embed
Transcript
248 slides
-
does the chicken of all chickens that don’t contain themselves
contain itself? -
Chicken Chicken Chicken: Chicken Chicken Doug Zongker University of Washington
Chicken Chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken. Chicken chicken chicken chicken chicken chicken chicken chicken. Chicken, chicken chicken chicken, chicken chicken, chic- ken chicken chicken “chicken chicken” chicken “chicken chicken” chicken. Chicken, chicken chicken chicken chicken chicken chi- cken (chicken chicken) chicken chicken chicken chicken chicken, chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken. Chicken chicken chicken chicken chicken chicken chicken chicken chicken, chicken chicken chicken, chicken chicken chicken chicken chicken chicken chicken. CC Chickens: C.3.2 [Chickens]: Chicken Chickens—chicken/chicken chicken; C.3.4 [Chicken chicken]: Chicken chicken chicken—chickens; C.2.4 [Chicken-chicken chickens]: Chicken/Chicken, chicken chickens Chickens: chicken, chicken chicken, chicken, chicken 1 Chicken Chicken chicken, chicken, chicken chicken chicken chicken, chic- ken chicken chicken chicken chicken chicken [4]. Chicken chicken chicken chicken, chicken chicken chicken: chicken chicken chic- ken chicken chicken chicken chicken chicken chicken. (chicken chicken chicken chicken chicken chicken, chicken chicken chicken chicken chicken chicken chicken!) Chicken, chicken-chicken chicken chicken—chicken chicken, chi- cken chicken 95% chicken chicken-chicken chicken, chicken chic- ken chicken chicken—chicken chicken chicken chicken. Chicken, chicken chicken, chicken chicken chicken 1987. Chicken chicken chicken chicken chicken chicken-chicken-chicken chicken chicken chicken chicken chicken chicken, chicken chicken chicken chicken chicken chicken chicken. Chicken chicken, chicken chicken ch- icken chicken chicken chicken chicken (chicken chicken chicken chicken chicken, chicken chicken chicken chicken chicken chicken chicken chicken). Chicken chicken chicken chicken chicken chicken, chicken chicken (chicken chicken chicken chicken chicken chicken) chicken chic- ken chickens chicken. Chicken chickens chicken chicken chicken chicken chicken “chicken” chicken chickens chicken. Chicken ch- icken, chicken-chicken chicken chickens, chicken chicken chicken chicken chicken chicken chicken.1 Chicken chicken’s “chicken” chicken chicken chicken chicken—chicken chicken chicken chic- ken chicken chicken, chicken chicken chicken chicken chicken ch- icken. 1Chicken chicken chicken chicken chicken chicken chicken; chicken chickens. Chicken chicken Chicken [5]. + Chicken? Chicken Chicken Chicken Chicken Chicken, chicken, chicken Chicken Chicken Chicken Chicken/chicken chicken Chicken chicken chicken C C Chicken chicke n chicken chicken Chicken 1 Chicken chicken chicken. Chicken chicken, chicken chicken (chic- ken chicken chicken) chicken chicken-chicken. Chicken chicken chicken chicken chicken. Chicken-chicken chic- ken chicken chicken chicken chicken chicken, chicken chicken chi- cken chicken, chicken, chicken chicken chicken “chicken” chicken. Chicken chicken chicken chicken chicken chicken chicken, chic- ken, chicken chicken. Chicken chicken, chicken chicken chicken chicken chicken, chicken chicken chicken chicken chicken chicken (chicken, chicken-chicken chicken chicken chicken-chicken chic- ken chicken-chicken chicken). Chicken, chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken. Chicken chicken chicken chicken chicken chicken, chicken chic- ken chicken chicken chicken chicken chicken chicken chicken (ch- icken). Chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken, chicken chicken chicken, chicken, chicken chicken chicken chicken. Chicken chicken chicken, chicken chicken chicken, chicken chic- ken chickens chicken chicken chicken chicken. Chicken, chicken chicken chicken chicken chicken chicken chicken-chicken chicken, chicken chicken chickens Chicken 2. Chicken chicken chicken ch- icken chicken chicken chicken chicken chicken, chicken chicken chicken, chicken chickens chicken. Chicken chicken chicken chic- ken chicken chicken chicken chicken (chicken chicken Chicken 3), chicken chickens chicken chicken chicken (Chicken 4). Chicken chicken chicken chicken chicken, chicken chicken chickens chic- ken, chicken chicken chickens chickens chicken. Chicken chicken chicken chicken chicken chicken chicken. 2 Chicken chicken Chicken chicken chicken, C(n) chicken chicken chicken chicken chicken chicken chicken [4]. Chicken chicken chicken chicken ch- icken’s chickens Chicken [3] chicken chicken, chicken chicken ch- -
function chicken(CHICKEN, Chicken) { Chicken &&( chicken. chicken =[, CHICKEN,
CHICKEN = Chicken = chicken. $Chicken =-( CHICKEN ==( chicken. Chicken = Chicken ))], chicken. chicken [Chicken++] = chicken. chicken, chicken. CHICKEN = ++Chicken, chicken (--Chicken), chicken. $Chicken = ++Chicken, chicken. CHICKEN++ ); Chicken = chicken. Chicken [chicken. $Chicken++ ]; chicken. Chicken = CHICKEN? Chicken? '\012'== Chicken? chicken (++ CHICKEN, chicken. chicken [++ chicken. CHICKEN ]= CHICKEN - CHICKEN ): Chicken ==' '|'\015'== Chicken || (Chicken )== "c" & chicken. Chicken [chicken. $Chicken++ ]== "h" & chicken. Chicken [chicken. $Chicken++ ]== "i" & chicken. Chicken [chicken. $Chicken++ ]== "c" & chicken. Chicken [chicken. $Chicken++ ]== "k" & chicken. Chicken [chicken. $Chicken++ ]== "e" & chicken. Chicken [chicken. $Chicken++ ]== "n"&&++chicken. chicken [chicken. CHICKEN]? chicken (CHICKEN) :[ "Error on line "+CHICKEN+": expected 'chicken'", chicken. CHICKEN = CHICKEN ++- CHICKEN ]: chicken. chicken :( CHICKEN = chicken. Chicken[chicken.CHICKEN], Chicken? (Chicken = } --Chicken? --Chicken? --Chicken? --Chicken? --Chicken? --Chicken? --Chicken? --Chicken? --Chicken? chicken. CHICKEN++ && --Chicken :'&#'+CHICKEN+';': chicken. Chicken [chicken. Chicken [-- chicken. CHICKEN ]&& (chicken. $Chicken += CHICKEN), --chicken. CHICKEN ]: chicken. Chicken [chicken. Chicken [CHICKEN] = chicken. Chicken [-- chicken. CHICKEN ],-- chicken. CHICKEN ]: chicken. Chicken [chicken. Chicken [chicken. $Chicken++ ]] [CHICKEN]: CHICKEN == chicken. Chicken [-- chicken. CHICKEN ]: CHICKEN*chicken. Chicken [-- chicken. CHICKEN ]: chicken. Chicken [-- chicken. CHICKEN ]- CHICKEN: chicken. Chicken [-- chicken. CHICKEN ]+ CHICKEN: chicken. CHICKEN ++ && "chicken", chicken. Chicken [chicken. CHICKEN ]= Chicken, chicken ()): CHICKEN ); return chicken. Chicken -
cat chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ -
Spec Every line in the program is inspected for chickens,
and the corresponding number of chickens are pushed onto the stack. Execution is done directly on the stack, which may make the program susceptible to arbitrary chicken injection attacks. -
0 axe Terminates all chickens. 1 chicken Pushes “chicken” onto
the stack. 2 add Adds two topmost groups of chickens. 3 fox Topmost chickens become foxes. Subtract. 4 rooster Causes two topmost groups to multiply. 4.5 fence Divides chickens. Cannot be used. 5 compare Compares, pushes truthy or falsy chicken. 6 pick Pop address, pop source. 0 stack, 1 input. 7 peck Pop address, store value. 8 fr Pop offset, pop cond. If cond, fly to offset. 9 BBQ Chars the topmost group into ASCII. n Pushes n-10 chickens onto the stack. -
• Same variables with different case or prefix • Long
chains of conditional evaluation • Increment, decrement, parentheses, commas, ternaries • Variable re-definition • Store values on the function object • Recursion -
function chicken(CHICKEN, Chicken) { Chicken && (chicken.chicken = [, CHICKEN,
CHICKEN = Chicken = chicken.$Chicken = -(CHICKEN == (chicken.Chicken = Chicken)) ], chicken.chicken[Chicken++] = chicken.chicken, chicken.CHICKEN = ++Chicken, chicken(--Chicken), chicken. $Chicken = ++Chicken, chicken.CHICKEN++); Chicken = chicken.Chicken[chicken.$Chicken++]; chicken.Chicken = CHICKEN ? Chicken ? '\012' == Chicken ? chicken(++CHICKEN, chicken.chicken[++chicken.CHICKEN] = CHICKEN - CHICKEN) : Chicken == ' ' | '\015' == Chicken || (Chicken) == "c" & chicken.Chicken[chicken.$Chicken++] == "h" & chicken.Chicken[chicken.$Chicken++] == "i" & chicken.Chicken[chicken.$Chicken++] == "c" & chicken.Chicken[chicken.$Chicken++] == "k" & chicken.Chicken[chicken.$Chicken++] == "e" & chicken.Chicken[chicken.$Chicken++] == "n" && + +chicken.chicken[chicken.CHICKEN] ? chicken(CHICKEN) : ["Error on line " + CHICKEN + ": expected 'chicken'", chicken.CHICKEN = CHICKEN++-CHICKEN ] : chicken.chicken : (CHICKEN = chicken.Chicken[chicken.CHICKEN], Chicken ? (Chicken = --Chicken ? --Chicken ? --Chicken ? --Chicken ? --Chicken ? --Chicken ? --Chicken ? --Chicken ? --Chicken ? chicken.CHICKEN++ && --Chicken : '&#' + CHICKEN + ';' : chicken.Chicken[chicken.Chicken[--chicken.CHICKEN] && (chicken.$Chicken += CHICKEN), --chicken.CHICKEN] : chicken.Chicken[chicken.Chicken[CHICKEN] = chicken.Chicken[--chicken.CHICKEN], --chicken.CHICKEN] : chicken.Chicken[chicken.Chicken[chicken.$Chicken++]][CHICKEN] : CHICKEN == chicken.Chicken[-- chicken.CHICKEN] : CHICKEN * chicken.Chicken[--chicken.CHICKEN] : chicken.Chicken[--chicken.CHICKEN] - CHICKEN : chicken.Chicken[--chicken.CHICKEN] + CHICKEN : chicken.CHICKEN++ && "chicken", chicken.Chicken[chicken.CHICKEN] = Chicken, chicken()) : CHICKEN); return chicken.Chicken } -
function chicken(code, input) { if (input) { chicken.chicken = [
, code, code = input = chicken.$Chicken = -(code == (chicken.Chicken = input)) ]; chicken.chicken[input++] = chicken.chicken; chicken.CHICKEN = ++input; chicken(--input); chicken.$Chicken = ++input; chicken.CHICKEN++; } -
• Restructure • Step through debugger • Stare until eyes
fall out • Rename variable • Rinse, repeat... Strategy -
var code = "", stack = [], $sp = -1,
$ip = 0, $cp = 0; function inc() { stack[$sp]++; return true; } function push(value) { stack[++$sp] = value; } function pop() { return stack[$sp--]; } function peek() { return stack[$sp]; } -
function chicken(input, le_code) { code = le_code; $cp = 0;
$sp = -1; stack = []; push(stack); push(input); push(0); read_line(1); return run_loop(); } -
function read_line(line) { var character = code[$cp++]; if (!character) {
return; } if ('\012' == character) { // LF line++; push(0); return read_line(line); } if (character == ' ' || (character == "c" && code[$cp++] == "h" && code[$cp++] == "i" && code[$cp++] == "c" && code[$cp++] == "k" && code[$cp++] == "e" && code[$cp++] == "n") && inc()) { return read_line(line); } $sp = 0; stack = [ 0x0, "Error on line "+line+": expected 'chicken'" ]; } -
function run_loop() { var instruction; $ip = 2; push(0); while
(instruction = stack[$ip++]) { process_instruction(instruction); } return peek(); } -
function process_instruction(instruction) { var head; switch (instruction) { case 1:
push("chicken"); break; case 2: head = pop(); push(pop() + head); break; case 3: head = pop(); push(pop() - head); break; case 4: push(pop() * pop()); break; case 5: push(pop() == pop()); break; case 6: head = pop(); push(stack[stack[$ip++]][head]); break; case 7: head = pop(); stack[head] = pop(); break; case 8: head = pop(); if (pop()) { $ip += head; } break; case 9: push('&#'+pop()+';'); break; default: push(instruction - 10); break; } } -
&stack &input 0 ip sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ -
&stack &input 0 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 1 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 2 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 3 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 4 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 5 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 6 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 7 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 8 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 9 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 10 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 sp chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 0 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 1 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 2 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 3 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 4 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 5 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 6 sp chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 6 0 sp chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken ␊ chicken chicken chicken chicken chicken chicken ␊ ip -
&stack &input 11 6 0 sp set the code pointer
to the beginning of the code segment ip -
&stack &input 11 6 0 0 sp delimit code segment
with an exit opcode ip -
&stack &input 11 6 0 0 1 sp 6 =
load ip -
&stack &input 11 6 0 0 1 sp 6, 0
= load stack[0] ip source -
&stack &input 11 6 0 0 &input return head of
stack to caller which is: &input ip sp -
push 5 push 13 rooster bbq axe chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken␊ chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken␊ chicken chicken chicken chicken␊ chicken chicken chicken chicken chicken chicken chicken chicken chicken␊ eggsemble -
push 5 push 13 rooster bbq axe push 5 push
13 multiply char exit chicken asm -
&stack &input ... ... ... ip push 0 push 2
store push 0 push 32 char add push 3 store 3 sp -
&stack &input ... ... ... ip push 0 push 2
store push 0 push 32 char add push 3 store write 0 into register 2 } 3 sp -
&stack &input 0 ... ... ip push 0 push 2
store push 0 push 32 char add push 3 store i 3 write 0 into register 2 } sp -
&stack &input 0 ... ... ip push 0 push 2
store push 0 push 32 char add push 3 store write “0<space>” into register 3 } i 3 write 0 into register 2 } sp -
&stack &input 0 “0 “ ... ip push 0 push
2 store push 0 push 32 char add push 3 store i out 3 write 0 into register 2 } write “0<space>” into register 3 } sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 3 sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } 3 sp -
&stack &input 0 “0 “ ... 0 sp ip i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } 3 -
&stack &input 0 “0 “ ... 0 ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 sp -
&stack &input 0 “0 “ ... 0 3 sp ip
i out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 -
&stack &input 0 “0 “ ... 0 3 ip i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } false sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } false if true, jump to end } sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } false if true, jump to end } sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } sp -
&stack &input 0 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } sp -
&stack &input 0 “0 “ ... 0 ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } sp -
&stack &input 0 “0 “ ... 0 ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } increment } sp -
&stack &input 0 “0 “ ... 1 ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } increment } sp -
&stack &input 0 “0 “ ... 1 ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } increment } store register 2 i } sp -
&stack &input 1 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 load register 2 i } load register 1 input } 3 compare } if true, jump to end } load register 2 i } increment } store register 2 i } sp -
&stack &input 1 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } sp -
&stack &input 1 “0 “ ... ip i out push
2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } append “i<space>” to out } sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } false sp -
&stack &input 1 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 2 “0 1 “ ... ip i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 2 “0 1 2 “ ... ip i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } sp -
&stack &input 2 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 2 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 2 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 2 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip false sp -
&stack &input 2 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 “ ... i out
push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip true sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip sp -
&stack &input 3 “0 1 2 3 “ ... i
out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip load out } sp -
&stack &input 3 “0 1 2 3 “ ... “0
1 2 3 “ i out push 2 load 0 push 1 load 0 compare push 24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 } 3 compare i to input if true, jump to end } increment i } }append “i<space>” to out jump to start } ip load out } sp -
&stack &input 3 “0 1 2 3 “ ... “0
1 2 3 “ i out 3 “0 1 2 3 “ is returned to caller sp -
push 2 load 0 push 1 load 0 compare push
24 jump push 2 load 0 push 1 add push 2 store push 3 load 0 push 2 load 0 add push 32 char add push 3 store push 1 push 0 push 33 subtract jump push 3 load 0 loop break -
&stack &input ... ... ip push 11 push 12 push
2 push 0 push 1 push 1 jump sp -
&stack &input ... ... 11 ip push 11 push 12
push 2 push 0 push 1 push 1 jump sp -
&stack &input ... ... 11 12 ip push 11 push
12 push 2 push 0 push 1 push 1 jump sp -
&stack &input ... ... 11 12 2 ip push 11
push 12 push 2 push 0 push 1 push 1 jump sp -
&stack &input ... ... 11 12 2 0 ip push
11 push 12 push 2 push 0 push 1 push 1 jump sp -
&stack &input ... ... 11 12 2 0 ip push
11 push 12 push 2 push 0 push 1 push 1 jump sp ip -
&stack &input ... ... 11 12 2 0 ip push
11 push 12 push 2 push 0 push 1 push 1 jump sp ip -
&stack &input ... ... 11 12 2 0 ip return
3 to caller 3 sp -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 ip -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 0 ip -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 0 0 ip -
v @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 0 0 ip -
3 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n] -
3 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 ip [n] -
3 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 1 ip [n] -
3 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 1 0 ip [n] -
3 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 1 0 ip [n] -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n,i] -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 ip [n,i] -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 32 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 32 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 0 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 0 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 0 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 0 ip [n,i] Output: 0 -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 0 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 1 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 1 [n,i] Output: 0 ip -
30 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 1 0 [n,i] Output: 0 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 0 [n,i] Output: 0 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 32 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 ip [n,i] Output: 0 1 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 0 0 ip [n,i] Output: 0 1 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 ip [n,i] Output: 0 1 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 ip [n,i] Output: 0 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 0 ip [n,i] Output: 0 1 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 ip [n,i] Output: 0 1 -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 1 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 0 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 1 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 2 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 2 1 [n,i] Output: 0 1 ip -
31 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 2 1 0 [n,i] Output: 0 1 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 [n,i] Output: 0 1 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 1 0 [n,i] Output: 0 1 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 2 [n,i] Output: 0 1 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 32 [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 2 [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 ip -
32 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 [n,i] Output: 0 1 2 ip -
33 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 3 ip -
33 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 3 ip -
33 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 3 ip -
33 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ 3 3 [n,i] Output: 0 1 2 3 ip -
33 @ > & 00p 0 10p ;; 0. ;;
" ", ;; > 00g 10g w @ v < > 10g 1+ 10p ;; 10g. ;; " ", ^ [n,i] Output: 0 1 2 3 ip -
int sp = 0; double val[MAXVAL]; void push(double f) {
val[sp++] = f; } double pop(void) { return val[--sp]; } -
/* reverse Polish calculator */ int main(int argc, char **argv)
{ int type; double op2; char s[MAXOP]; while ((type = getop(s)) != EOF) { switch (type) { case NUMBER: push(atof(s)); break; case '+': push (pop() + pop()) ; break; case '*': push(pop() * pop()); break; case '-': op2 = pop(); push(pop() - op2); break; case '/': op2 = pop(); if (op2 != 0.0) push(pop() / op2); else printf("error: zero divisor\n"); break; case '\n': printf("\t%.8g\n", pop()); break; default: printf("error: unknown command %s\n", s); break; } } return 0; } -
RPN calculator 3 4 + 7 5 5 * 25
2 3 + 2 * 10 -
References • Paper by Doug Zongker isotropic.org/papers/chicken.pdf youtube.com/watch?v=yL_-1d9OSdk • Chicken.js
by Torbjörn Söderstedt torso.me/chicken -
Questions? • Chicken Chicken Chicken • github.com/igorw/chicken-php • github.com/igorw/befunge-php •
github.com/igorw/brainfuck-php • @igorwesome