#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 1::1.4.3 Interpretive Routines
#columns:Front	Back	Tags
TAOCP §1.4.3 Interpretive Routines: what does it cover?	Interpreters written in MIX, culminating in a MIX simulator written in MIX itself and a trace routine that watches a program run. It covers decoding, dispatch, and the cost of interpretation.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::about
TAOCP §1.4.3: why does it matter?	You built two interpreters with Crafting Interpreters. This section is the same idea at the machine level, and the trace routine is the ancestor of every debugger.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::why
TAOCP §1.4.3, a common trap: “Trying to understand every line of the simulator in one sitting.” What's the catch?	Go routine by routine.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::trap
TAOCP §1.4.3, exercise 2 of §1.4.3.1 (rated 20): what is it asking?	Write the missing shift routine for the simulator.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 3 of §1.4.3.1 (rated 22, recommended): what is it asking?	Write the missing MOVE routine for the simulator.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 5 of §1.4.3.1 (rated 24, recommended): what is it asking?	Measure the slowdown of simulating two instructions against running them directly.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 8 of §1.4.3.1 (rated 20): what is it asking?	True or false about an index register in the simulator's main loop. Practice reading someone else's code closely.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 1 of §1.4.3.2 (rated 22): what is it asking?	Make the trace routine restore rJ when it leaves.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 4 of §1.4.3.2 (rated 25, recommended): what is it asking?	Reason about what happens when the trace routine traces itself.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 7 of §1.4.3.2 (rated 25, recommended): what is it asking?	Design a jump trace that records only control transfers.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3, exercise 7 of §1.4.3.1 (rated 32, recommended): what is it asking?	Make simulated I/O take simulated time instead of finishing instantly. The stretch.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercise
TAOCP §1.4.3: how many exercises, and how are they rated?	15 exercises, rated 10 to 40.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::exercises
TAOCP §1.4.3: what should you be comfortable with first?	<ul><li>1.4.1 Subroutines</li><li>Crafting Interpreters (clox dispatch loop)</li></ul>	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::prereqs
TAOCP §1.4.3: how should you work through it?	Map each part of Knuth's simulator to the matching part of your clox run() loop: fetch, decode, dispatch, execute. Read the simulator code slowly; it is long. The trace routine section is worth reading closely for how it intercepts each instruction.	cracked.guide cracked.guide::phase::taocp-1 cracked.guide::section::1.4.3 cracked.guide::kind::approach
