Reads integer N from stdin, prints out Nth fibonacci number. Usage (a) download and compile TOY.java java-introcs TOY fib.toy type N on standard input OR (b) download toy_1.5.jar java -jar toy_1.5.jar open fib.toy enter debug mode press Run, or repeatedly press Step add N to Stdin (and press Run/Step again) Addr code pseudocode comment --------------------------------------------------------------- 10: 7101 R[1] <- 01 R[1] holds the constant 1 11: 4200 R[2] <- R[0]^R[0] Initialize R[2] to zero* 12: 7301 R[3] <- 01 Initialize R[3] to 1 13: 85FF R[5] <- mem[FF] Read N from Stdin 14: 1423 R[4] <- R[2]+R[3] We'll keep a sum in R[4] 15: 1203 R[2] <- R[0]+R[3] Copy R[3] over to R[2] 16: 1304 R[3] <- R[0]+R[4] Copy R[4] over to R[3] 17: 2551 R[5] <- R[5]-R[1] Subtract 1 from N 18: D514 if (R[5]>0) pc <- 14 N > 0? Do it again. 19: 94FF mem[FF] <- R[4] Send the sum in R[4] to Stdout 1A: 0000 halt All done! * Address 11 is different from the 4222 on the in-class handout because Visual X-TOY is unwilling to execute 4222 when R[2] is uninitialized. (But TOY.java likes both versions!)