# Motion How things move in a canim frame, in what order, and for how long. [`README.md`](README.md) gave durations and curves. This is the direction that uses them, written after measuring the first five scenes frame by frame. Where the two disagree this one wins; its figures are tokens, see [Tokens](#tokens). Times are at 60 frames a second: "12 f" is twelve frames, 0.20 s. **Since the design language** ([`README.md`](README.md)): the blocks this page moves have names there, and its [verbs](README.md#6-verbs) are this page's charts in one table. The direction below stands. What reads differently now: - There is no head. The step counter and the progress line are the `clock`, and it moves as this page says the progress line does: still through a step at a walk or a run (the step's piece of gold fades in once its mark has landed), sweeping at a sprint. - In the context a strike arms with a 2-unit frame, pulses out 3 units, and cools to nothing, leaving the `held` corner where this page says ember and bar. A lens's cell cools to a bar along its bottom edge. The cool starts with the advance, whenever that is. - Tags of variables and registers are `pin`s. A pin is one thing and [`travel`](README.md#6-verbs)s along its lane; it never jumps. - `extend`: a chain whose first hop is struck is followed again hop by hop, 4 f apart, each fading in over 6 f. - `link`: 6 f after a register's strike its old `pin` fades (12 f) and the line draws from the register's row to the thing it now points at, head first (24 f, 36 f over 400 units, `standard`). The pin lands with the head and settles (12 f). At the advance the line draws back into the pin (18 f). "Its plaque slides" and "its tag travels", below, are this. - `project`: the idea's slot in the cascade is a tie. When bytes in the dump, or a frame's return address on the stack, are read or struck, a bracket takes their row (6 f) and a line draws from them to the part of the drawing they are (18 f; 30 f over 600 units; `standard`). The drawing reacts when the line arrives and not before: its bytes are always 18 f ahead of it. Out with the advance (18 f). - `advance`: the `thread` (the bracket on the source line, the brackets on its instructions, the line between) moves with the plaques and rip, as one mark, last. - `establish`, for a lens: its view first; then its elements come in beside their rows, 2 f apart in address order, with no lines (six lines at once would break the budget of three). - The levels of the cascade are places in one frame: the pc's annotation and the registers (CPU), the stack's slots and the dump's bytes (memory), the drawing (the idea). The order and the 18 f between them are the same. - The camera rests at x1.5 as well, and that is its usual scale: a frame of 1195 by 560. At x2 the frame is 896 by 420. It always returns. - Above the working frame there is the map, the same moment with every panel whole, and in the working frame's corner the minimap. A scene goes between them by `dive` and `surface` (below, "The map and the working frame"). - Down is deeper: a call the narration follows opens its callee's window under the call row and the kernel's under a `syscall` (the [descent](README.md#descent)); the answer comes back up the same lane. The backtrace lists the newest at the bottom. - `current` is a white wash across the row and the gold plaque; a strike's paper is a softened vermilion, and cools to nothing; `held` is a turned corner, which fades in over the cool's last 6 f. ## What was measured The five scenes as exported (30 fps, build of 13:01), with [`motion/motion.py`](motion/motion.py): a timing chart of each ([`motion/charts/`](motion/charts)), contact sheets of every transition looked at ([`motion/sheets/`](motion/sheets)), and five rule checks. | | fib | list | sort | syscalls | zoom | | --- | --- | --- | --- | --- | --- | | seconds | 30.8 | 39.3 | 36.6 | 13.8 | 25.8 | | CROWD: three or more panels begin on the same frame | 75 | 43 | 44 | 4 | 5 | | POP: a change with no frames in between | 68 | 40 | 35 | 0 | 1 | | METRONOME: longest run of evenly spaced steps | 68 at 0.25 s | 15 at 0.25 s | 36 at 0.25 s | 4 at 3.0 s | | | walked steps exactly 1.5 s apart | 8 | 7 | 14 | | | | seconds between the first caption and the first step | 0.0 | 1.5 | 0.0 | 0.0 | 0.0 | Three things account for nearly all of it: 1. **A step spends itself on its first frame.** The line's mark, the registers, the bytes and the idea drawn from them all start together and are done in 0.25 s; then 1.25 s of stillness. One change is seen, three are missed, and nothing says which caused which. 2. **Steps tick.** A walked step is 1.5 s whether it moved a line or pushed a call through four panels. 3. **Run is a strobe.** 0.25 s a step with nothing eased: whole panels replaced four times a second, for 17 of fib's 31 seconds. ## The direction ### What motion is for Four jobs, and a movement that does none of them is a cut: - **Where to look next.** An onset pulls the eye. So onsets come one at a time, and each is where the next thing to understand is. - **What caused what.** Cause moves first; its effect follows. Order on the timeline is the argument. - **This is the same thing.** What persists slides; what begins or ends fades. A plaque that teleports is two plaques. - **Now.** A change has an instant. The strike marks it; everything before is preparation and everything after is reading time. The viewer listens, reads and watches, and can do one of the three well. Nothing moves while a caption arrives. Nothing arrives while something moves. The eye takes about a quarter of a second to get anywhere, so two onsets in different panels are at least 0.30 s apart. ### A step is a sentence A step is one line (or one instruction) doing its work. It is drawn in the order it would be said: > *this line* → *changes this* → *which changes that* → *next.* 1. **Fire** (12 f). The current mark is on the line about to run. Its plaque pulses once. Nothing else moves. 2. **Effects, a level at a time**, 18 f apart, in the order they were caused: CPU (registers), then memory (bytes, words, the heap strip, the locals table), then the idea drawn from them (stack cards, call tree, list nodes, array cells). A level the scene does not show gives up its slot. Each effect is *armed* for 12 f (a frame round the cell, the old value still in it) and then struck. 3. **Hold.** 36 f after the last strike, 12 f more for each further value, 84 f at most. The gold line and the vermilion values are on screen together: the line, and what it did. 4. **Advance** (12 to 24 f). The mark moves to the next line. This is the step's follow-through and the next step's anticipation. 5. **Rest** (24 f). The next line is read. **The mark goes last.** The exported scenes move it first, and so does the working tree's `cursor.lead` (`source = 0.0`). That is a debugger's convention, and it puts gold on the line that has *not* run while the strikes show what the line before it did: in `list` at 5.27 the mark lands on `n->next = head;` as `7` is struck into `value`. Execute, then advance, and gold always names the cause of what is red. A step's length follows from its content: | A step that | Frames | Seconds | | --- | --- | --- | | only moves the line | 12 fire + 12 advance + 24 rest | 0.8 | | writes one register (or one word, or one cell) | 18 + 36 + 12 + 24 | 1.5 | | writes a register and memory | 36 + 48 + 12 + 24 | 2.0 | | makes a call, three levels shown | 108 + 36 + 12 + 24 | 3.0 | | returns from one | 126 + 24 + 12 + 24 | 3.1 | | swaps two cells | 90 + 36 + 12 + 24 | 2.7 | | crosses into the kernel | see the chart | 3.7 to 5.1 | A level with nothing on screen to change gives up its slot: a step whose writes all land outside every window is a step that only moves the line. So a walk has the program's rhythm and not a clock's. ### The principles, here **Timing and spacing.** A change takes 0.1 to 0.6 s and is then held for at least twice that and at least as long as it takes to read: | To read | Seconds | | --- | --- | | that something was struck | 0.25 | | a byte, a small decimal | 0.3 | | a group of four hex digits | 0.5 | | the end of an address against another (nobody reads twelve digits) | 0.6 | | a line of code, first time; again | 0.8; 0.3 | | a caption | 1.5 + 0.06 a character | | a frame of n panels, on first sight | 1.0 + 0.5 n | Spacing is where the frames of a move fall. Measured on the swap in `sort` the card is fastest on the first frame it moves and slows from there (35, 24, 17, 13, 10, 8, 7 pixels a frame), then creeps for eight frames more: a jump and a crawl, not an arc ([sheet](motion/sheets/sort-20.4-swap-onion.png)). The curve does that, not the duration; see the next principle. Duration follows distance: the mark takes 12 f for one row and 2 f more for each further row; a flight 30, 36 or 48 f. **Slow in and slow out.** Three curves do the work. | Curve | cubic-bezier | Peak speed | For | | --- | --- | --- | --- | | `standard` | 0.3, 0, 0.2, 1 | 2.6 x mean, a quarter of the way in | the mark, cards, tags, arrows growing, rows making room: things that answer the program | | `glide` | 0.45, 0, 0.55, 1 | 1.8 x mean, at the middle | things with weight: a value in flight, the camera, a layout, a colour cooling | | `linear` | | | time itself: the progress line, a counter, the playhead; and opacity | `standard` today is 0.2, 0, 0, 1: half the distance in the first fifth of the time, a peak of 4 x mean on the second frame. `camera` today is 0.65, 0, 0.35, 1: 4% of the way after a fifth of the time, then 2.9 x mean. Both read as a pop with a tail. `enter` (0, 0, 0.2, 1) starts at full speed and is kept only for a fade that rises 8 units; `exit` for a fade that leaves. A strike is not eased in position, because nothing moves; its fill comes in over 6 f so that a cell does not flash in one. **Anticipation.** The eye is told where before it is told what. | Before | The cue | Frames | | --- | --- | --- | | a line runs | its plaque pulses | 12 | | a value changes | a 3-unit write-coloured frame round its cell, old value still inside | 12 | | a pointer turns | its old arrow goes dashed and faint | 12, with the arm | | a value flies | it lifts: a card, 1.12 of its size, 6 units off the cell | 6 | | the camera moves | a bright frame on the target; everything else leaves | 24, 18 | | the pace changes | the steps before it shorten or lengthen | 3 or 4 steps | | a caption's subject | the caption, alone on a still frame | 60 or more | No wind-up: nothing draws back before it goes. (`cursor.anticipation`, a cell shrinking before its pulse, should go; on a 46-unit cell it is two pixels of cartoon.) No anticipation at run or sprint. **Staging.** One idea at a time. - One onset at a time, 18 f apart. Two panels that show the same bytes (the heap strip and the words) start together; only the one in focus pulses. - What cannot be read at the current pace is veiled: the registers, the stack and the disassembly from the first shortened step of a run, and at a sprint the source and the band's view as well (see Pace). What is not the subject of a camera move is gone before it starts. - The subject is never at the edge. At x2 the rows about to change are in the middle of the frame, and no row is cut by the stage's edge. A stack under the camera holds its window still, so a push fills a row in the middle of the frame instead of scrolling the whole panel at its edge. - A layout is stable. A row, a node, a card or a divider that appears makes room first; nothing else jumps because it came. - One caption at a time. The old one leaves (12 f), six frames of nothing, the new one arrives (18 f). Two captions crossfading are an unreadable third ([sheet](motion/sheets/zoom-08.7-out-and-in.png), f304). **Follow-through and overlapping action.** The cascade is the overlap: each level starts while the one before is still solid. After that: - A strike is followed by its cool, 36 f later, starting as the mark leaves. The digits change face at the middle of the cool, where the colour is moving fastest and hides it. - A pointer's word strikes first; its arrow leaves 6 f later and takes 24 f; the row or node it lands on is framed bright for 12 f. The cell is the cause, the arrow the consequence, the landing the point. - Of two things doing the same (two flights, four registers read, sixteen bytes copied) the second starts 6 f after the first; bytes of one write, 1 f apart, low address first; bytes copied by the kernel, 2 f apart. - What leaves has left before what replaces it arrives. - Nothing settles by bouncing. A flight's card is back to size on its last 6 f and the strike is its impact. **Arcs.** Ideas move on arcs; the machine moves on wires. - A value between cells of an array, or between nodes: an arc a quarter as high as it is long (34 to 120 units), on `glide`, so it is slowest at lift-off and landing and quickest over the top. A swap is one over and one under. The arc stays inside the drawing's lanes (lowered if it must), and the card passes under names and pins, never hiding them. - A value between a register and memory, or across the kernel's line: along a square-cornered path, as a flow arrow draws it. Machines do not lob. - A variable following a pointer (`cur = cur->next`): its pin travels along the drawing's bottom lane, under the arrow it followed. - The mark moves straight up and down its gutter. The camera moves in a straight line and zooms by ratio (interpolate the logarithm of the scale), or the first half of a move to x2 looks twice as fast as the second. **Secondary action.** Embers, bars, the trail, flag chips, result badges, the step counter and the progress line. They never start on a frame where something primary starts, never travel or scale, and only fade. If one of them draws the eye it is too strong: the digit pop at the middle of each cool does, in every scene, 0.8 s after each strike. **Exaggeration and appeal.** The look is sober, so the budget is small and spent in three places: the pulse of a strike, the lift of a flight, the fire of a line. Appeal here is exactness: everything lands on the grid, on whole pixels, on the beat; the same event takes the same frames every time. No bounce, no elastic, no rotation, no blur, no smear frames. **Squash and stretch.** Only the pulse, and not as a scale. At 8% a register's cell grows 27 units sideways and 3 up, and two struck rows merge ([sheet](motion/sheets/fib-02.2-register-strike-and-cool.png), f70). The pulse is an outset of 4 units on every side, whatever the cell's size, drawn over its neighbours; the digits do not move. **Pose to pose.** Every rest state is a still that was designed (the mocks). Motion is the way between two of them and is never the only place something is shown. ### The rhythm of a scene **Open.** The opening is read under its first caption, not before it: seven seconds of stillness before anything happened was the first videos' longest flaw. | Frames | | | --- | --- | | 0 to 48 | the panels fade in, 18 f each, 6 f apart: registers, stack, source, disassembly, the band's view, the drawing's panel | | 30 to 54 | the drawing's elements fade in rising 8 units, 2 f apart in address order, each with its row's quiet bracket | | 60 to 78 | the first caption arrives | | 78 to 198 | still: the caption and the picture are read | | 198 to 240 | the first step fires, by 240 (4.0 s) at the latest | **Beats.** The beat is 0.5 s. Steps are as long as their content; a *phrase* (one trip round a loop, one call and its return) ends with a rest of one beat. Three steps and a rest is a bar, and a loop is heard as bars. **Breath.** A caption is up 60 f before the first step it describes fires (120 f for a scene's first), and holds a beat longer after. It is on screen at least 1.5 s + 0.06 s a character, and at most 12 s; if there is nothing to say for longer, the scene is too long there. Captions change only in a rest. A sentence that would need three lines is two captions, split at a phrase rest. The numbers an author checks are in the catalogue's [caption](README.md#clock-and-caption). **Pace.** | | A step | What is drawn | Veiled | When | | --- | --- | --- | --- | --- | | walk | by content, 0.8 to 3.0 s | everything | nothing | the first time anything happens, and whatever the narration names | | run | 0.30 s | the mark glides (8 f); cards, nodes, arrows and pins ease (8 f); no strikes, no held corners, no arcs drawing: values change in place under 8 f crossfades, and what the run changed is shown settled when it ends (its arcs fade in, 8 f); no fire, arm, pulse, link or projection | registers, stack, disassembly | a pattern seen once in full; 24 steps at most | | sprint | 0.067 s or less | the drawing grows; embers; the mark and the pins only at phrase ends; the clock sweeps | the same, and the source and the band's view | everything longer | A run keeps its bars: 12 f of rest at each phrase end. A sprint does not. **Changing pace** is never a switch. - Into a run: four steps, each 0.6 of the one before (1.5, 0.9, 0.54, 0.32). Out of it: three steps lengthening the same way, then one beat of stillness before the walked step that the run was heading for. - On the first shortened step the panels that cannot be read at speed take the veil (50%, in over 18 f with its fire); on the last step back to a walk it lifts (18 f, with the advance). Under the veil the values go on changing, without marks: the veil says "not now", not "nothing". - The clock: at a walk and a run it is still while a step plays, and the step's piece of gold fades in once its mark has landed (12 f; 8 f at a run), the count changing as the fade starts: moving every frame of a walked step it would be a secondary action that never stops. In a sprint it grows linearly with the recording: the only thing on screen that says "fast". - The caption says it too: "and so on, down to `fib(1)`". **Close.** The last step's hold, then 2 s on the finished picture. A scene ends on its result, read. ## Timing charts Frames at 60 a second from the step's first frame. *Arm* and *strike* are always the same sub-chart: | Frames | A strike at frame s | | --- | --- | | s-12 to s | arm: a 3-unit frame in write's colour inside the cell's edge, in over 2 f; the old value unchanged | | s to s+6 | the fill (`b54f42`) comes in, linear; the digits become the new value, bold, bright, at s+3 | | s to s+12 | pulse: the fill's edges go out 4 units and back, sine | | s+6 to the advance | solid (at least to s+36) | | the advance to +24 | cool, on `glide`, the paper to nothing; digits to their ordinary face at its middle; the turned corner fades in over the last 6 f | | then | the corner for three steps; out over 36 f, linear, in the step after | ### A register written | Frames | | | --- | --- | | 0 to 12 | fire | | 6 to 18 | arm on the value cell | | 18 | strike (to 24 in, to 30 pulse, to 54 solid) | | 54 to 66 | the mark advances, `standard`; the cool starts (to 78) | | 66 to 90 | rest | Two registers by one step: the second is armed and struck 6 f after the first, in the order they were written. rip is not one of them: it is the current mark's, and moves with the advance. ### Memory written The same, one slot later if a register was struck too: arm 24 to 36, strike 36. Drawn as bytes, only the bytes whose value changed are armed and struck, 1 f apart from the low address. The heap strip's mark is the same strike at scale, without a pulse. Hold to 84, advance to 96, rest to 120. A word outside the window: the window scrolls first (the stack's or the dump's, 24 f, `glide`, whole rows, until the word is in its middle rows), and only then is the word armed; the level's slot starts after the scroll. A row that was not in the grid: the rows below glide down 18 f, the row fades in 12 f, and only then is it armed. An unknown byte that becomes known without being written fades from dots to digits in 12 f, with no mark. ### A value read | Frames | | | --- | --- | | r to r+6 | a 3-unit frame in read's colour and its ember, fading in; no arm, no pulse | | to the advance | held | | advance to +18 | out | A read is in the slot of its level. It is gone before the next line fires: in `sort` and `syscalls` read frames stand through the rest and vanish in one frame. ### A pointer written | Frames | Memory | The idea (one slot later) | | --- | --- | --- | | s-12 to s | arm on the word; the old arrow goes dashed and faint | | | s to s+6 | strike | arm on the node's pointer square, from s+6 | | s+6 to s+30 | the new arrow draws along its lane, head first, `standard` | strike at s+18 | | s+30 to s+42 | the row it lands on: a bright 3-unit frame, then 12 f out | its arrow draws, s+24 to s+48 | | | | the node it lands on framed, s+48 to s+60 | | s+6 to s+54, +18 | the old arrow, dashed, holds, then fades | the same | A pointer made null draws no new arrow; the old one still lingers, in both panels (today only the nodes keep it). ### A pointer followed `cur = cur->next`. | Frames | | | --- | --- | | r to r+6 | the `next` word, and the node's pointer half, framed as read | | s = r+18 | the variable's own word (a local on the stack) is struck: it is where the address was written | | s+18 to s+48 | `cur`'s pin travels along the drawing's bottom lane to the node it now points at, `glide`: 30 f to the next node, 36 f to one farther | Low level first: the word changes, then the pin moves. Where the variable is a register, its strike is in the CPU's slot and a `link` carries the pin instead. A pin that appears (`next` the first time) fades in rising 8 units over 12 f; two names that meet on one node keep their sides, and a name that joins or leaves cross-fades over 12 f. ### A call pushed Three levels shown: the registers, the stack, the tree ([mock 12](mock/12-calls-subject.png) is its frame 108). | Frames | | | --- | --- | | 0 to 12 | fire on the line that calls | | 6 to 18, 18 | arm, strike: `rdi`, the argument | | 12 to 24, 24 | arm, strike: `rsp`. Its pin stays on the window's top row: no link | | 30 to 48 | the stack's rows slide down one slot, `glide`, as rows making room do: the new top row comes in with them | | 48 to 60, 60 | arm, strike: the return address, in the new top row; the new frame's `call` span (gold, `fib(2)`) and its `backtrace` row fade in with the strike, the old ones going to rule and dim | | 66 to 72 | the new backtrace row's bracket (`project`): the frame the return address made | | 72 to 102 | the projection draws from it into the gutter beside the drawing and along the drawing's bottom lane to the place of the new node, 30 f, `standard` | | 90 to 102 | the edge draws from the caller's node, arriving with the line | | 102 to 108 | the callee's node fades in gold; the caller's goes from gold to a waiting ring | | 108 to 144 | hold | | 144 to 156 | the advance: the mark on the calling line cools to the trail, out 6 f; in 6 f on the callee's first line (the panel scrolls first if it must); the projection draws back out (18 f) | | 156 to 180 | rest | A call is a jump: the mark does not cross the lines between ([sheet](motion/sheets/fib-02.2-mark-crosses-seven-lines.png): seven lines in five frames). ### A return | Frames | | | --- | --- | | 0 to 12 | fire on the `return` | | 6 to 18, 18 | arm, strike: `rax`, the answer | | 12 to 24, 24 | arm, strike: `rsp` | | 42 to 48 | the return address framed as read (`ret` reads it); the frame's backtrace row takes its bracket | | 48 to 78 | the projection, in read's colour, draws from that row to the node, 30 f | | 78 to 90, 90 | arm, strike: the node's result on its shoulder, rax's digits; the node goes from gold to done, the caller from waiting to gold | | 96 to 108 | the frame's span and backtrace row fade out, `exit` | | 108 to 126 | the stack's rows slide up to the new rsp, `glide` | | 126 to 150 | hold | | 150 to 162 | the mark jumps back to the caller's line; the projection draws back | | 162 to 186 | rest | The answer's tie is its digits: rax's and the badge's are the same number, struck one level apart. A line from rax would be a sixth thing in the frame saying what the digits say. ### The line changes | | Frames | | | --- | --- | --- | | to a line 1 to 8 rows away, in view | 12, and 2 a row beyond the first, 24 at most | slides, `standard`; the number appears in the plaque when it lands | | a call, a return, more than 8 rows | 6 out, 6 in, the in starting as the out ends | the old place takes the trail's first colour | | to a line out of view, within a window's height | 24 before the mark moves | the text scrolls by whole lines, `glide`; never a cut | | to a line farther than that (another function, line 42 290 after 80 895) | 12 out, 12 in, before the mark moves | the window fades through: scrolled, it would only blur | The trail shifts without animation. ### A system call `openat(AT_FDCWD, "note", O_RDONLY)`, followed down to libc's `syscall` row ([`descent`](README.md#descent)). The kernel is under the program: its window opens under the row, at the floor of the descent. Stepped over (a line that calls the wrapper, not followed down), the same window opens under the call row instead. | Frames | | | --- | --- | | 0 to 12 | fire on the `syscall` row | | 18, 24, 30, 36 | `rax`, `rdi`, `rsi`, `rdx` (and `r10`, `r8`, `r9` as the call has them) framed as read, 6 f each, the argument rows hanging under the `syscall` row with them (`echo`): only those that hold the argument at the stop shown | | 48 to 72 | the crossing lane draws down from the plaque, 3 units, vellum, `standard` | | 66 to 78 | the kernel's window opens where it lands, the vellum filling down from the lane's head | | 78, 84 | its head, then the call in C's form, each fading in over 6 f | | 120 to 144 | a call with work: a flow draws from the kernel's window up the gutter to `buf` in the view (`read`; for `write` the bytes are framed as read first and the flow goes down) | | 144 to 176 | the bytes strike 2 f apart; no pulse | | 180 to 186 | `returns` takes the value, struck: the kernel answers before the answer travels | | 186 to 210 | the answer climbs the lane to the `syscall` row | | 198 to 210, 210 | arm, strike: `rax`, as it lands | | 216, 222 | the registers the call clobbers, `rcx` and `r11`, 6 f apart; the band's log takes its new row (12 f, secondary) | | 222 to 258 | hold | | 258 to 270 | advance: the kernel's window draws back up into the lane (12 f) and the lane into the plaque as the plaque moves on | | 270 to 294 | rest | The result is stored only after the kernel has given it: `returns` has the value before rax, and rax before anything the caller does with it, never the other way round. A call with no bytes to move (`open`, `close`) does not wait: it goes from 84 straight to `returns` at 108, the answer climbs 108 to 132 in its full 24 f, and the step is 3.6 s; one that moves bytes, 4.9 s. The band's view changes with the arguments' framing (18 to 36): the last call's bytes out (12 f), this one's in (12 f), a path or a buffer handed in whole, a buffer the kernel fills as dots until 144 to 176; it is cleared when the log takes the row. **Stepped over.** A line that calls libc's wrapper (`n = read(f, buf, 32);`) is three parts, in the order the machine does them; the kernel's window opens under the call row, and the wrapper is not shown. | Frames | | | --- | --- | | 0 to 12 | 1, the instructions before the call, a cascade: fire on the line | | 6 to 18, 18 · 12 to 24, 24 · 18 to 30, 30 | arm, strike: the argument registers, in the order the instructions set them (`rdx` 32, `rsi` buf, `rdi` 3), the disassembly's trail following them | | 36 to 48, 48 | a store the line makes before the call, in memory's slot | | 60 to 72 | the plaque advances onto the call row; the line stays current | | 72 to 90 | 2, the crossing, on the chart above with its frame 18 at 72 (no second fire): the arguments framed with their new values, 6 f apart, the view's bytes changing with them | | 102 to 126 | the crossing lane, from the call row's plaque down to the kernel's window under it | | 120 to 132 | the window opens and its call fades in | | 198 to 230 | the bytes the kernel fills strike, 2 f apart (none for `open` or `close`, whose `returns` comes at 162) | | 234 | `returns` | | 240 to 264 | the answer climbs to the call row | | 264 | rax struck as it lands | | 270, 276 | `rcx`, `r11` | | 270 to 282, 282 | 3, the stores after the call, in their own slot 18 f after rax: `n`, `[rbp - 0x34]` | | 282 to 318 | hold | | 318 to 330 | advance; the kernel's window draws back up into the lane | | 330 to 354 | rest: 5.9 s for `read`; `close`, with no bytes and no store, 4.5 s | The order is the claim: no register is framed as an argument before the instruction that set it has struck, the kernel shows nothing before the lane lands, and nothing the caller does with the result moves before rax. A step that makes more than one call (a continue through a library) is not a crossing: the log takes the calls, oldest first, 2 f apart, and the step is a `continue`. Nothing on the kernel's side changes before frame 66: the kernel does not know the call until it has crossed. ### A call followed down `call open@plt`, followed into the stub and on to libc's `open` ([mock 16](mock/16-descent.png)). Its first 60 frames are any call's. | Frames | | | --- | --- | | 0 to 12 | fire on the call row | | 12 to 24, 24 | arm, strike: `rsp`. Its pin stays on the window's top row | | 30 to 48 | the stack's rows slide down one slot, `glide` | | 48 to 60, 60 | arm, strike: the return address, `main+48` | | 66 to 78 | the caller's window closes round its call row, first move: the rows it gives up fade out (those after its return row, and from its top as many as the callee needs) | | 78 to 96 | second move: the rows it keeps glide up to their places, `glide`, where they move at all. Never both at once: a row gliding over a row fading is text on text | | 84 to 96 | the call row's gold plaque becomes the waiting ring | | 96 to 114 | the call lane draws down from the ring, head first, `standard`, to the head's place directly under the return row | | 108 to 120 | the callee's head fades in rising 8 units as the lane reaches it | | 114 to 138 | its rows fade in top down, 2 f apart, 12 f each | | 138 to 150 | the advance: the plaque lands on the callee's first row; the source's line goes `waiting` (6 f) where the callee has no source | | 150 to 174 | rest: 2.9 s | The stub's `jmp`, the next step, reads its GOT slot: fire (0 to 12); the slot framed as read in memory, on the map or in a loupe, and the row's annotation names it (18 to 24); the stub's other rows fade (24 to 36), then its `jmp` row, `pass`, glides to its place (36 to 54, `glide`); the lane runs on from it to `open`'s head (54 to 72); `open`'s head and rows come in as above (66 to 96); the stack span's name and the source's tag crossfade to `open`'s (84 to 96, 12 f, never in a frame); advance (96 to 108). A jump is not a call: nothing is pushed. **Back up.** `open`'s `ret`: | Frames | | | --- | --- | | 0 to 12 | fire on `ret` | | 18 to 24 | the return address framed as read on the stack | | 24 to 36, 36 | arm, strike: `rsp` | | 48 to 72 | `open`'s window closes, its rows fading bottom up, 2 f apart, 12 f each, its head last; the stub's `pass` row with it: the return skips the stub | | 72 to 84 | the lane draws back up into the ring | | 84 to 102 | main's window opens in the reverse of its closing, first move: the rows it kept glide back down to their places, `glide` | | 102 to 114 | second move: the rows it gave up fade in | | 114 to 126 | the ring becomes a trail bar, the call's annotation takes its result (`= 3`, 6 f), and the plaque lands on the row after the call; the source's line from `waiting` to `current`, its tag crossfading | | 126 to 150 | rest: 2.5 s | A descent is a beat the narration names, and each of its steps is walked: at a run the windows open and close in 8 f with no lane drawn, and at a sprint the scene surfaces to the map, where the disassembly column is the descent whole. ### A continue A stop far from the last: a breakpoint hit, thousands of instructions on. The levels are the cascade's; what is in them is not one write each. | Frames | | | --- | --- | | 0 to 12 | fire on the line the program left from | | 18 to 18 + 2n + 6 | the n registers that changed strike in a wave, top to bottom in pwndbg's order, 2 f apart; the fill in over 6 f; no arm, no pulse | | then 18 f | memory: the stack's window scrolls to the new frame (24 f) when that is within six slots, else fades out (12 f) and in (12 f) with no marks; a dump the scene keeps follows its region the same way | | with it | the backtrace: frames that end fade out (12 f); frames both stops share slide to their new depth (24 f, `glide`); new ones fade in (12 f) | | then 18 f | the idea: the lens's drawing reacts, or a lens the scene brings comes in | | 36 f after the last strike | hold | | 12 | the advance: the mark jumps (6 out, 6 in), the source and disassembly fading through first when the new line is farther than a window | | 24 | rest; the clock's gold for every moment passed fades in at once | A dozen registers struck on one frame is a flash that says only "a lot"; the wave says it in about 0.6 s and lets the eye run down the panel with it. ### A pointer written in a panel of rows `n->next = head` where both nodes are rows of the dump: the bytes and the [`arc`](README.md#arc) between their rows are one event, the bytes first. | Frames | | | --- | --- | | s−12 to s | the arm on the word's bytes; the old arc, if its target was on screen, goes dashed | | s | the strike on the bytes that changed | | s+6 to s+18 | the old arc fades; the new one draws from the word's row along its lane to the target's row, head first, `standard`, full ink | | the advance to +24 | with the cool, the arc quiets to its standing ink | A pointer only read (`cur->next`) brings its arc to full ink with the read (6 f) and back with the advance. Where the new target is off the panel, the old arc fades and nothing replaces it, or a stub to the panel's rule if the target is in the same region but out of the window. ### A block left On a function's graph ([`graph`](README.md#graph); mock 24 is reverse's loop): `jg` decides between the swap and the next pass. | Frames | | | --- | --- | | 0 to 12 | fire on the `jg` row | | 18 to 24 | the compare's chips (`zf sf of`), on the `cmp` row above, framed as read: what decides | | 24 to 42 | the edge it takes draws gold, 3 units, from the port on its target's side to the target's top, `standard` | | 42 to 66 | the mark travels the edge: the plaque leaves the row, `glide`, 12 f and 2 f a 100 units (30 f at most); the row it left cools to the trail | | 66 | it lands on the target's first row: the advance | | 60 to 72, 72 | arm, strike: the target's count, `×5` to `×6` | | 66 to 84 | the oldest of the three trail edges cools to `dim` | | 84 to 108 | rest: 1.8 s | **A loop's turn** is the same along the back edge: down out of the block, out to the lane, up the lane (the one thing that climbs), in at the header's head; the lane's count, `×2` to `×3`, is struck as the mark goes in. The mark keeps its speed on the climb: a lane of 400 units is 20 f. **Rows into blocks** (`spread`, and back, `gather`): a scene that shows its disassembly as a graph on the map, or a `dive` and a `surface` between the map's graph and the working frame's rows. What persists slides: every row travels from its place in the column to its place in its block (36 f, `glide`, the blocks 4 f apart in layer order), and only then do the blocks' frames and heads fade in round them (12 f) and the edges draw, layer by layer (2 f apart, 12 f each). Backwards, the edges and frames go first and the rows glide home last. No text is ever over text: a row moves only over page. **At a run and a sprint** the graph is at its best: a pass is a path. At a run the mark goes block to block in 8 f, each edge it takes flashes gold and cools in 8 f, the counts change in place; nothing is struck. At a sprint, on the map, the gold moves only when the block changes (4 f at most), the three trail edges follow it, the loops' lanes count, and the picture settles at the phrase's end: the counts are where the run left them, the heat of the path in their numbers. ### A pointer opened A `loupe`, on a beat the caption names: `rdi` has just taken the next node, and the heap round it is opened beside it. | Frames | | | --- | --- | | p to p+6 | the pointer's hop framed as read | | p+6 to p+24 | the stem draws from the end of its row to the loupe's place, head first, `standard` (30 f where it is longer than 1200 units) | | p+6 to p+24 | the loupe rises with it: fading in over 12 f from 8 units lower, its shadow growing from nothing to 12 and 16 over 18 f, `standard` | | p+30 to p+36 | its target's bright frame | | p+36 to p+96 | held: the caption reads it | | q to q+36 | from a pointer inside it, the next opens the same way, over its lower rows, its shadow 20 and 26 | | the advance after | close, the deepest first: the stem draws back (12 f), the loupe sinks, fading as it falls 8 units (12 f); the other 6 f after | Two loupes at most; a third closes the first as it rises. Nothing else moves while a loupe rises: it is a beat of its own, or the idea's slot of a step, never two at once. At a run or a sprint none opens. ### A swap The compare in the step before is its anticipation: both cells framed as read. Low level first: the bytes change, the tie carries it, the cards fly. | Frames | | | --- | --- | | 0 to 12 | fire on the `swap` | | 6 to 18, 18 | arm, strike: the first element's bytes in the dump (a run of its type; only the bytes that change) | | 12 to 24, 24 | arm, strike: the second's | | 24 to 30 | the first run's bracket; the second's echoes on its own row at 30, with no line | | 30 to 48 | the projection draws from the first run to its cell, 18 f | | 48 to 54 | the first card lifts (1.12, 6 units off its cell) | | 54 to 60 | the second lifts | | 54 to 84 | the first flies over, `glide`, 30 f for neighbours | | 60 to 90 | the second flies under, under the index pins' names | | 84, 90 | each lands: back to size on its last 6 f, then its cell is struck | | 90 to 126 | hold | | 126 to 138 | advance | | 138 to 162 | rest | Each cell keeps its old digits, faint, until its own landing. Its bar (`held`) is on the cells whose value changed, and on no other. ### A node linked `n->next = head` is a pointer written (above). A node allocated: | Frames | | | --- | --- | | slot 0 | the heap strip's block fades in, 12 f; in the words, rows make room (18 f) and arrive with dots (12 f) | | slot 1 | the node fades in, 12 f, with dots in both halves, at its place in the row; nodes after it glide aside first (18 f) | `head = n`: `head`'s word is struck; its arrow redraws to the new node as for any pointer; the other nodes glide to their new places 18 f after the arrow lands. ### The camera In, to x2: | Frames | | | --- | --- | | before | the level's caption has been up at least 60 f; nothing is mid-step | | 0 to 24 | a bright 3-unit frame on the target (6 f in) | | 12 to 30 | everything else on the stage fades out; the head and the caption stay | | 30 to 102 | the move, `glide`, on the logarithm of the scale; the frame fades over its first 12 f; the rail's gold square slides to the level | | 102 to 138 | still | Out is the same backwards: the move, then the other panels fade in 6 f apart, then 36 f still. Sideways at x2 (registers to stack) is not out and in: the target fades out (12 f), the next fades in at x2 (12 f), the rail's square slides. 0.5 s instead of 2.6. On the stack the window holds still from the frame on the target to the way back: it is set before the move so that the slots the visit's steps will write are in its middle, with `free` slots above rsp for the pushes. A push fills one of them; rsp's pin climbs to it (24 f, `glide`), rbp's travels the same way, and no row of the panel moves. The frame at x2 is 896 by 384 units, on the 24-unit grid: the panel's tag and as many whole rows as fit, with the rows the next steps will change in the middle third. If they move out of it the frame glides a whole row (24 f) between steps. The stage clips what the camera shows at y = 112 and 888. Two seconds at x2 without a change and the camera should not be there. ### The map and the working frame The working frame's panels are windows onto the map's columns; the minimap in its corner is the map at a twentieth, with the windows drawn on it. Going between the two is the most cinematic move there is, and the rule for it is the camera's: the viewer never loses where they are. So it is one continuous move, in which nothing appears and nothing jumps: the windows rise out of the map and become the panels while the map falls away into the corner and becomes the minimap, the windows' outlines riding on it. It is not a camera move on one world (the working frame is not a crop of the map: there the source is over the disassembly, here beside it) and not a `relayout` (that keeps the text's size): every panel has its own path and its own scale. `dive`, the map to the working frame: | Frames | | | --- | --- | | before | the map is still and the caption that says where we are going has been up 60 f | | 0 to 6 | the windows' outlines go bright | | 6 to 24 | the rest of the map takes the veil, 50% | | 24 to 96 | each window travels to its panel's place, its scale from a half to whole on its logarithm, `glide`; the panels set off 6 f apart in the frame's reading order (drawing, view, source, registers, disassembly, stack), each drawn over the ones before, so that two crossing are seen to cross. The map, veiled, travels the same 72 f to the minimap's rect (1664, 912, 192 by 108), its scale from a half to a twentieth on its logarithm: continuously, never dropped or hidden on the way | | 90 to 96 | as it lands, the falling map crossfades into the minimap's own drawing | | 72 to 96 | the drawing crossfades from the map's size to the frame's within its box | | 84 to 102 | the working frame's tags, rules and lanes fade in; the veil on the map lifts as it lands; the clock's count fades in | | 102 to 138 | still | `surface` is the same backwards and a little quicker (the eye already knows the map): the tags fade (12 f), the panels shrink into their windows as the minimap grows to fill the frame (72 f, `glide`, the same stagger in the reverse order), the veil lifts (12 f), 36 f still. What is played on the map, and why: - **A sprint**: `surface`, then the sprint on the map: the current row's gold moves with the pc, the windows glide to follow it (8 f), strikes appear as their small vermilion and fade; then `dive` at the stop it reaches. On the map a sprint can be seen as a shape (the pc walking the function, the stack growing down its column), which in the working frame it could not. - **A far `continue`**: where the windows' new places are farther than their own heights, `surface`, the jump on the map (the gold goes out and in at the new place, 6 and 6, the windows glide there, 36 f), `dive`. - **A long run** may stay in the working frame; it surfaces only if it leaves the windows. In the working frame the minimap is secondary action: its windows glide with their scrolls (24 f), a mark no window shows `flash`es on it once (12 f) as it is struck, and every change on it starts 6 f after the primary onset it follows, never on that frame. A scene that opens on the map establishes it (0 to 48), its first caption at 60, dives at 150, and has its first step by 300 (5.0 s). ### Captions, opening, closing | | Frames | | --- | --- | | a caption leaves | 12, `exit` | | nothing | 6 | | a caption arrives, rising 8 units | 18, `enter` | | on screen, from arrived to leaving | at least 90 + 3.6 a character; at most 720 | | the stage stays still after it | 60; 120 after a scene's first | | panels arrive at the opening | 18 each, 6 apart, all by 48; the drawing's elements by 54 | | a scene's first caption arrives | at 60 | | a scene's first step fires | by 240 | | still on the last picture | 120, after the last caption's reading time | ## Tokens Every figure on this page is a token in `anim/src/theme.zig` (`time`, `bezier`, `pulse`), and the verbs of the [catalogue](README.md#6-verbs) use the same figures. Where the file and the documents still differ is listed once, under the catalogue's [Token changes](README.md#token-changes). Every figure is an even number of frames at 60, so a 30 fps export keeps them whole. Review at 60 all the same: at 30, today's 0.25 s run alternates steps of 7 and 8 frames. ## The five scenes In each, most valuable first. Times are seconds into the exported file. ### fib 1. **The run is the scene.** 12.77 to 29.77: 68 steps at four a second, each a single frame in which the mark jumps, a card and a node appear and two registers flash solid ([sheet](motion/sheets/fib-12.8-run.png)). 55% of the running time. Ramp into a run (four steps), run only down the first branch (about 12 steps, with a rest at each call), then sprint the rest with registers veiled and the tree as the subject. 2. **No return is ever walked.** The three steps shown in full are three calls. What recursion is *for*, an answer coming back in `rax` and a card leaving, happens only inside the run. Slow to a walk for the first return (`fib(1)`, at 14.8) and for the last (`fib(5)` = 5, at 29.77, now a pop one second before the cut). 3. **Each walked step is one frame wide.** 2.27, 6.77, 11.27: mark, tree node, card and two registers all start at the same frame and finish within eight ([sheet](motion/sheets/fib-02.2-call-all-at-once.png)). Sequence them as "A call pushed". 4. **Nothing is established.** Panels are whole at 0.43, the caption at 0.73, the first step at 0.77 ([sheet](motion/sheets/fib-00.0-opening.png)). The panels must be in and the first caption read before anything moves: see [Open](#the-rhythm-of-a-scene). 5. **1.5 s for everything.** 5.27 and 9.77 move one line and then wait 1.23 s; 2.27 pushes a call through four panels in the same time. 6. **The mark sweeps seven lines in five frames** at 2.27, 6.77, 11.27. A call is a jump. 7. **The digit pop**, 0.80 s after each strike (1.57, 3.07, 4.57, ...): bold ink to ordinary digits with faint zeros in one frame, alone on a still picture. 8. One caption for 31 s. It needs three: the call, the return, the tree. 9. Ends 1.0 s after the answer arrives. ### list 1. **The reversal cannot be followed.** The scene exists to show three `next` fields turning. The first turn is walked (22.50) and the other two are in the run at 25.53 to 29.03, a frame each. Walk the first trip round the loop, run the second with its eases and a rest, walk the third. 2. **Four panels on one frame**, every step: 5.27, 6.77, 21.00, 22.50 ([sheet](motion/sheets/list-05.2-write-in-four-panels.png)). Memory first (strip and words together), the node 18 f later, the mark last. 3. **The rewrite at 22.50 has no anticipation and two endings.** In the words the old arrow vanishes on the strike's frame; in the nodes it goes dashed for 0.8 s ([sheet](motion/sheets/list-22.5-pointer-rewritten.png)). Dash it during the arm, in both. 4. **Things appear from nothing.** 2.27: the source panel is `main` on one frame and `push` on the next ([sheet](motion/sheets/list-02.2-source-cut.png)). 5.27: a row of memory exists, struck, where there was none. 11.27 to 14.50: two nodes arrive in pops. Scroll, make room, fade in. 5. **Three empty steps in a row**: 16.50, 18.00, 19.50 each move one line and wait 1.23 s, straight after the caption that promised the reversal. At 0.8 s each they are a lead-in; at 1.5 they are 4.5 s of nothing. 6. Captions crossfade at 14.80 and 29.03: at 14.87 both are on screen, one over the other. 7. Node bodies change pigment whenever `cur`, `prev` or `next` moves on: colour changes that are not writes, every step of the loop. Keep the pigment on the variable's tag and plaque. 8. The frees (30.77, then 35.27 to 38.03) are pops. Walk one, run two. ### sort 1. **The first swap is at 20.5 of 36.6 s.** Twelve walked steps (2.27 to 18.77) show three trips round the loop in which nothing swaps. Walk one, run two, and reach the swap by 10 s. 2. **The caption about the swap arrives 0.2 s before it** (20.30, the flights lift at 20.50). Bring it up at the rest before, and hold 2 s. 3. **The flights are a jump and a crawl.** Lift 0.10 s; two frames later the cards are two fifths of the way; they spend their last eight frames (0.27 s) on the final few units, hovering over the faint digits they are about to replace ([sheet](motion/sheets/sort-20.4-swap.png)). `glide`, 30 f, the second 6 f behind the first. 4. **Both cells strike on one frame** (21.23) and their pulses merge into one block. One lands, then the other; the pulse is an outset. 5. **36 steps, swaps and compares alike, in a 9 s strobe**, 26.53 to 35.27. Run two trips, sprint the rest, slow for the last swap. 6. Read frames from each compare stand through the rest and vanish in one frame at the next step ([sheet](motion/sheets/sort-06.7-step.png), f202 to f203). 7. Every third step (5.27, 9.77, 14.27, 18.77) moves one line and waits 1.25 s. 8. The sorted array is on screen for 1.0 s and nothing says it is sorted. ### syscalls 1. **Effect before cause.** At the first frame of each step (3.77, 6.77, 9.77) the kernel's side already shows the new call, decoded, with its card pushed ([sheet](motion/sheets/syscalls-03.7-kernel-pops.png)); the arrow sets off afterwards. For `read`, `buf` is struck full at 3.77 and the arrow comes back at 4.9 ([sheet](motion/sheets/syscalls-03.7-read.png)). `write` already copies its bytes in order, after the arrow: that is the model ([sheet](motion/sheets/syscalls-09.7-write.png)). 2. **Four calls in 13.8 s under one caption.** This is the richest scene and the shortest. Each call wants its own line of caption, its own 2 s lead, and the 3.5 to 4.8 s the chart gives it: about 30 s. 3. **Everything on the kernel's side pops**: name, rows, list. 4. **3.0 s a call whatever it does.** `close` has one number in and one out; `read` moves fifteen bytes. 5. The registers reload their arguments in one frame at the step's start, unmarked. Frame them one at a time: they are what the caption is about. 6. Starts 0.04 s after its caption; ends 1.0 s after `write` returns. ### zoom 1. **The CPU level has nothing to show.** 5.2 to 8.8 at x2 on the registers: `rip`'s digits change once (5.83, a pop) and `rdi` is struck once (7.33) ([sheet](motion/sheets/zoom-05.3-at-x2-registers.png)). The caption says "a handful of instructions" and no instruction is on screen. Until a line can unfold into its instructions, put the instruction in the head's `where`, and leave after the second step. 2. **Out and in again.** 8.83 to 11.43: back to x1, a caption crossfade in the middle (10.07), in to the stack: 2.6 s of the whole frame moving to go one panel to the right ([sheet](motion/sheets/zoom-08.7-out-and-in.png)). Fade through at x2. 3. **The subject is at the frame's edge.** 12.07: the return address is struck in the bottom row, half under the caption band; 13.57 the row above it ([sheet](motion/sheets/zoom-11.5-at-x2-stack.png)). The panel's tag is out of frame, so nothing says this is the stack. 4. **16.57: the grid jumps.** The `fib` divider moves four rows, every row shifts 20 units, `rsp`'s plaque teleports, and sixteen unknown bytes become digits with no mark, all between two frames ([sheet](motion/sheets/zoom-16.5-rows-jump.png)). 5. **Four seconds of nothing** at x2, 19.1 to 23.1, after one byte is struck at 18.07 ([sheet](motion/sheets/zoom-18.0-end.png)). 6. **The camera leaves unannounced** at 4.03, 0.03 s after a caption arrives, with no frame on its target; the source and stack slide away and the stack's edge stays in view ([sheet](motion/sheets/zoom-03.7-camera-in.png)). 7. Back at x1 (24.5) the memory caption is still up, one run step pops, and the scene cuts 1.0 s later. "And back up" needs its own beat: the mark on line 6 again, the three levels in view, 2 s. 8. Text under the zoom is steady ([sheet](motion/sheets/zoom-05.1-text-settles.png)): nothing to do. ## A scene: libc's heap from the inside Not a lens: a scene, drawn with the blocks the catalogue has, and two small additions (`nodes` in two rows with a `bin` at the second's head, and malloc's words `size` and `protected` in a dump). The program is [`mock/heap.c`](mock/heap.c): three pushes, two pops, a push. Every byte below is a recording's: `ztrace dbg` on it under glibc 2.44, stopped after each `malloc` and `free` returns ([mock 18](mock/18-heap.png)). **The frame.** Split `subject`. The band's drawing is `nodes` in two rows: the program's list from `head` over the tcache's free list for chunks of 0x20, headed by its `bin`. Its view is the heap by `fields`, seven rows, 405000 to 40506f, three chunks of two rows each and the next chunk's header: each size word read as `size` (`0x20 a m P`), a node's two words as the program's (`number`, `pointer`) while it has them and as malloc's (`protected`, then `bytes` noted `key`) while malloc does. Both lists are `arc`s in the view: the program's `next`s, and the free list's links to the pointers they protect. The tcache is a `loupe` hung from the view's row of the chunk it lives in (405060), two of its rows named: `num_slots[0]` and `entries[0]`. The disassembly is the program's; the calls to `malloc` and `free` are stepped over (free's own path is two hundred instructions: a descent into it is a scene of its own). **The map and the minimap.** The map's memory column holds the heap whole, from its start to the top's header (rows round what was touched, fieldless ones folded), the tcache as its own panel under it, and the arena (`main_arena`, in libc's data, far from the heap) as a dump by fields: `top`, `last_remainder`, `system_mem`, `flags`, and the bins' heads. On the minimap those three are where they sit; a strike on one no window shows (the top's header moving down when the tcache is cut from it) flashes there. **The beats.** Each `free` and the `malloc` that takes the head back are walked; pushes 2 and 3 are a run, which draws no strikes and no arcs and shows what it did settled at its end. | | Stop | Pace | What plays | | --- | --- | --- | --- | | 1 | the first `malloc` returns | walked | `fire`; `rax` struck and its `link` to the pin under the chunk, which fades in on the program's row, in neither list: no arrow into it (12 f); the view's rows come in unmarked, the region being new; the `bin` dashed, `dummy tcache` (before the first free the thread's tcache is a read-only dummy in libc). Then push's three stores walked: the value struck, `next` struck, `head`'s pin travelling to the node | | 2 | after `push(9)` | a run | pushes 2 and 3, twelve steps at a run: the nodes come in (8 f), values change in place unmarked; when the run ends the arcs of the `next`s fade in standing (8 f) | | 3 | the first `free` returns | walked | the chart below: the tcache made, the loupe opened on it, the node travelling to the bin's row | | 4 | the second `free` returns | walked | the chunk's first word struck on its three bytes that changed (`55 54 40`), then the key; the loupe opens again in the idea's slot (36 f) and in it `entries[0]` struck on its low byte alone (`50` to `30`), `num_slots[0]` 15 to 14 on its one byte; the free node glides one place right (18 f) and the new one travels down to the bin's head; the `arc` from 405030 to 405050 draws at full ink (12 f); the count 1 to 2, struck | | 5 | the next `malloc` returns | walked | `rax` struck and its link; the key's 8 bytes struck to zero; the loupe opens again, its head and count struck back on the bytes that changed; the arc from 405030 fades (the word is the program's again, read as `bytes`, `the old link`); the node travels up to the program's row (36 f), in neither list, its old link faint in the value's half; the count 2 to 1. Then `push` writes 25 and its `next`, walked, and that arc draws | The loupe on the tcache hangs over the stack, never over the registers (the free's register wave and malloc's `rax` are what the captions are about); it opens in each step that changes the tcache (3, 4, 5), in its idea slot, and closes at that step's advance: it is never open over a step it does not concern. Its tag reads `tcache_perthread_struct · 0x2f8 bytes` (76 two-byte counts and 76 pointers: 760), and a note that does not fit is cut with `…`, never in mid-word without it. **The captions**, on the rules (`say`; at least 90 f + 3.6 f a character, at most 720 f, arriving at least 60 f before the step they describe, in a rest). Frames from the scene's first; "lands" is when the caption has arrived, "leaves" when it starts to go. | Lands | Leaves | Least | Caption | The step it leads, at | | --- | --- | --- | --- | --- | | 78 | 396 | 317 | Three pushes and two pops: what malloc and free do to the heap. | main's `push(7)`, 198 | | 414 | 954 | 529 | malloc(16) cut a chunk of 0x20 off the top: its size word, 0x21, then the 16 bytes rax points at. The top is 0x20 smaller. | the malloc line, 474; push's stores to 954 | | 972 | 1570 | 428 | Two more pushes, at a run: three chunks in a row, each with P set, the chunk before it in use. | the run, 1032 to 1522 | | 1588 | 2068 | 263 | pop takes the head off the list: head = n->next. | the call to pop, 1648 | | 2086 | 2615 | 529 | free gave 9's chunk to the tcache, malloc's bin for 0x20. Its first word is the link now: 405, which is NULL, safe-linked. | the free, 2146 | | 2633 | 3113 | 245 | The second pop: head moves on, to 7's node. | the call to pop, 2693 | | 3131 | 3693 | 562 | The second free chains to the first: 405455 is 405050 xor 405, the chunk's own address shifted 12. The arc is the pointer it hides. | the free, 3191 | | 3711 | 4204 | 493 | malloc(16) took the bin's head, 405030: the tcache points at 405050 again, the key is wiped, the old link stays. | the call to push, 3771; its malloc, 3951 | | 4222 | the cut, 4762 | 295 | push writes 25 over the old link: the list is 25, then 7. | push's stores, 4282 to 4642 | Each caption leaves 18 f before the next lands (12 out, 6 of nothing) and only in a rest; none is up more than 598 f; the scene is 79.4 s, its last 120 f the finished picture. This replaces the rendered scene's caption up 31 s and the two that arrived after their steps. The first free, frame by frame, from its fire: | Frames | | | --- | --- | | 0 to 12 | fire on `free(n);` | | 18 to 30 | the registers `free` left changed, struck in a wave 2 f apart (`rax`, `rcx` 405, `rdx`, `rsi`, `r8`, `r10`): it was stepped over, so as a `continue` | | 54 to 66, 66 | memory: the chunk's first word armed and struck on its two bytes that changed (`05 04`), 1 f apart, the held corner to come on the first | | 72 to 80 | its second word, the key, its 8 bytes 1 f apart | | 90 to 102 | the next chunk's header struck on its three bytes that changed (`01 03 00`): the tcache's chunk, cut from the top at this first free; the top's own header has left the window and flashes on the minimap (6 f after) | | 102 to 138 | `open`: the loupe on the tcache, over the stack, its stem down the gutter from that row; its two fields framed | | 144, 150 | in the loupe: `num_slots[0]` struck on its one byte (16 to 15), then `entries[0]` on its three (`50 50 40`) | | 162 to 174 | the idea: the `bin`'s box crossfades from dashed to raised, `dummy tcache` to `tcache 0x20`, and the top's box crossfades to its new place and size, `0x20ca0` struck | | 168 to 210 | the node lifts (6 f) and travels down to the bin's row (36 f, `glide`); as it lands its outline goes dashed and its halves turn (12 f): the first word's half the link's well, the second hatched, `key`. `rdi`'s pin rides with it: the pointer was freed, not cleared | | 204 to 210 | the count fades in on the bin's shoulder | | 210 to 222, 222 | arm, strike: the count, 1 | | 222 to 258 | hold | | 258 to 270 | advance; the loupe closes with it | | 270 to 294 | rest: 4.9 s | **What the scene's author writes.** A sketch in the shape of `anim/scenes/sqlite.zig`'s fields: ```zig // The view: a chunk as the program has it, and as malloc does. const used = [_]Field{ .{ .at = 8, .len = 8, .reads = .size }, // size, A M P .{ .at = 16, .len = 8, .mark = 0 }, // value .{ .at = 24, .len = 8, .reads = .pointer, .mark = 1 }, // next: an arc }; const freed = [_]Field{ .{ .at = 8, .len = 8, .reads = .size }, .{ .at = 16, .len = 8, .reads = .protected, .mark = 2 }, // the tcache's next: an arc .{ .at = 24, .len = 8, .reads = .bytes, .note = "key" }, }; // Which a chunk gets is the recording's: the list each chunk is on, per stop. // The tcache, as a loupe from the row of its chunk: two fields of 760 bytes. const tcache = [_]Field{ .{ .at = 0, .len = 2, .note = "slots left" }, // num_slots[0] .{ .at = 0x98, .len = 8, .reads = .pointer, .note = "the head of 0x20" }, // entries[0] }; // The drawing: the list from `head`; the bin `tcache 0x20`, its count the // reader's (16 less the slots left), its chain the reader's, revealed. ``` **What the recording must hold, per stop.** The tracer's reader (`zt.heap.glibc`) has most of it; the scene needs: 1. The chunks in address order, each with its address, its size word (at address + 8) and the list it is on (in use, tcache and which, unsorted, small or large and which, the top). 2. For each chunk on a list, its two link words as stored and the pointers they protect, and how each chain ends (the end, memory not recorded, misaligned, a limit). 3. The tcache whole: its address, `num_slots` and `entries` (76 each on 2.44), and the capacity a bin starts with (16 here), so the count shown is what the bin holds. Before the first free, the thread's `tcache` pointer, at libc's dummy. 4. The arena: its address, `top`, `last_remainder`, `system_mem`, `flags`, and the bins' heads, each with its word's address. 5. The bodies of the in-use chunks the scene draws: the reader records them only when watched, so the heap's first kilobyte watched (`-w` on it) or `--around` round what each instruction touches. 6. Which bytes changed since the stop before (a pointer whose low byte alone moved is struck on that byte), and glibc's version: 2.44 makes the tcache at the first free, counts slots left, and has no fastbins. **Further beats on this glibc**, with the same blocks: a large chunk freed beside a live one goes to the unsorted bin (a third row, its `bin` the arena's bin, the chain ending `→ the bin`; the next chunk's `P` chip struck clear); a malloc that sorts it into a large bin (the node travels between rows); a chunk freed beside the top merges into it (the node fades into the top's box, whose size is struck). Fastbins only as a beat marked `glibc before 2.41`, under the 2.40 that runs through pwndbg's loader. **musl's mallocng** would keep the dump by fields (a group's header and its slots), the arcs (meta to group and back), a loupe on the meta (its `avail_mask` and `freed_mask` read as bits, as `size` reads A M P), and the per-class rows; but its free list is a bitmask in metadata kept apart from the chunks, not links inside them, so its drawing is a row of slots, nearer `array` than `nodes`, with no safe-linking to show. ## A scene: ASan against a plain build A [`pair`](README.md#pair): one small program built twice, plain and with clang's AddressSanitizer (`-O0 -g -fno-omit-frame-pointer -no-pie -fno-stack-protector`; Arch's clang turns the stack protector on by default, and with it the plain build dies in `__stack_chk_fail` instead of at `ret`), each recorded by instruction from `fill`. The program is [`mock/overflow.c`](mock/overflow.c): `char buf[16]; for (int i = 0; i < 32; i++) buf[i] = 'A';` in a function of its own. Every figure here is those two recordings' (mocks 26 to 28). **The program and its frame.** The tracer's tested `targets/overflow.c` (a bound `n`, gcc's layout) keeps `i` and `n` above the buffer at -O0: the loop overwrites them and runs on to the end of the stack, faulting at a store. This scene's program has a constant bound and is built with clang, which puts `i` below `buf` (rbp-0x14): the overflow reaches the saved rbp and the return address and the fault is the classic one, at `ret`. The target should become [`mock/overflow.c`](mock/overflow.c) with those flags. The ASan build is shown as a user meets it, with the fake stack (the default); with `detect_stack_use_after_return=0` the frame would be on the real stack between the same redzones, a simpler picture and a second scene. **What differs, as recorded.** - *The frame.* Plain: `buf` is at rbp-0x10, its last byte against the saved rbp, the return address the word after. ASan: `buf` is not on the stack at all but in a fake frame on ASan's fake stack (7bfff58f0000, 64 bytes): a header (magic `41b58ab3`, a descriptor `"1 32 16 5 buf:3"`, the pc, the real stack), `buf` at +0x20, a redzone at +0x30; the real stack holds only spills, the saved rbp and the return address, far away. The two stack panels are scrolled so that `buf` faces `buf`: then plain's saved rbp faces ASan's redzone, and its return address the redzone's second word. That facing is the scene. - *The code.* Line 4's store is one instruction plain (`mov [rbp + rax - 0x10]▮, 0x41`), eight a turn; ASan's turn is seventeen: the address, `shr rax, 3`, the shadow's load at `rax + 7fff8000`, `cmp al, 0`, `je` to the store; the partial check (`and rax, 7`, `cmp al, cl`, `jl`) and `call __asan_report_store1` only when the shadow is not 0. The prologue (38 instructions and `__asan_stack_malloc_0`, 250) writes the header and poisons the shadow, `f1 f1 f1 f1 f8 f8 f3 f3`; line 3, which plain has no instruction for, turns `f8 f8` to `00 00` (buf's scope begins). - *The shadow.* One byte for each word of the fake frame, on the word's own row of the stack panel ([`slot`](README.md#slot)): `f1` four times (the header), `00 00` (buf), `f3 f3` (the redzone). - *When they part.* At i = 16: plain's store writes `41` into the saved rbp's low byte (7fffffffed00 becomes 7fffffffed41); ASan's check loads `f3`, `je` is not taken, the partial check (`0 : f3`, signed 0 against -13) is not taken, and it calls `__asan_report_store1(7bfff58f0030)`; the store never runs. After that plain goes on alone: by i = 23 the saved rbp is `4141414141414141`, at i = 24 the return address briefly points at `fill+1`, by i = 31 it is `4141414141414141`; `pop rbp`, then `ret` faults on a non-canonical address: SIGSEGV, rip still at `ret`, exit 139. ASan's report: `stack-buffer-overflow on address 0x7bfff58f0030 ... WRITE of size 1 ... [32, 48) 'buf' (line 3) <== Memory access at offset 48 overflows this variable`. - *How long.* Plain: 263 instructions from `fill` to the fault. ASan: 578 to the report's call, then about 4.75 million to write the report and exit. **The beats**, with the captions on the rules (frames from the scene's first; a caption lands, leads its step by at least 60 f, 120 for the first, and leaves only in a rest; every one up its reading time and at most 642 f). Each step is a source line in both builds, or one turn of the loop; inside it each side walks its own rows (README, `pair`). | Lands | Leaves | Caption | The step, firing at | What plays | | --- | --- | --- | --- | --- | | 78 | 452 | Plain against AddressSanitizer: one loop writes 32 bytes into a 16-byte buffer. | `fill()` called in both, 198 | the call, as any; `establish` before it | | 470 | 884 | ASan's prologue moves buf to a fake frame and poisons its shadow: f1 before buf, f3 after. | line 2, the prologues, 530 | plain: two rows walked. ASan: its 38 rows at a run inside the step, `__asan_stack_malloc_0` stepped over; the fake frame's rows come in (12 f), the header's words struck; the shadow's cells struck 2 f apart, `f1 f1 f1 f1 f8 f8 f3 f3` | | 902 | 1255 | Line 3 is ASan's alone: buf's scope begins, its shadow f8 f8 turns 00 00. | line 3, 962 | ASan's one row, `only here`; plain holds; the two cells struck | | 1273 | 1651 | Before each store ASan reads buf[i]'s byte of shadow, at (addr >> 3) + 7fff8000. | i = 0, the check, 1333 | ASan's address and check rows walked, 36 f a row, the shadow cell framed as read when its load runs; plain's plaque waits on the row facing them | | 1669 | 2076 | It is 00: the store may go. Both write 'A'; plain in one instruction, ASan in seventeen. | i = 0, the stores, 1729 | both stores strike together (6 f apart, plain first), each side's `i++` | | 2094 | 2736 | Fourteen more turns, at a run: buf fills on both sides. | i = 1 to 14, a run, 2154 | a run: no strikes, no corners; buf's bytes change in place; settled at the end | | 2754 | 3118 | i = 15, the last byte of buf. Still 00 on ASan's side; still buf on plain's. | i = 15, walked, 2814 | both walked; the last 00 read | | 3136 | 3528 | i = 16, one past buf. Plain writes 'A' into the saved rbp; ASan reads f3, a redzone. | i = 16, they part, 3196 | the chart below | | 3546 | 3967 | ASan's branch to the store is not taken: it calls the report, which names buf and the write. | the report, 3606 | ASan's partial check and its call walked; its run stops: its registers give way to its stderr, the report's lines, the three the caption names framed | | 3985 | 4495 | Plain goes on alone: the saved rbp, then the return address, become AAAAAAAA. | i = 17 to 31, a run, 4045 | plain alone at a run; ASan's side holds its last picture; at the run's end the saved rbp and return address settled at `4141414141414141`, `differs` on their rows | | 4513 | 4903 | The loop ends; pop rbp, then ret to 4141414141414141: the CPU faults. SIGSEGV. | the loop's exit, `pop`, `ret`, 4573 | walked: rbp struck; `ret` faults: the `fault` mark on its row, hazard bands round an ink plaque, `SIGSEGV`; rip stays | The cut at 5023, 83.7 s, after 2 s on the two last pictures: a fault on the left, a report on the right. **The step in which they part** (i = 16), from its fire: | Frames | | | --- | --- | | 0 to 12 | fire on line 4, both sides' plaques on the turn's first row | | 18 to 66 | plain walks to its store, its rows spread over the time ASan takes to reach its check: ASan's address rows, 12 f each | | 72 to 78 | the two first different rows framed `attention`, one each side: plain's store, ASan's shadow load | | 84 to 96, 96 | plain: arm, strike the saved rbp's low byte, `00` to `41`; the row's value turns to 7fffffffed41 (`extend`) and its `differs` bar comes in (12 f) | | 102 to 108 | ASan: the shadow load's cell, `f3`, framed as read, and the load's annotation reads it | | 114 to 126 | ASan: `cmp al, 0`, its values `f3 : 0` and `zf` | | 132 to 150 | ASan: `je` not taken, its row's annotation `not taken`; plain's plaque goes on to `i++` | | 186 to 222 | hold | | 222 to 234 | advance | | 234 to 258 | rest: 4.3 s | **What the recordings must hold, each run, per stop** (beyond what any scene asks): the shadow bytes for the stack window and for every fake frame the window shows, each with the 8 application bytes it stands for; which words are a fake frame (ASan's fake stack mapping, the frame's base and size class) and its header decoded (magic, the descriptor's variables with their offsets, sizes and lines, the pc); the red zone under rsp (the plain build's `buf` and `i` live there); names for ASan's runtime (`__asan_report_store1`, `__asan_stack_malloc_0`); the run's stderr as written, by stop (the report's lines arrive by `write(2, …)`, 18 of them, 1.5 M to 4.7 M instructions after the call: a `continue` to the exit); a fault: the signal, rip and rsp at it, the exit status. And for the pair: the two recordings' stops matched by source line and by the loop's turn (i from its slot), so a step can be one line or one turn in both. ## Stills Seen while looking at motion; against `README.md`. - **Camera at x2**: the neighbouring panel shows at the frame's edge (the stack's divider and `rsp` plaque beside the registers, the source's bottom rule above them); on the stack the last row is cut by the caption band and the tag is out of frame. See "The camera". - **Kernel argument names** come from a type, not the call: `close` and `read` show their descriptor as `number`, `open` shows flags and mode both as `pointer`. They are `fd`; `path`, `flags`, `mode`; `fd`, `buf`, `count`. - **`rax`'s role** reads `result` while it holds the call's number going in. `number`, then `result` once it is struck. - A pointer in the kernel's rows is twelve digits unbroken (`7fffffffd8c0`); in fours, as everywhere. - On `write` the user's bytes are not framed as read; they still carry the ember of `read`, two calls and six seconds ago. - **Types** are in Zig's spelling for a C program: `[8]i32`, `i32`. The source says `int a[8]`. - **Two panels titled `heap`** in `list` (the strip and the words). - **Two dividers named `fib`** in the stack at x1: `fib(5)`, `fib(4)`. - The call stack clips its sixth card; elide below ("2 more"). - Unknown bytes become known with a reflow and no transition (zoom, 16.57). - A divider row inserted into the grid moves every row under it by 20 units. Give dividers a fixed place between rows. ## The ten changes 1. **Sequence the step.** Fire; effects one level at a time, 0.30 s apart, each armed then struck; the mark last. The kernel's side included: no effect before its cause. 2. **Time a step by its content** (0.8, 1.5, 2.0, 2.5 s) and rest a beat at each phrase end. 3. **Rebuild run and sprint.** 0.30 s steps with the mark and structures eased and values as embers; 24 steps at most; sprint beyond; ramp in over four steps and out over three; veil what cannot be read; counter and progress line. 4. **Let the picture and the caption be read.** The panels in by 0.9 s, the first caption at 1.0 s, the first step by 4.0 s; 2 s after a scene's first caption, 1 s after any other; each caption up for its reading time and at most 12 s; captions leave, pause, arrive; 2 s on the last picture. 5. **Walk the point of each scene once**: a return, each pointer turning, a swap by 10 s, each system call under its own caption. 6. **Anticipate every write**: the arm, the fill over six frames, the pulse as a 4-unit outset, the cool eased with the digits changing at its middle. 7. **New curves, and travel timed by distance**: `standard` 0.3, 0, 0.2, 1; `glide` 0.45, 0, 0.55, 1; the mark 12 to 24 f or a jump; flights 30 to 48 f, the second six behind. 8. **Direct the camera**: frame the target, clear the stage, move, hold; the tag and whole rows in frame with the action in the middle; sideways by fading through; never 2 s at x2 without a change. 9. **Nothing pops into a layout**: make room, then arrive; scroll, never cut; slide what persists; fade what becomes known. 10. **Show the instruction** at the CPU level, and review at 60 frames a second. ## The instruments [`motion/motion.py`](motion/motion.py): ffmpeg, numpy, Pillow. Regions and crops are in design units. ```sh cd design/motion python3 motion.py chart VIDEO --out charts # the chart, the events, the checks python3 motion.py auto VIDEO --out tmp/auto # and a contact sheet of every event python3 motion.py sheet VIDEO 20.4 21.4 --step 2 --crop 400,160,1120,368 python3 motion.py sheet VIDEO f66 f77 --diff # what changed, white on the frame dimmed python3 motion.py onion VIDEO f614 f636 --crop 400,160,1120,368 # every frame of a move in one picture python3 motion.py track VIDEO f139 f158 --color e8c46a # a colour's box and centre, frame by frame ``` `chart` compares each frame with the one before, in each region of the scene's layout (a table at the top of the script, keyed by the video's name; add a scene there). Any other name gets the working frame's: the program column, the state column, the caption's text alone (64 to 1464, 906 to 1032, clear of the clock's count), the clock and the minimap. A pixel *moved* if a channel changed by more than 24 of 255 and is *fading* if by more than 6. The picture is one bar a frame and one strip a region: solid for moving, outlined for fading, holds shaded with their length. The text lists every event with the first and last frame of each region in it, which is where simultaneity shows, and ends with the checks: | Check | Fires when | Wants | | --- | --- | --- | | POP | a region still for 12 frames or more changes in one frame and is still again, at any size (a label swapped, a count appearing, a box gone, a window that jumped); or over 0.2% of the frame changes within two frames, still either side. The clock's count is exempt: it is time | a crossfade, a fade, an arm and a strike | | CROWD | three or more panels begin within two frames of each other | the cascade | | METRONOME | seven or more events of over 0.5% of the frame, evenly spaced | content-timed steps, phrase rests | | CAPTION | a caption is on screen over 720 f, or under 90 f + 3.6 f a character, or the picture moves less than 60 f after it arrives. Its time on screen runs from the end of the change that brought it to the start of the next. `design/motion/motion.py` reads the video only, so it holds a caption to 90 f; `anim/tools/chart.py`, which has the scene's captions, counts their characters | a second caption, a shorter scene, a later step | | AIR | nothing changes for three seconds | a shorter hold, or something to say | A scene is ready for eyes when all five are empty or each remaining line is deliberate. They are not taste: a chart can pass and still be dull. Limits: regions are fixed on the screen, so under a camera move their names stop meaning panels; `track` follows a colour, so crop to one object (its box columns are the honest ones when two share the colour); the thresholds suit x264 at the export's quality and will need loosening for a harder encode. x264's default keyframe every 250 frames shows as a one-frame change in every region every 4.17 s: the encoder, not the scene; export with `-g 600`. What is kept: `motion/charts/` (chart, events and per-frame counts for the five scenes as reviewed) and `motion/sheets/` (the sheets this page cites, named scene, second, what). `motion/tmp/` is scratch.