Critical Code Studies


Kittler's Code

matrices.s is the assembly code that performs the matrix operations used in Kittler's raytracer.

xsuptrace.c matrices.s German repository of Kittler's Code Lectures by Friedrich Kittler

Author: Friedrich Kittler
Year: early 1980s-2000s

Hardware: Pentium IV,
x86 family of processors
x87 family of floating point coprocessors
Languages: C and Assembly

II. Notes:

The % before register names is required by the GNU assembler (aka gas).

1. Comments are proceeded by #. This assembler code was written for the x86 Intel processor, using GNU assembler. This line means that the povasm.asm was ported to Linux with floating point arithmetic.

2. Compute_Axis_Transform was only formally tested.

4. This appears to be the date February 5, 2011, perhaps the last time Kittler worked on the code. Kittler died October 18, 2011.

8-10. .equ “sets the value of.” These statements assign values. For example, the first sets PII to 1.

12. .data assembles what follows to the data subsection.

13. .extern imports the symbol only if it is referred to. This is a bit unnecessary as the gnu assembler treats all undefined symbols as external ones. This is perhaps an old habit or a sign that this code was adapted from a different version of assembly.

14-21. creates empty matrices. .fill reserves the space to fill with values.

22. float converts the floating point number (flonum, in this case, 180.0) into binary floating point number.

24. The other subsection to complement .data is the .text section. This code assembles what follows to the .text subsection.

26-43 global variable declarations, naming the various matrix transformations.

45. .align places the next byte at an address evenly divisible by 8. The process of aligning accelerates memory access, a sign of Kittler’s programming priorities.

46. clobbers, a term from assembly, overwrites ecx, registers eax and adx are free.

47. pushl means put the long operand (l, meaning 32 bits) onto the stack.

48. movl, move the long operand from the stackpointer (esp) to esi.

50. xorl clears ecx, changing the operand to 0.

54-57. flds loads the product onto the stack. Fl refers to “floating point.”

73. Add the contents of register st to the register 5 after st.

77-80. In between, the two commands, decb (decrement) and jnz (jump as long as counter is not zero), Kittler has added instructions in order to buy time for the processor to catch up. See a full discussion of this process later in the chapter.