1 # Primitives are functions that are implemented directly in Mu.
2 # They always evaluate all their arguments.
4 fn initialize-primitives _self: (addr global-table) {
5 var self/esi: (addr global-table) <- copy _self
7 append-primitive self, "+"
8 append-primitive self, "-"
9 append-primitive self, "*"
10 append-primitive self, "/"
11 append-primitive self, "%"
12 append-primitive self, "sqrt"
13 append-primitive self, "abs"
14 append-primitive self, "sgn"
15 append-primitive self, "<"
16 append-primitive self, ">"
17 append-primitive self, "<="
18 append-primitive self, ">="
20 append-primitive self, "apply"
21 append-primitive self, "="
22 append-primitive self, "no"
23 append-primitive self, "not"
24 append-primitive self, "dbg"
25 append-primitive self, "len"
27 append-primitive self, "car"
28 append-primitive self, "cdr"
29 append-primitive self, "cons"
30 append-primitive self, "cons?"
32 append-primitive self, "print"
33 append-primitive self, "clear"
34 append-primitive self, "lines"
35 append-primitive self, "columns"
36 append-primitive self, "up"
37 append-primitive self, "down"
38 append-primitive self, "left"
39 append-primitive self, "right"
40 append-primitive self, "cr"
41 append-primitive self, "pixel"
42 append-primitive self, "line"
43 append-primitive self, "hline"
44 append-primitive self, "vline"
45 append-primitive self, "circle"
46 append-primitive self, "bezier"
47 append-primitive self, "width"
48 append-primitive self, "height"
49 append-primitive self, "new_screen"
50 append-primitive self, "blit"
52 append-primitive self, "key"
54 append-primitive self, "stream"
55 append-primitive self, "write"
56 append-primitive self, "read"
57 append-primitive self, "rewind"
59 append-primitive self, "array"
60 append-primitive self, "populate"
61 append-primitive self, "index"
62 append-primitive self, "iset"
64 append-primitive self, "img"
66 append-primitive self, "abort"
67 # keep sync'd with render-primitives
70 # Slightly misnamed; renders primitives as well as special forms that don't
71 # evaluate all their arguments.
72 fn render-primitives screen: (addr screen), xmin: int, xmax: int, ymax: int {
73 var y/ecx: int <- copy ymax
74 y <- subtract 0x11/primitives-border
75 clear-rect screen, xmin, y, xmax, ymax, 0xdc/bg=green-bg
77 var right-min/edx: int <- copy xmax
78 right-min <- subtract 0x1e/primitives-divider
79 set-cursor-position screen, right-min, y
80 draw-text-wrapping-right-then-down-from-cursor screen, "primitives", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
82 set-cursor-position screen, right-min, y
83 draw-text-wrapping-right-then-down-from-cursor screen, " fn apply set if while", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
85 set-cursor-position screen, right-min, y
86 draw-text-wrapping-right-then-down-from-cursor screen, "booleans", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
88 set-cursor-position screen, right-min, y
89 draw-text-wrapping-right-then-down-from-cursor screen, " = and or not", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
91 set-cursor-position screen, right-min, y
92 draw-text-wrapping-right-then-down-from-cursor screen, "lists", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
94 set-cursor-position screen, right-min, y
95 draw-text-wrapping-right-then-down-from-cursor screen, " cons car cdr no cons? len", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
97 set-cursor-position screen, right-min, y
98 draw-text-wrapping-right-then-down-from-cursor screen, "numbers", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
100 set-cursor-position screen, right-min, y
101 draw-text-wrapping-right-then-down-from-cursor screen, " + - * / %", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
103 set-cursor-position screen, right-min, y
104 draw-text-wrapping-right-then-down-from-cursor screen, " < > <= >=", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
106 set-cursor-position screen, right-min, y
107 draw-text-wrapping-right-then-down-from-cursor screen, " sqrt abs sgn", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
109 set-cursor-position screen, right-min, y
110 draw-text-wrapping-right-then-down-from-cursor screen, "arrays", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
112 set-cursor-position screen, right-min, y
113 draw-text-wrapping-right-then-down-from-cursor screen, " array index iset len", right-min, y, xmax, ymax, 0x2a/fg=orange, 0xdc/bg=green-bg
115 var tmpx/eax: int <- copy right-min
116 tmpx <- draw-text-rightward screen, " populate", tmpx, xmax, y, 0x2a/fg=orange, 0xdc/bg=green-bg
117 tmpx <- draw-text-rightward screen, ": int _ -> array", tmpx, xmax, y, 7/fg=grey, 0xdc/bg=green-bg
119 set-cursor-position screen, right-min, y
120 draw-text-wrapping-right-then-down-from-cursor screen, "images", right-min, y, xmax, ymax, 7/fg=grey, 0xdc/bg=green-bg
122 var tmpx/eax: int <- copy right-min
123 tmpx <- draw-text-rightward screen, " img", tmpx, xmax, y, 0x2a/fg=orange, 0xdc/bg=green-bg
124 tmpx <- draw-text-rightward screen, ": screen stream x y w h", tmpx, xmax, y, 7/fg=grey, 0xdc/bg=green-bg
128 #? var foo/eax: byte <- read-key 0/keyboard
133 y <- subtract 0x10/primitives-border
134 var left-max/edx: int <- copy xmax
135 left-max <- subtract 0x20/primitives-divider
136 var tmpx/eax: int <- copy xmin
137 tmpx <- draw-text-rightward screen, "cursor graphics", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
139 var tmpx/eax: int <- copy xmin
140 tmpx <- draw-text-rightward screen, " print", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
141 tmpx <- draw-text-rightward screen, ": screen _ -> _", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
143 var tmpx/eax: int <- copy xmin
144 tmpx <- draw-text-rightward screen, " lines columns", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
145 tmpx <- draw-text-rightward screen, ": screen -> number", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
147 var tmpx/eax: int <- copy xmin
148 tmpx <- draw-text-rightward screen, " up down left right", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
149 tmpx <- draw-text-rightward screen, ": screen", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
151 var tmpx/eax: int <- copy xmin
152 tmpx <- draw-text-rightward screen, " cr", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
153 tmpx <- draw-text-rightward screen, ": screen ", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
154 tmpx <- draw-text-rightward screen, "# move cursor down and to left margin", tmpx, left-max, y, 0x38/fg=trace, 0xdc/bg=green-bg
156 var tmpx/eax: int <- copy xmin
157 tmpx <- draw-text-rightward screen, "pixel graphics", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
159 var tmpx/eax: int <- copy xmin
160 tmpx <- draw-text-rightward screen, " circle bezier line hline vline pixel", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
162 var tmpx/eax: int <- copy xmin
163 tmpx <- draw-text-rightward screen, " width height", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
164 tmpx <- draw-text-rightward screen, ": screen -> number", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
166 var tmpx/eax: int <- copy xmin
167 tmpx <- draw-text-rightward screen, " clear", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
168 tmpx <- draw-text-rightward screen, ": screen", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
170 var tmpx/eax: int <- copy xmin
171 tmpx <- draw-text-rightward screen, "input", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
173 var tmpx/eax: int <- copy xmin
174 tmpx <- draw-text-rightward screen, " key", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
175 tmpx <- draw-text-rightward screen, ": keyboard -> code-point-utf8?", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
177 var tmpx/eax: int <- copy xmin
178 tmpx <- draw-text-rightward screen, "streams", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
180 var tmpx/eax: int <- copy xmin
181 tmpx <- draw-text-rightward screen, " stream", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
182 tmpx <- draw-text-rightward screen, ": -> stream ", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
184 var tmpx/eax: int <- copy xmin
185 tmpx <- draw-text-rightward screen, " write", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
186 tmpx <- draw-text-rightward screen, ": stream code-point-utf8 -> stream", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
188 var tmpx/eax: int <- copy xmin
189 tmpx <- draw-text-rightward screen, " rewind clear", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
190 tmpx <- draw-text-rightward screen, ": stream", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
192 var tmpx/eax: int <- copy xmin
193 tmpx <- draw-text-rightward screen, " read", tmpx, left-max, y, 0x2a/fg=orange, 0xdc/bg=green-bg
194 tmpx <- draw-text-rightward screen, ": stream -> code-point-utf8", tmpx, left-max, y, 7/fg=grey, 0xdc/bg=green-bg
197 fn primitive-global? _x: (addr global) -> _/eax: boolean {
198 var x/eax: (addr global) <- copy _x
199 var value-ah/eax: (addr handle cell) <- get x, value
200 var value/eax: (addr cell) <- lookup *value-ah
201 compare value, 0/null
206 var primitive?/eax: boolean <- primitive? value
210 fn append-primitive _self: (addr global-table), name: (addr array byte) {
211 var self/esi: (addr global-table) <- copy _self
215 abort "append primitive"
218 var final-index-addr/ecx: (addr int) <- get self, final-index
219 increment *final-index-addr
220 var curr-index/ecx: int <- copy *final-index-addr
221 var data-ah/eax: (addr handle array global) <- get self, data
222 var data/eax: (addr array global) <- lookup *data-ah
223 var curr-offset/esi: (offset global) <- compute-offset data, curr-index
224 var curr/esi: (addr global) <- index data, curr-offset
225 var curr-name-ah/eax: (addr handle array byte) <- get curr, name
226 copy-array-object name, curr-name-ah
227 var curr-value-ah/eax: (addr handle cell) <- get curr, value
228 new-primitive-function curr-value-ah, curr-index
231 # a little strange; goes from value to name and selects primitive based on name
232 fn apply-primitive _f: (addr cell), args-ah: (addr handle cell), out: (addr handle cell), _globals: (addr global-table), trace: (addr trace) {
233 var f/esi: (addr cell) <- copy _f
234 var f-index-a/ecx: (addr int) <- get f, index-data
235 var f-index/ecx: int <- copy *f-index-a
236 var globals/eax: (addr global-table) <- copy _globals
240 abort "apply primitive"
243 var global-data-ah/eax: (addr handle array global) <- get globals, data
244 var global-data/eax: (addr array global) <- lookup *global-data-ah
245 var f-offset/ecx: (offset global) <- compute-offset global-data, f-index
246 var f-value/ecx: (addr global) <- index global-data, f-offset
247 var f-name-ah/ecx: (addr handle array byte) <- get f-value, name
248 var f-name/eax: (addr array byte) <- lookup *f-name-ah
250 var add?/eax: boolean <- string-equal? f-name, "+"
251 compare add?, 0/false
253 apply-add args-ah, out, trace
257 var subtract?/eax: boolean <- string-equal? f-name, "-"
258 compare subtract?, 0/false
260 apply-subtract args-ah, out, trace
264 var multiply?/eax: boolean <- string-equal? f-name, "*"
265 compare multiply?, 0/false
267 apply-multiply args-ah, out, trace
271 var divide?/eax: boolean <- string-equal? f-name, "/"
272 compare divide?, 0/false
274 apply-divide args-ah, out, trace
277 # '%' is the remainder operator, because modulo isn't really meaningful for
280 # I considered calling this operator 'rem', but I want to follow Arc in
281 # using 'rem' for filtering out elements from lists.
282 # https://arclanguage.github.io/ref/list.html#rem
284 var remainder?/eax: boolean <- string-equal? f-name, "%"
285 compare remainder?, 0/false
287 apply-remainder args-ah, out, trace
291 var square-root?/eax: boolean <- string-equal? f-name, "sqrt"
292 compare square-root?, 0/false
294 apply-square-root args-ah, out, trace
298 var abs?/eax: boolean <- string-equal? f-name, "abs"
299 compare abs?, 0/false
301 apply-abs args-ah, out, trace
305 var sgn?/eax: boolean <- string-equal? f-name, "sgn"
306 compare sgn?, 0/false
308 apply-sgn args-ah, out, trace
312 var car?/eax: boolean <- string-equal? f-name, "car"
313 compare car?, 0/false
315 apply-car args-ah, out, trace
319 var cdr?/eax: boolean <- string-equal? f-name, "cdr"
320 compare cdr?, 0/false
322 apply-cdr args-ah, out, trace
326 var cons?/eax: boolean <- string-equal? f-name, "cons"
327 compare cons?, 0/false
329 apply-cons args-ah, out, trace
333 var cons-check?/eax: boolean <- string-equal? f-name, "cons?"
334 compare cons-check?, 0/false
336 apply-cons-check args-ah, out, trace
340 var len?/eax: boolean <- string-equal? f-name, "len"
341 compare len?, 0/false
343 apply-len args-ah, out, trace
347 var cell-isomorphic?/eax: boolean <- string-equal? f-name, "="
348 compare cell-isomorphic?, 0/false
350 apply-cell-isomorphic args-ah, out, trace
354 var not?/eax: boolean <- string-equal? f-name, "no"
355 compare not?, 0/false
357 apply-not args-ah, out, trace
361 var not?/eax: boolean <- string-equal? f-name, "not"
362 compare not?, 0/false
364 apply-not args-ah, out, trace
368 var debug?/eax: boolean <- string-equal? f-name, "dbg"
369 compare debug?, 0/false
371 apply-debug args-ah, out, trace
375 var lesser?/eax: boolean <- string-equal? f-name, "<"
376 compare lesser?, 0/false
378 apply-< args-ah, out, trace
382 var greater?/eax: boolean <- string-equal? f-name, ">"
383 compare greater?, 0/false
385 apply-> args-ah, out, trace
389 var lesser-or-equal?/eax: boolean <- string-equal? f-name, "<="
390 compare lesser-or-equal?, 0/false
392 apply-<= args-ah, out, trace
396 var greater-or-equal?/eax: boolean <- string-equal? f-name, ">="
397 compare greater-or-equal?, 0/false
399 apply->= args-ah, out, trace
403 var print?/eax: boolean <- string-equal? f-name, "print"
404 compare print?, 0/false
406 apply-print args-ah, out, trace
410 var clear?/eax: boolean <- string-equal? f-name, "clear"
411 compare clear?, 0/false
413 apply-clear args-ah, out, trace
417 var lines?/eax: boolean <- string-equal? f-name, "lines"
418 compare lines?, 0/false
420 apply-lines args-ah, out, trace
424 var columns?/eax: boolean <- string-equal? f-name, "columns"
425 compare columns?, 0/false
427 apply-columns args-ah, out, trace
431 var up?/eax: boolean <- string-equal? f-name, "up"
434 apply-up args-ah, out, trace
438 var down?/eax: boolean <- string-equal? f-name, "down"
439 compare down?, 0/false
441 apply-down args-ah, out, trace
445 var left?/eax: boolean <- string-equal? f-name, "left"
446 compare left?, 0/false
448 apply-left args-ah, out, trace
452 var right?/eax: boolean <- string-equal? f-name, "right"
453 compare right?, 0/false
455 apply-right args-ah, out, trace
459 var cr?/eax: boolean <- string-equal? f-name, "cr"
462 apply-cr args-ah, out, trace
466 var pixel?/eax: boolean <- string-equal? f-name, "pixel"
467 compare pixel?, 0/false
469 apply-pixel args-ah, out, trace
473 var line?/eax: boolean <- string-equal? f-name, "line"
474 compare line?, 0/false
476 apply-line args-ah, out, trace
480 var hline?/eax: boolean <- string-equal? f-name, "hline"
481 compare hline?, 0/false
483 apply-hline args-ah, out, trace
487 var vline?/eax: boolean <- string-equal? f-name, "vline"
488 compare vline?, 0/false
490 apply-vline args-ah, out, trace
494 var circle?/eax: boolean <- string-equal? f-name, "circle"
495 compare circle?, 0/false
497 apply-circle args-ah, out, trace
501 var bezier?/eax: boolean <- string-equal? f-name, "bezier"
502 compare bezier?, 0/false
504 apply-bezier args-ah, out, trace
508 var width?/eax: boolean <- string-equal? f-name, "width"
509 compare width?, 0/false
511 apply-width args-ah, out, trace
515 var height?/eax: boolean <- string-equal? f-name, "height"
516 compare height?, 0/false
518 apply-height args-ah, out, trace
522 var screen?/eax: boolean <- string-equal? f-name, "new_screen"
523 compare screen?, 0/false
525 apply-new-screen args-ah, out, trace
529 var blit?/eax: boolean <- string-equal? f-name, "blit"
530 compare blit?, 0/false
532 apply-blit args-ah, out, trace
536 var wait-for-key?/eax: boolean <- string-equal? f-name, "key"
537 compare wait-for-key?, 0/false
539 apply-wait-for-key args-ah, out, trace
543 var stream?/eax: boolean <- string-equal? f-name, "stream"
544 compare stream?, 0/false
546 apply-stream args-ah, out, trace
550 var write?/eax: boolean <- string-equal? f-name, "write"
551 compare write?, 0/false
553 apply-write args-ah, out, trace
557 var rewind?/eax: boolean <- string-equal? f-name, "rewind"
558 compare rewind?, 0/false
560 apply-rewind args-ah, out, trace
564 var read?/eax: boolean <- string-equal? f-name, "read"
565 compare read?, 0/false
567 apply-read args-ah, out, trace
571 var array?/eax: boolean <- string-equal? f-name, "array"
572 compare array?, 0/false
574 apply-array args-ah, out, trace
578 var populate?/eax: boolean <- string-equal? f-name, "populate"
579 compare populate?, 0/false
581 apply-populate args-ah, out, trace
585 var index?/eax: boolean <- string-equal? f-name, "index"
586 compare index?, 0/false
588 apply-index args-ah, out, trace
592 var iset?/eax: boolean <- string-equal? f-name, "iset"
593 compare iset?, 0/false
595 apply-iset args-ah, out, trace
599 var render-image?/eax: boolean <- string-equal? f-name, "img"
600 compare render-image?, 0/false
602 apply-render-image args-ah, out, trace
606 var abort?/eax: boolean <- string-equal? f-name, "abort"
607 compare abort?, 0/false
609 apply-abort args-ah, out, trace
612 abort "unknown primitive function"
615 fn apply-add _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
616 trace-text trace, "eval", "apply +"
617 var args-ah/eax: (addr handle cell) <- copy _args-ah
618 var _args/eax: (addr cell) <- lookup *args-ah
619 var args/esi: (addr cell) <- copy _args
621 var args-type/eax: (addr int) <- get args, type
622 compare *args-type, 0/pair
624 error trace, "args to + are not a list"
627 var empty-args?/eax: boolean <- nil? args
628 compare empty-args?, 0/false
631 error trace, "+ needs 2 args but got 0"
635 var first-ah/eax: (addr handle cell) <- get args, left
636 var first/eax: (addr cell) <- lookup *first-ah
638 var first-type/eax: (addr int) <- get first, type
639 compare *first-type, 1/number
641 error trace, "first arg for + is not a number"
644 var first-value/ecx: (addr float) <- get first, number-data
645 # args->right->left->value
646 var right-ah/eax: (addr handle cell) <- get args, right
647 var right/eax: (addr cell) <- lookup *right-ah
649 var right-type/eax: (addr int) <- get right, type
650 compare *right-type, 0/pair
652 error trace, "+ encountered non-pair"
656 var nil?/eax: boolean <- nil? right
657 compare nil?, 0/false
659 error trace, "+ needs 2 args but got 1"
662 var second-ah/eax: (addr handle cell) <- get right, left
663 var second/eax: (addr cell) <- lookup *second-ah
665 var second-type/eax: (addr int) <- get second, type
666 compare *second-type, 1/number
668 error trace, "second arg for + is not a number"
671 var second-value/edx: (addr float) <- get second, number-data
673 var result/xmm0: float <- copy *first-value
674 result <- add *second-value
675 new-float out, result
678 fn test-evaluate-missing-arg-in-add {
680 var t/edi: (addr trace) <- address t-storage
681 initialize-trace t, 0x100/max-depth, 0x100/capacity, 0/visible # we don't use trace UI
683 var nil-storage: (handle cell)
684 var nil-ah/ecx: (addr handle cell) <- address nil-storage
686 var one-storage: (handle cell)
687 var one-ah/edx: (addr handle cell) <- address one-storage
688 new-integer one-ah, 1
689 var add-storage: (handle cell)
690 var add-ah/ebx: (addr handle cell) <- address add-storage
691 new-symbol add-ah, "+"
693 var tmp-storage: (handle cell)
694 var tmp-ah/esi: (addr handle cell) <- address tmp-storage
695 new-pair tmp-ah, *one-ah, *nil-ah
696 new-pair tmp-ah, *add-ah, *tmp-ah
699 var globals-storage: global-table
700 var globals/edx: (addr global-table) <- address globals-storage
701 initialize-globals globals
703 evaluate tmp-ah, tmp-ah, *nil-ah, globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
707 fn apply-subtract _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
708 trace-text trace, "eval", "apply -"
709 var args-ah/eax: (addr handle cell) <- copy _args-ah
710 var _args/eax: (addr cell) <- lookup *args-ah
711 var args/esi: (addr cell) <- copy _args
713 var args-type/eax: (addr int) <- get args, type
714 compare *args-type, 0/pair
716 error trace, "args to - are not a list"
719 var empty-args?/eax: boolean <- nil? args
720 compare empty-args?, 0/false
723 error trace, "- needs 2 args but got 0"
727 var first-ah/eax: (addr handle cell) <- get args, left
728 var first/eax: (addr cell) <- lookup *first-ah
730 var first-type/eax: (addr int) <- get first, type
731 compare *first-type, 1/number
733 error trace, "first arg for - is not a number"
736 var first-value/ecx: (addr float) <- get first, number-data
737 # args->right->left->value
738 var right-ah/eax: (addr handle cell) <- get args, right
739 var right/eax: (addr cell) <- lookup *right-ah
741 var right-type/eax: (addr int) <- get right, type
742 compare *right-type, 0/pair
744 error trace, "- encountered non-pair"
748 var nil?/eax: boolean <- nil? right
749 compare nil?, 0/false
751 error trace, "- needs 2 args but got 1"
754 var second-ah/eax: (addr handle cell) <- get right, left
755 var second/eax: (addr cell) <- lookup *second-ah
757 var second-type/eax: (addr int) <- get second, type
758 compare *second-type, 1/number
760 error trace, "second arg for - is not a number"
763 var second-value/edx: (addr float) <- get second, number-data
765 var result/xmm0: float <- copy *first-value
766 result <- subtract *second-value
767 new-float out, result
770 fn apply-multiply _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
771 trace-text trace, "eval", "apply *"
772 var args-ah/eax: (addr handle cell) <- copy _args-ah
773 var _args/eax: (addr cell) <- lookup *args-ah
774 var args/esi: (addr cell) <- copy _args
776 var args-type/eax: (addr int) <- get args, type
777 compare *args-type, 0/pair
779 error trace, "args to * are not a list"
782 var empty-args?/eax: boolean <- nil? args
783 compare empty-args?, 0/false
786 error trace, "* needs 2 args but got 0"
790 var first-ah/eax: (addr handle cell) <- get args, left
791 var first/eax: (addr cell) <- lookup *first-ah
793 var first-type/eax: (addr int) <- get first, type
794 compare *first-type, 1/number
796 error trace, "first arg for * is not a number"
799 var first-value/ecx: (addr float) <- get first, number-data
800 # args->right->left->value
801 var right-ah/eax: (addr handle cell) <- get args, right
802 var right/eax: (addr cell) <- lookup *right-ah
804 var right-type/eax: (addr int) <- get right, type
805 compare *right-type, 0/pair
807 error trace, "* encountered non-pair"
811 var nil?/eax: boolean <- nil? right
812 compare nil?, 0/false
814 error trace, "* needs 2 args but got 1"
817 var second-ah/eax: (addr handle cell) <- get right, left
818 var second/eax: (addr cell) <- lookup *second-ah
820 var second-type/eax: (addr int) <- get second, type
821 compare *second-type, 1/number
823 error trace, "second arg for * is not a number"
826 var second-value/edx: (addr float) <- get second, number-data
828 var result/xmm0: float <- copy *first-value
829 result <- multiply *second-value
830 new-float out, result
833 fn apply-divide _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
834 trace-text trace, "eval", "apply /"
835 var args-ah/eax: (addr handle cell) <- copy _args-ah
836 var _args/eax: (addr cell) <- lookup *args-ah
837 var args/esi: (addr cell) <- copy _args
839 var args-type/eax: (addr int) <- get args, type
840 compare *args-type, 0/pair
842 error trace, "args to / are not a list"
845 var empty-args?/eax: boolean <- nil? args
846 compare empty-args?, 0/false
849 error trace, "/ needs 2 args but got 0"
853 var first-ah/eax: (addr handle cell) <- get args, left
854 var first/eax: (addr cell) <- lookup *first-ah
856 var first-type/eax: (addr int) <- get first, type
857 compare *first-type, 1/number
859 error trace, "first arg for / is not a number"
862 var first-value/ecx: (addr float) <- get first, number-data
863 # args->right->left->value
864 var right-ah/eax: (addr handle cell) <- get args, right
865 var right/eax: (addr cell) <- lookup *right-ah
867 var right-type/eax: (addr int) <- get right, type
868 compare *right-type, 0/pair
870 error trace, "/ encountered non-pair"
874 var nil?/eax: boolean <- nil? right
875 compare nil?, 0/false
877 error trace, "/ needs 2 args but got 1"
880 var second-ah/eax: (addr handle cell) <- get right, left
881 var second/eax: (addr cell) <- lookup *second-ah
883 var second-type/eax: (addr int) <- get second, type
884 compare *second-type, 1/number
886 error trace, "second arg for / is not a number"
889 var second-value/edx: (addr float) <- get second, number-data
891 var result/xmm0: float <- copy *first-value
892 result <- divide *second-value
893 new-float out, result
896 fn apply-remainder _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
897 trace-text trace, "eval", "apply %"
898 var args-ah/eax: (addr handle cell) <- copy _args-ah
899 var _args/eax: (addr cell) <- lookup *args-ah
900 var args/esi: (addr cell) <- copy _args
902 var args-type/eax: (addr int) <- get args, type
903 compare *args-type, 0/pair
905 error trace, "args to % are not a list"
908 var empty-args?/eax: boolean <- nil? args
909 compare empty-args?, 0/false
912 error trace, "% needs 2 args but got 0"
916 var first-ah/eax: (addr handle cell) <- get args, left
917 var first/eax: (addr cell) <- lookup *first-ah
919 var first-type/eax: (addr int) <- get first, type
920 compare *first-type, 1/number
922 error trace, "first arg for % is not a number"
925 var first-value/ecx: (addr float) <- get first, number-data
926 # args->right->left->value
927 var right-ah/eax: (addr handle cell) <- get args, right
928 var right/eax: (addr cell) <- lookup *right-ah
930 var right-type/eax: (addr int) <- get right, type
931 compare *right-type, 0/pair
933 error trace, "% encountered non-pair"
937 var nil?/eax: boolean <- nil? right
938 compare nil?, 0/false
940 error trace, "% needs 2 args but got 1"
943 var second-ah/eax: (addr handle cell) <- get right, left
944 var second/eax: (addr cell) <- lookup *second-ah
946 var second-type/eax: (addr int) <- get second, type
947 compare *second-type, 1/number
949 error trace, "second arg for % is not a number"
952 var second-value/edx: (addr float) <- get second, number-data
954 var quotient/xmm0: float <- copy *first-value
955 quotient <- divide *second-value
956 var quotient-int/eax: int <- truncate quotient
957 quotient <- convert quotient-int
958 var sub-result/xmm1: float <- copy quotient
959 sub-result <- multiply *second-value
960 var result/xmm0: float <- copy *first-value
961 result <- subtract sub-result
962 new-float out, result
965 fn apply-square-root _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
966 trace-text trace, "eval", "apply sqrt"
967 var args-ah/eax: (addr handle cell) <- copy _args-ah
968 var _args/eax: (addr cell) <- lookup *args-ah
969 var args/esi: (addr cell) <- copy _args
971 var args-type/eax: (addr int) <- get args, type
972 compare *args-type, 0/pair
974 error trace, "args to sqrt are not a list"
977 var empty-args?/eax: boolean <- nil? args
978 compare empty-args?, 0/false
981 error trace, "sqrt needs 1 arg but got 0"
985 var first-ah/eax: (addr handle cell) <- get args, left
986 var first/eax: (addr cell) <- lookup *first-ah
988 var first-type/eax: (addr int) <- get first, type
989 compare *first-type, 1/number
991 error trace, "arg for sqrt is not a number"
994 var first-value/eax: (addr float) <- get first, number-data
996 var result/xmm0: float <- square-root *first-value
997 new-float out, result
1000 fn apply-abs _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1001 trace-text trace, "eval", "apply abs"
1002 var args-ah/eax: (addr handle cell) <- copy _args-ah
1003 var _args/eax: (addr cell) <- lookup *args-ah
1004 var args/esi: (addr cell) <- copy _args
1006 var args-type/eax: (addr int) <- get args, type
1007 compare *args-type, 0/pair
1009 error trace, "args to abs are not a list"
1012 var empty-args?/eax: boolean <- nil? args
1013 compare empty-args?, 0/false
1016 error trace, "abs needs 1 arg but got 0"
1020 var first-ah/eax: (addr handle cell) <- get args, left
1021 var first/eax: (addr cell) <- lookup *first-ah
1023 var first-type/eax: (addr int) <- get first, type
1024 compare *first-type, 1/number
1026 error trace, "arg for abs is not a number"
1029 var first-value/ecx: (addr float) <- get first, number-data
1031 var result/xmm0: float <- copy *first-value
1033 compare result, zero
1036 var neg1/eax: int <- copy -1
1037 var neg1-f/xmm1: float <- convert neg1
1038 result <- multiply neg1-f
1040 new-float out, result
1043 fn apply-sgn _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1044 trace-text trace, "eval", "apply sgn"
1045 var args-ah/eax: (addr handle cell) <- copy _args-ah
1046 var _args/eax: (addr cell) <- lookup *args-ah
1047 var args/esi: (addr cell) <- copy _args
1049 var args-type/eax: (addr int) <- get args, type
1050 compare *args-type, 0/pair
1052 error trace, "args to sgn are not a list"
1055 var empty-args?/eax: boolean <- nil? args
1056 compare empty-args?, 0/false
1059 error trace, "sgn needs 1 arg but got 0"
1063 var first-ah/eax: (addr handle cell) <- get args, left
1064 var first/eax: (addr cell) <- lookup *first-ah
1066 var first-type/eax: (addr int) <- get first, type
1067 compare *first-type, 1/number
1069 error trace, "arg for sgn is not a number"
1072 var first-value/ecx: (addr float) <- get first, number-data
1074 var result/xmm0: float <- copy *first-value
1077 compare result, zero
1081 var neg1/eax: int <- copy -1
1082 result <- convert neg1
1083 break $apply-sgn:core
1087 var one/eax: int <- copy 1
1088 result <- convert one
1089 break $apply-sgn:core
1092 new-float out, result
1095 fn apply-car _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1096 trace-text trace, "eval", "apply car"
1097 var args-ah/eax: (addr handle cell) <- copy _args-ah
1098 var _args/eax: (addr cell) <- lookup *args-ah
1099 var args/esi: (addr cell) <- copy _args
1101 var args-type/eax: (addr int) <- get args, type
1102 compare *args-type, 0/pair
1104 error trace, "args to car are not a list"
1107 var empty-args?/eax: boolean <- nil? args
1108 compare empty-args?, 0/false
1111 error trace, "car needs 1 arg but got 0"
1115 var first-ah/edx: (addr handle cell) <- get args, left
1116 var first/eax: (addr cell) <- lookup *first-ah
1118 var first-type/eax: (addr int) <- get first, type
1119 compare *first-type, 0/pair
1121 error trace, "arg for car is not a pair"
1126 var nil?/eax: boolean <- nil? first
1127 compare nil?, 0/false
1129 copy-object first-ah, out
1133 var result/eax: (addr handle cell) <- get first, left
1134 copy-object result, out
1137 fn apply-cdr _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1138 trace-text trace, "eval", "apply cdr"
1139 var args-ah/eax: (addr handle cell) <- copy _args-ah
1140 var _args/eax: (addr cell) <- lookup *args-ah
1141 var args/esi: (addr cell) <- copy _args
1143 var args-type/eax: (addr int) <- get args, type
1144 compare *args-type, 0/pair
1146 error trace, "args to cdr are not a list"
1149 var empty-args?/eax: boolean <- nil? args
1150 compare empty-args?, 0/false
1153 error trace, "cdr needs 1 arg but got 0"
1157 var first-ah/edx: (addr handle cell) <- get args, left
1158 var first/eax: (addr cell) <- lookup *first-ah
1160 var first-type/eax: (addr int) <- get first, type
1161 compare *first-type, 0/pair
1163 error trace, "arg for cdr is not a pair"
1168 var nil?/eax: boolean <- nil? first
1169 compare nil?, 0/false
1171 copy-object first-ah, out
1175 var result/eax: (addr handle cell) <- get first, right
1176 copy-object result, out
1179 fn apply-cons _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1180 trace-text trace, "eval", "apply cons"
1181 var args-ah/eax: (addr handle cell) <- copy _args-ah
1182 var _args/eax: (addr cell) <- lookup *args-ah
1183 var args/esi: (addr cell) <- copy _args
1185 var args-type/eax: (addr int) <- get args, type
1186 compare *args-type, 0/pair
1188 error trace, "args to 'cons' are not a list"
1191 var empty-args?/eax: boolean <- nil? args
1192 compare empty-args?, 0/false
1195 error trace, "cons needs 2 args but got 0"
1199 var first-ah/ecx: (addr handle cell) <- get args, left
1201 var right-ah/eax: (addr handle cell) <- get args, right
1202 var right/eax: (addr cell) <- lookup *right-ah
1204 var right-type/eax: (addr int) <- get right, type
1205 compare *right-type, 0/pair
1207 error trace, "'cons' encountered non-pair"
1211 var nil?/eax: boolean <- nil? right
1212 compare nil?, 0/false
1214 error trace, "'cons' needs 2 args but got 1"
1217 var second-ah/eax: (addr handle cell) <- get right, left
1219 new-pair out, *first-ah, *second-ah
1222 fn apply-cons-check _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1223 trace-text trace, "eval", "apply cons?"
1224 var args-ah/eax: (addr handle cell) <- copy _args-ah
1225 var _args/eax: (addr cell) <- lookup *args-ah
1226 var args/esi: (addr cell) <- copy _args
1228 var args-type/eax: (addr int) <- get args, type
1229 compare *args-type, 0/pair
1231 error trace, "args to cons? are not a list"
1234 var empty-args?/eax: boolean <- nil? args
1235 compare empty-args?, 0/false
1238 error trace, "cons? needs 1 arg but got 0"
1242 var first-ah/edx: (addr handle cell) <- get args, left
1243 var first/eax: (addr cell) <- lookup *first-ah
1245 var first-type/eax: (addr int) <- get first, type
1246 compare *first-type, 0/pair
1254 fn apply-len _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1255 trace-text trace, "eval", "apply len"
1256 var args-ah/eax: (addr handle cell) <- copy _args-ah
1257 var _args/eax: (addr cell) <- lookup *args-ah
1258 var args/esi: (addr cell) <- copy _args
1260 var args-type/eax: (addr int) <- get args, type
1261 compare *args-type, 0/pair
1263 error trace, "args to len are not a list"
1266 var empty-args?/eax: boolean <- nil? args
1267 compare empty-args?, 0/false
1270 error trace, "len needs 1 arg but got 0"
1274 var first-ah/edx: (addr handle cell) <- get args, left
1275 var first/eax: (addr cell) <- lookup *first-ah
1278 var first-pair?/eax: boolean <- pair? first
1279 compare first-pair?, 0/false
1282 var result/eax: int <- list-length first
1283 new-integer out, result
1288 var first-array?/eax: boolean <- array? first
1289 compare first-array?, 0/false
1292 var result/eax: int <- array-length first
1293 new-integer out, result
1299 fn list-length in: (addr cell) -> _/eax: int {
1300 var curr/ecx: (addr cell) <- copy in
1301 var result/edi: int <- copy 0
1303 var pair?/eax: boolean <- pair? curr
1305 compare pair?, 0/false
1307 abort "len: ran into a non-cons"
1309 var nil?/eax: boolean <- nil? curr
1310 compare nil?, 0/false
1313 var next-ah/eax: (addr handle cell) <- get curr, right
1314 var next/eax: (addr cell) <- lookup *next-ah
1321 fn array-length _in: (addr cell) -> _/eax: int {
1322 var in/esi: (addr cell) <- copy _in
1323 var in-data-ah/eax: (addr handle array handle cell) <- get in, array-data
1324 var in-data/eax: (addr array handle cell) <- lookup *in-data-ah
1325 var result/eax: int <- length in-data
1329 fn apply-cell-isomorphic _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1330 trace-text trace, "eval", "apply '='"
1331 var args-ah/eax: (addr handle cell) <- copy _args-ah
1332 var _args/eax: (addr cell) <- lookup *args-ah
1333 var args/esi: (addr cell) <- copy _args
1335 var args-type/eax: (addr int) <- get args, type
1336 compare *args-type, 0/pair
1338 error trace, "args to '=' are not a list"
1341 var empty-args?/eax: boolean <- nil? args
1342 compare empty-args?, 0/false
1345 error trace, "'=' needs 2 args but got 0"
1349 var first-ah/ecx: (addr handle cell) <- get args, left
1351 var right-ah/eax: (addr handle cell) <- get args, right
1352 var right/eax: (addr cell) <- lookup *right-ah
1354 var right-type/eax: (addr int) <- get right, type
1355 compare *right-type, 0/pair
1357 error trace, "'=' encountered non-pair"
1361 var nil?/eax: boolean <- nil? right
1362 compare nil?, 0/false
1364 error trace, "'=' needs 2 args but got 1"
1367 var second-ah/edx: (addr handle cell) <- get right, left
1369 var _first/eax: (addr cell) <- lookup *first-ah
1370 var first/ecx: (addr cell) <- copy _first
1371 var second/eax: (addr cell) <- lookup *second-ah
1372 var match?/eax: boolean <- cell-isomorphic? first, second, trace
1373 compare match?, 0/false
1379 new-integer out, 1/true
1382 fn apply-not _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1383 trace-text trace, "eval", "apply 'not'"
1384 var args-ah/eax: (addr handle cell) <- copy _args-ah
1385 var _args/eax: (addr cell) <- lookup *args-ah
1386 var args/esi: (addr cell) <- copy _args
1388 var args-type/eax: (addr int) <- get args, type
1389 compare *args-type, 0/pair
1391 error trace, "args to 'not' are not a list"
1394 var empty-args?/eax: boolean <- nil? args
1395 compare empty-args?, 0/false
1398 error trace, "'not' needs 1 arg but got 0"
1402 var first-ah/eax: (addr handle cell) <- get args, left
1403 var first/eax: (addr cell) <- lookup *first-ah
1405 var nil?/eax: boolean <- nil? first
1406 compare nil?, 0/false
1415 fn apply-debug _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1416 trace-text trace, "eval", "apply 'debug'"
1417 var args-ah/eax: (addr handle cell) <- copy _args-ah
1418 var _args/eax: (addr cell) <- lookup *args-ah
1419 var args/esi: (addr cell) <- copy _args
1421 var args-type/eax: (addr int) <- get args, type
1422 compare *args-type, 0/pair
1424 error trace, "args to 'debug' are not a list"
1427 var empty-args?/eax: boolean <- nil? args
1428 compare empty-args?, 0/false
1431 error trace, "'debug' needs 1 arg but got 0"
1434 # dump args->left uglily to screen and wait for a keypress
1435 var first-ah/eax: (addr handle cell) <- get args, left
1436 dump-cell-from-cursor-over-full-screen first-ah, 7/fg 0/bg
1438 var foo/eax: byte <- read-key 0/keyboard
1445 fn apply-< _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1446 trace-text trace, "eval", "apply '<'"
1447 var args-ah/eax: (addr handle cell) <- copy _args-ah
1448 var _args/eax: (addr cell) <- lookup *args-ah
1449 var args/esi: (addr cell) <- copy _args
1451 var args-type/eax: (addr int) <- get args, type
1452 compare *args-type, 0/pair
1454 error trace, "args to '<' are not a list"
1457 var empty-args?/eax: boolean <- nil? args
1458 compare empty-args?, 0/false
1461 error trace, "'<' needs 2 args but got 0"
1465 var first-ah/ecx: (addr handle cell) <- get args, left
1467 var right-ah/eax: (addr handle cell) <- get args, right
1468 var right/eax: (addr cell) <- lookup *right-ah
1470 var right-type/eax: (addr int) <- get right, type
1471 compare *right-type, 0/pair
1473 error trace, "'<' encountered non-pair"
1477 var nil?/eax: boolean <- nil? right
1478 compare nil?, 0/false
1480 error trace, "'<' needs 2 args but got 1"
1483 var second-ah/edx: (addr handle cell) <- get right, left
1485 var _first/eax: (addr cell) <- lookup *first-ah
1486 var first/ecx: (addr cell) <- copy _first
1488 var first-type/eax: (addr int) <- get first, type
1489 compare *first-type, 1/number
1491 error trace, "first arg for '<' is not a number"
1494 var first-value/ecx: (addr float) <- get first, number-data
1495 var first-float/xmm0: float <- copy *first-value
1496 var second/eax: (addr cell) <- lookup *second-ah
1498 var second-type/eax: (addr int) <- get second, type
1499 compare *second-type, 1/number
1501 error trace, "second arg for '<' is not a number"
1504 var second-value/eax: (addr float) <- get second, number-data
1505 compare first-float, *second-value
1511 new-integer out, 1/true
1514 fn apply-> _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1515 trace-text trace, "eval", "apply '>'"
1516 var args-ah/eax: (addr handle cell) <- copy _args-ah
1517 var _args/eax: (addr cell) <- lookup *args-ah
1518 var args/esi: (addr cell) <- copy _args
1520 var args-type/eax: (addr int) <- get args, type
1521 compare *args-type, 0/pair
1523 error trace, "args to '>' are not a list"
1526 var empty-args?/eax: boolean <- nil? args
1527 compare empty-args?, 0/false
1530 error trace, "'>' needs 2 args but got 0"
1534 var first-ah/ecx: (addr handle cell) <- get args, left
1536 var right-ah/eax: (addr handle cell) <- get args, right
1537 var right/eax: (addr cell) <- lookup *right-ah
1539 var right-type/eax: (addr int) <- get right, type
1540 compare *right-type, 0/pair
1542 error trace, "'>' encountered non-pair"
1546 var nil?/eax: boolean <- nil? right
1547 compare nil?, 0/false
1549 error trace, "'>' needs 2 args but got 1"
1552 var second-ah/edx: (addr handle cell) <- get right, left
1554 var _first/eax: (addr cell) <- lookup *first-ah
1555 var first/ecx: (addr cell) <- copy _first
1557 var first-type/eax: (addr int) <- get first, type
1558 compare *first-type, 1/number
1560 error trace, "first arg for '>' is not a number"
1563 var first-value/ecx: (addr float) <- get first, number-data
1564 var first-float/xmm0: float <- copy *first-value
1565 var second/eax: (addr cell) <- lookup *second-ah
1567 var second-type/eax: (addr int) <- get second, type
1568 compare *second-type, 1/number
1570 error trace, "second arg for '>' is not a number"
1573 var second-value/eax: (addr float) <- get second, number-data
1574 compare first-float, *second-value
1580 new-integer out, 1/true
1583 fn apply-<= _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1584 trace-text trace, "eval", "apply '<='"
1585 var args-ah/eax: (addr handle cell) <- copy _args-ah
1586 var _args/eax: (addr cell) <- lookup *args-ah
1587 var args/esi: (addr cell) <- copy _args
1589 var args-type/eax: (addr int) <- get args, type
1590 compare *args-type, 0/pair
1592 error trace, "args to '<=' are not a list"
1595 var empty-args?/eax: boolean <- nil? args
1596 compare empty-args?, 0/false
1599 error trace, "'<=' needs 2 args but got 0"
1603 var first-ah/ecx: (addr handle cell) <- get args, left
1605 var right-ah/eax: (addr handle cell) <- get args, right
1606 var right/eax: (addr cell) <- lookup *right-ah
1608 var right-type/eax: (addr int) <- get right, type
1609 compare *right-type, 0/pair
1611 error trace, "'<=' encountered non-pair"
1615 var nil?/eax: boolean <- nil? right
1616 compare nil?, 0/false
1618 error trace, "'<=' needs 2 args but got 1"
1621 var second-ah/edx: (addr handle cell) <- get right, left
1623 var _first/eax: (addr cell) <- lookup *first-ah
1624 var first/ecx: (addr cell) <- copy _first
1626 var first-type/eax: (addr int) <- get first, type
1627 compare *first-type, 1/number
1629 error trace, "first arg for '<=' is not a number"
1632 var first-value/ecx: (addr float) <- get first, number-data
1633 var first-float/xmm0: float <- copy *first-value
1634 var second/eax: (addr cell) <- lookup *second-ah
1636 var second-type/eax: (addr int) <- get second, type
1637 compare *second-type, 1/number
1639 error trace, "second arg for '<=' is not a number"
1642 var second-value/eax: (addr float) <- get second, number-data
1643 compare first-float, *second-value
1649 new-integer out, 1/true
1652 fn apply->= _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1653 trace-text trace, "eval", "apply '>='"
1654 var args-ah/eax: (addr handle cell) <- copy _args-ah
1655 var _args/eax: (addr cell) <- lookup *args-ah
1656 var args/esi: (addr cell) <- copy _args
1658 var args-type/eax: (addr int) <- get args, type
1659 compare *args-type, 0/pair
1661 error trace, "args to '>=' are not a list"
1664 var empty-args?/eax: boolean <- nil? args
1665 compare empty-args?, 0/false
1668 error trace, "'>=' needs 2 args but got 0"
1672 var first-ah/ecx: (addr handle cell) <- get args, left
1674 var right-ah/eax: (addr handle cell) <- get args, right
1675 var right/eax: (addr cell) <- lookup *right-ah
1677 var right-type/eax: (addr int) <- get right, type
1678 compare *right-type, 0/pair
1680 error trace, "'>=' encountered non-pair"
1684 var nil?/eax: boolean <- nil? right
1685 compare nil?, 0/false
1687 error trace, "'>=' needs 2 args but got 1"
1690 var second-ah/edx: (addr handle cell) <- get right, left
1692 var _first/eax: (addr cell) <- lookup *first-ah
1693 var first/ecx: (addr cell) <- copy _first
1695 var first-type/eax: (addr int) <- get first, type
1696 compare *first-type, 1/number
1698 error trace, "first arg for '>=' is not a number"
1701 var first-value/ecx: (addr float) <- get first, number-data
1702 var first-float/xmm0: float <- copy *first-value
1703 var second/eax: (addr cell) <- lookup *second-ah
1705 var second-type/eax: (addr int) <- get second, type
1706 compare *second-type, 1/number
1708 error trace, "second arg for '>=' is not a number"
1711 var second-value/eax: (addr float) <- get second, number-data
1712 compare first-float, *second-value
1718 new-integer out, 1/true
1721 fn apply-print _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1722 trace-text trace, "eval", "apply 'print'"
1723 var args-ah/eax: (addr handle cell) <- copy _args-ah
1724 var _args/eax: (addr cell) <- lookup *args-ah
1725 var args/esi: (addr cell) <- copy _args
1727 var args-type/eax: (addr int) <- get args, type
1728 compare *args-type, 0/pair
1730 error trace, "args to 'print' are not a list"
1733 var empty-args?/eax: boolean <- nil? args
1734 compare empty-args?, 0/false
1737 error trace, "'print' needs 2 args but got 0"
1740 # screen = args->left
1741 var first-ah/eax: (addr handle cell) <- get args, left
1742 var first/eax: (addr cell) <- lookup *first-ah
1744 var first-type/eax: (addr int) <- get first, type
1745 compare *first-type, 5/screen
1747 error trace, "first arg for 'print' is not a screen"
1750 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1751 var _screen/eax: (addr screen) <- lookup *screen-ah
1752 var screen/ecx: (addr screen) <- copy _screen
1754 var right-ah/eax: (addr handle cell) <- get args, right
1755 var right/eax: (addr cell) <- lookup *right-ah
1757 var right-type/eax: (addr int) <- get right, type
1758 compare *right-type, 0/pair
1760 error trace, "'print' encountered non-pair"
1764 var nil?/eax: boolean <- nil? right
1765 compare nil?, 0/false
1767 error trace, "'print' needs 2 args but got 1"
1770 var second-ah/eax: (addr handle cell) <- get right, left
1771 var stream-storage: (stream byte 0x100)
1772 var stream/edi: (addr stream byte) <- address stream-storage
1773 print-cell second-ah, stream, trace
1774 draw-stream-wrapping-right-then-down-from-cursor-over-full-screen screen, stream, 7/fg, 0/bg
1775 # return what was printed
1776 copy-object second-ah, out
1779 fn apply-clear _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1780 trace-text trace, "eval", "apply 'clear'"
1781 var args-ah/eax: (addr handle cell) <- copy _args-ah
1782 var _args/eax: (addr cell) <- lookup *args-ah
1783 var args/esi: (addr cell) <- copy _args
1785 var args-type/eax: (addr int) <- get args, type
1786 compare *args-type, 0/pair
1788 error trace, "args to 'clear' are not a list"
1791 var empty-args?/eax: boolean <- nil? args
1792 compare empty-args?, 0/false
1795 error trace, "'clear' needs 1 arg but got 0"
1798 # screen = args->left
1799 var first-ah/eax: (addr handle cell) <- get args, left
1800 var first/eax: (addr cell) <- lookup *first-ah
1801 var first-type/ecx: (addr int) <- get first, type
1802 compare *first-type, 3/stream
1805 var stream-data-ah/eax: (addr handle stream byte) <- get first, text-data
1806 var _stream-data/eax: (addr stream byte) <- lookup *stream-data-ah
1807 var stream-data/ebx: (addr stream byte) <- copy _stream-data
1808 clear-stream stream-data
1811 compare *first-type, 5/screen
1814 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1815 var _screen/eax: (addr screen) <- lookup *screen-ah
1816 var screen/ecx: (addr screen) <- copy _screen
1820 error trace, "first arg for 'clear' is not a screen or a stream"
1823 fn apply-up _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1824 trace-text trace, "eval", "apply 'up'"
1825 var args-ah/eax: (addr handle cell) <- copy _args-ah
1826 var _args/eax: (addr cell) <- lookup *args-ah
1827 var args/esi: (addr cell) <- copy _args
1829 var args-type/eax: (addr int) <- get args, type
1830 compare *args-type, 0/pair
1832 error trace, "args to 'up' are not a list"
1835 var empty-args?/eax: boolean <- nil? args
1836 compare empty-args?, 0/false
1839 error trace, "'up' needs 1 arg but got 0"
1842 # screen = args->left
1843 var first-ah/eax: (addr handle cell) <- get args, left
1844 var first/eax: (addr cell) <- lookup *first-ah
1846 var first-type/eax: (addr int) <- get first, type
1847 compare *first-type, 5/screen
1849 error trace, "first arg for 'up' is not a screen"
1852 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1853 var _screen/eax: (addr screen) <- lookup *screen-ah
1854 var screen/ecx: (addr screen) <- copy _screen
1856 move-cursor-up screen
1859 fn apply-down _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1860 trace-text trace, "eval", "apply 'down'"
1861 var args-ah/eax: (addr handle cell) <- copy _args-ah
1862 var _args/eax: (addr cell) <- lookup *args-ah
1863 var args/esi: (addr cell) <- copy _args
1865 var args-type/eax: (addr int) <- get args, type
1866 compare *args-type, 0/pair
1868 error trace, "args to 'down' are not a list"
1871 var empty-args?/eax: boolean <- nil? args
1872 compare empty-args?, 0/false
1875 error trace, "'down' needs 1 arg but got 0"
1878 # screen = args->left
1879 var first-ah/eax: (addr handle cell) <- get args, left
1880 var first/eax: (addr cell) <- lookup *first-ah
1882 var first-type/eax: (addr int) <- get first, type
1883 compare *first-type, 5/screen
1885 error trace, "first arg for 'down' is not a screen"
1888 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1889 var _screen/eax: (addr screen) <- lookup *screen-ah
1890 var screen/ecx: (addr screen) <- copy _screen
1892 move-cursor-down screen
1895 fn apply-left _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1896 trace-text trace, "eval", "apply 'left'"
1897 var args-ah/eax: (addr handle cell) <- copy _args-ah
1898 var _args/eax: (addr cell) <- lookup *args-ah
1899 var args/esi: (addr cell) <- copy _args
1901 var args-type/eax: (addr int) <- get args, type
1902 compare *args-type, 0/pair
1904 error trace, "args to 'left' are not a list"
1907 var empty-args?/eax: boolean <- nil? args
1908 compare empty-args?, 0/false
1911 error trace, "'left' needs 1 arg but got 0"
1914 # screen = args->left
1915 var first-ah/eax: (addr handle cell) <- get args, left
1916 var first/eax: (addr cell) <- lookup *first-ah
1918 var first-type/eax: (addr int) <- get first, type
1919 compare *first-type, 5/screen
1921 error trace, "first arg for 'left' is not a screen"
1924 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1925 var _screen/eax: (addr screen) <- lookup *screen-ah
1926 var screen/ecx: (addr screen) <- copy _screen
1928 move-cursor-left screen
1931 fn apply-right _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1932 trace-text trace, "eval", "apply 'right'"
1933 var args-ah/eax: (addr handle cell) <- copy _args-ah
1934 var _args/eax: (addr cell) <- lookup *args-ah
1935 var args/esi: (addr cell) <- copy _args
1937 var args-type/eax: (addr int) <- get args, type
1938 compare *args-type, 0/pair
1940 error trace, "args to 'right' are not a list"
1943 var empty-args?/eax: boolean <- nil? args
1944 compare empty-args?, 0/false
1947 error trace, "'right' needs 1 arg but got 0"
1950 # screen = args->left
1951 var first-ah/eax: (addr handle cell) <- get args, left
1952 var first/eax: (addr cell) <- lookup *first-ah
1954 var first-type/eax: (addr int) <- get first, type
1955 compare *first-type, 5/screen
1957 error trace, "first arg for 'right' is not a screen"
1960 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1961 var _screen/eax: (addr screen) <- lookup *screen-ah
1962 var screen/ecx: (addr screen) <- copy _screen
1964 move-cursor-right screen
1967 fn apply-cr _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
1968 trace-text trace, "eval", "apply 'cr'"
1969 var args-ah/eax: (addr handle cell) <- copy _args-ah
1970 var _args/eax: (addr cell) <- lookup *args-ah
1971 var args/esi: (addr cell) <- copy _args
1973 var args-type/eax: (addr int) <- get args, type
1974 compare *args-type, 0/pair
1976 error trace, "args to 'cr' are not a list"
1979 var empty-args?/eax: boolean <- nil? args
1980 compare empty-args?, 0/false
1983 error trace, "'cr' needs 1 arg but got 0"
1986 # screen = args->left
1987 var first-ah/eax: (addr handle cell) <- get args, left
1988 var first/eax: (addr cell) <- lookup *first-ah
1990 var first-type/eax: (addr int) <- get first, type
1991 compare *first-type, 5/screen
1993 error trace, "first arg for 'cr' is not a screen"
1996 var screen-ah/eax: (addr handle screen) <- get first, screen-data
1997 var _screen/eax: (addr screen) <- lookup *screen-ah
1998 var screen/ecx: (addr screen) <- copy _screen
2000 move-cursor-to-left-margin-of-next-line screen
2003 fn apply-pixel _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2004 trace-text trace, "eval", "apply 'pixel'"
2005 var args-ah/eax: (addr handle cell) <- copy _args-ah
2006 var _args/eax: (addr cell) <- lookup *args-ah
2007 var args/esi: (addr cell) <- copy _args
2009 var args-type/eax: (addr int) <- get args, type
2010 compare *args-type, 0/pair
2012 error trace, "args to 'pixel' are not a list"
2015 var empty-args?/eax: boolean <- nil? args
2016 compare empty-args?, 0/false
2019 error trace, "'pixel' needs 4 args but got 0"
2022 # screen = args->left
2023 var first-ah/eax: (addr handle cell) <- get args, left
2024 var first/eax: (addr cell) <- lookup *first-ah
2026 var first-type/eax: (addr int) <- get first, type
2027 compare *first-type, 5/screen
2029 error trace, "first arg for 'pixel' is not a screen"
2032 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2033 var _screen/eax: (addr screen) <- lookup *screen-ah
2034 var screen/edi: (addr screen) <- copy _screen
2035 # x = args->right->left->value
2036 var rest-ah/eax: (addr handle cell) <- get args, right
2037 var _rest/eax: (addr cell) <- lookup *rest-ah
2038 var rest/esi: (addr cell) <- copy _rest
2040 var rest-type/eax: (addr int) <- get rest, type
2041 compare *rest-type, 0/pair
2043 error trace, "'pixel' encountered non-pair"
2047 var rest-nil?/eax: boolean <- nil? rest
2048 compare rest-nil?, 0/false
2050 error trace, "'pixel' needs 4 args but got 1"
2053 var second-ah/eax: (addr handle cell) <- get rest, left
2054 var second/eax: (addr cell) <- lookup *second-ah
2056 var second-type/eax: (addr int) <- get second, type
2057 compare *second-type, 1/number
2059 error trace, "second arg for 'pixel' is not an int (x coordinate)"
2062 var second-value/eax: (addr float) <- get second, number-data
2063 var x/edx: int <- convert *second-value
2064 # y = rest->right->left->value
2065 var rest-ah/eax: (addr handle cell) <- get rest, right
2066 var _rest/eax: (addr cell) <- lookup *rest-ah
2069 var rest-type/eax: (addr int) <- get rest, type
2070 compare *rest-type, 0/pair
2072 error trace, "'pixel' encountered non-pair"
2076 var rest-nil?/eax: boolean <- nil? rest
2077 compare rest-nil?, 0/false
2079 error trace, "'pixel' needs 4 args but got 2"
2082 var third-ah/eax: (addr handle cell) <- get rest, left
2083 var third/eax: (addr cell) <- lookup *third-ah
2085 var third-type/eax: (addr int) <- get third, type
2086 compare *third-type, 1/number
2088 error trace, "third arg for 'pixel' is not an int (y coordinate)"
2091 var third-value/eax: (addr float) <- get third, number-data
2092 var y/ebx: int <- convert *third-value
2093 # color = rest->right->left->value
2094 var rest-ah/eax: (addr handle cell) <- get rest, right
2095 var _rest/eax: (addr cell) <- lookup *rest-ah
2098 var rest-type/eax: (addr int) <- get rest, type
2099 compare *rest-type, 0/pair
2101 error trace, "'pixel' encountered non-pair"
2105 var rest-nil?/eax: boolean <- nil? rest
2106 compare rest-nil?, 0/false
2108 error trace, "'pixel' needs 4 args but got 3"
2111 var fourth-ah/eax: (addr handle cell) <- get rest, left
2112 var fourth/eax: (addr cell) <- lookup *fourth-ah
2114 var fourth-type/eax: (addr int) <- get fourth, type
2115 compare *fourth-type, 1/number
2117 error trace, "fourth arg for 'pixel' is not an int (color; 0..0xff)"
2120 var fourth-value/eax: (addr float) <- get fourth, number-data
2121 var color/eax: int <- convert *fourth-value
2122 pixel screen, x, y, color
2126 fn apply-line _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2127 trace-text trace, "eval", "apply 'line'"
2128 var args-ah/eax: (addr handle cell) <- copy _args-ah
2129 var _args/eax: (addr cell) <- lookup *args-ah
2130 var args/esi: (addr cell) <- copy _args
2132 var args-type/eax: (addr int) <- get args, type
2133 compare *args-type, 0/pair
2135 error trace, "args to 'line' are not a list"
2138 var empty-args?/eax: boolean <- nil? args
2139 compare empty-args?, 0/false
2142 error trace, "'line' needs 6 args but got 0"
2145 # screen = args->left
2146 var first-ah/eax: (addr handle cell) <- get args, left
2147 var first/eax: (addr cell) <- lookup *first-ah
2149 var first-type/eax: (addr int) <- get first, type
2150 compare *first-type, 5/screen
2152 error trace, "first arg for 'line' is not a screen"
2155 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2156 var _screen/eax: (addr screen) <- lookup *screen-ah
2157 var screen/edi: (addr screen) <- copy _screen
2158 # x1 = args->right->left->value
2159 var rest-ah/eax: (addr handle cell) <- get args, right
2160 var _rest/eax: (addr cell) <- lookup *rest-ah
2161 var rest/esi: (addr cell) <- copy _rest
2163 var rest-type/eax: (addr int) <- get rest, type
2164 compare *rest-type, 0/pair
2166 error trace, "'line' encountered non-pair"
2170 var rest-nil?/eax: boolean <- nil? rest
2171 compare rest-nil?, 0/false
2173 error trace, "'line' needs 6 args but got 1"
2176 var second-ah/eax: (addr handle cell) <- get rest, left
2177 var second/eax: (addr cell) <- lookup *second-ah
2179 var second-type/eax: (addr int) <- get second, type
2180 compare *second-type, 1/number
2182 error trace, "second arg for 'line' is not a number (screen x coordinate of start point)"
2185 var second-value/eax: (addr float) <- get second, number-data
2186 var x1/edx: int <- convert *second-value
2187 # y1 = rest->right->left->value
2188 var rest-ah/eax: (addr handle cell) <- get rest, right
2189 var _rest/eax: (addr cell) <- lookup *rest-ah
2192 var rest-type/eax: (addr int) <- get rest, type
2193 compare *rest-type, 0/pair
2195 error trace, "'line' encountered non-pair"
2199 var rest-nil?/eax: boolean <- nil? rest
2200 compare rest-nil?, 0/false
2202 error trace, "'line' needs 6 args but got 2"
2205 var third-ah/eax: (addr handle cell) <- get rest, left
2206 var third/eax: (addr cell) <- lookup *third-ah
2208 var third-type/eax: (addr int) <- get third, type
2209 compare *third-type, 1/number
2211 error trace, "third arg for 'line' is not a number (screen y coordinate of start point)"
2214 var third-value/eax: (addr float) <- get third, number-data
2215 var y1/ebx: int <- convert *third-value
2216 # x2 = rest->right->left->value
2217 var rest-ah/eax: (addr handle cell) <- get rest, right
2218 var _rest/eax: (addr cell) <- lookup *rest-ah
2219 var rest/esi: (addr cell) <- copy _rest
2221 var rest-type/eax: (addr int) <- get rest, type
2222 compare *rest-type, 0/pair
2224 error trace, "'line' encountered non-pair"
2228 var rest-nil?/eax: boolean <- nil? rest
2229 compare rest-nil?, 0/false
2231 error trace, "'line' needs 6 args but got 3"
2234 var fourth-ah/eax: (addr handle cell) <- get rest, left
2235 var fourth/eax: (addr cell) <- lookup *fourth-ah
2237 var fourth-type/eax: (addr int) <- get fourth, type
2238 compare *fourth-type, 1/number
2240 error trace, "fourth arg for 'line' is not a number (screen x coordinate of end point)"
2243 var fourth-value/eax: (addr float) <- get fourth, number-data
2244 var x2/ecx: int <- convert *fourth-value
2245 # y2 = rest->right->left->value
2246 var rest-ah/eax: (addr handle cell) <- get rest, right
2247 var _rest/eax: (addr cell) <- lookup *rest-ah
2250 var rest-type/eax: (addr int) <- get rest, type
2251 compare *rest-type, 0/pair
2253 error trace, "'line' encountered non-pair"
2257 var rest-nil?/eax: boolean <- nil? rest
2258 compare rest-nil?, 0/false
2260 error trace, "'line' needs 6 args but got 4"
2263 var fifth-ah/eax: (addr handle cell) <- get rest, left
2264 var fifth/eax: (addr cell) <- lookup *fifth-ah
2266 var fifth-type/eax: (addr int) <- get fifth, type
2267 compare *fifth-type, 1/number
2269 error trace, "fifth arg for 'line' is not a number (screen y coordinate of end point)"
2272 var fifth-value/eax: (addr float) <- get fifth, number-data
2273 var tmp/eax: int <- convert *fifth-value
2276 # color = rest->right->left->value
2277 var rest-ah/eax: (addr handle cell) <- get rest, right
2278 var _rest/eax: (addr cell) <- lookup *rest-ah
2281 var rest-type/eax: (addr int) <- get rest, type
2282 compare *rest-type, 0/pair
2284 error trace, "'line' encountered non-pair"
2288 var rest-nil?/eax: boolean <- nil? rest
2289 compare rest-nil?, 0/false
2291 error trace, "'line' needs 6 args but got 5"
2294 var sixth-ah/eax: (addr handle cell) <- get rest, left
2295 var sixth/eax: (addr cell) <- lookup *sixth-ah
2297 var sixth-type/eax: (addr int) <- get sixth, type
2298 compare *sixth-type, 1/number
2300 error trace, "sixth arg for 'line' is not an int (color; 0..0xff)"
2303 var sixth-value/eax: (addr float) <- get sixth, number-data
2304 var color/eax: int <- convert *sixth-value
2305 draw-line screen, x1, y1, x2, y2, color
2309 fn apply-hline _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2310 trace-text trace, "eval", "apply 'hline'"
2311 var args-ah/eax: (addr handle cell) <- copy _args-ah
2312 var _args/eax: (addr cell) <- lookup *args-ah
2313 var args/esi: (addr cell) <- copy _args
2315 var args-type/eax: (addr int) <- get args, type
2316 compare *args-type, 0/pair
2318 error trace, "args to 'hline' are not a list"
2321 var empty-args?/eax: boolean <- nil? args
2322 compare empty-args?, 0/false
2325 error trace, "'hline' needs 5 args but got 0"
2328 # screen = args->left
2329 var first-ah/eax: (addr handle cell) <- get args, left
2330 var first/eax: (addr cell) <- lookup *first-ah
2332 var first-type/eax: (addr int) <- get first, type
2333 compare *first-type, 5/screen
2335 error trace, "first arg for 'hline' is not a screen"
2338 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2339 var _screen/eax: (addr screen) <- lookup *screen-ah
2340 var screen/edi: (addr screen) <- copy _screen
2341 # y = args->right->left->value
2342 var rest-ah/eax: (addr handle cell) <- get args, right
2343 var _rest/eax: (addr cell) <- lookup *rest-ah
2344 var rest/esi: (addr cell) <- copy _rest
2346 var rest-type/eax: (addr int) <- get rest, type
2347 compare *rest-type, 0/pair
2349 error trace, "'hline' encountered non-pair"
2353 var rest-nil?/eax: boolean <- nil? rest
2354 compare rest-nil?, 0/false
2356 error trace, "'hline' needs 5 args but got 1"
2359 var second-ah/eax: (addr handle cell) <- get rest, left
2360 var second/eax: (addr cell) <- lookup *second-ah
2362 var second-type/eax: (addr int) <- get second, type
2363 compare *second-type, 1/number
2365 error trace, "second arg for 'hline' is not a number (screen y coordinate)"
2368 var second-value/eax: (addr float) <- get second, number-data
2369 var y/edx: int <- convert *second-value
2370 # x1 = rest->right->left->value
2371 var rest-ah/eax: (addr handle cell) <- get rest, right
2372 var _rest/eax: (addr cell) <- lookup *rest-ah
2375 var rest-type/eax: (addr int) <- get rest, type
2376 compare *rest-type, 0/pair
2378 error trace, "'hline' encountered non-pair"
2382 var rest-nil?/eax: boolean <- nil? rest
2383 compare rest-nil?, 0/false
2385 error trace, "'hline' needs 5 args but got 2"
2388 var third-ah/eax: (addr handle cell) <- get rest, left
2389 var third/eax: (addr cell) <- lookup *third-ah
2391 var third-type/eax: (addr int) <- get third, type
2392 compare *third-type, 1/number
2394 error trace, "third arg for 'hline' is not a number (screen x coordinate of start point)"
2397 var third-value/eax: (addr float) <- get third, number-data
2398 var x1/ebx: int <- convert *third-value
2399 # x2 = rest->right->left->value
2400 var rest-ah/eax: (addr handle cell) <- get rest, right
2401 var _rest/eax: (addr cell) <- lookup *rest-ah
2402 var rest/esi: (addr cell) <- copy _rest
2404 var rest-type/eax: (addr int) <- get rest, type
2405 compare *rest-type, 0/pair
2407 error trace, "'hline' encountered non-pair"
2411 var rest-nil?/eax: boolean <- nil? rest
2412 compare rest-nil?, 0/false
2414 error trace, "'hline' needs 5 args but got 3"
2417 var fourth-ah/eax: (addr handle cell) <- get rest, left
2418 var fourth/eax: (addr cell) <- lookup *fourth-ah
2420 var fourth-type/eax: (addr int) <- get fourth, type
2421 compare *fourth-type, 1/number
2423 error trace, "fourth arg for 'hline' is not a number (screen x coordinate of end point)"
2426 var fourth-value/eax: (addr float) <- get fourth, number-data
2427 var x2/ecx: int <- convert *fourth-value
2428 # color = rest->right->left->value
2429 var rest-ah/eax: (addr handle cell) <- get rest, right
2430 var _rest/eax: (addr cell) <- lookup *rest-ah
2433 var rest-type/eax: (addr int) <- get rest, type
2434 compare *rest-type, 0/pair
2436 error trace, "'hline' encountered non-pair"
2440 var rest-nil?/eax: boolean <- nil? rest
2441 compare rest-nil?, 0/false
2443 error trace, "'hline' needs 5 args but got 5"
2446 var fifth-ah/eax: (addr handle cell) <- get rest, left
2447 var fifth/eax: (addr cell) <- lookup *fifth-ah
2449 var fifth-type/eax: (addr int) <- get fifth, type
2450 compare *fifth-type, 1/number
2452 error trace, "fifth arg for 'hline' is not an int (color; 0..0xff)"
2455 var fifth-value/eax: (addr float) <- get fifth, number-data
2456 var color/eax: int <- convert *fifth-value
2457 draw-horizontal-line screen, y, x1, x2, color
2461 fn apply-vline _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2462 trace-text trace, "eval", "apply 'vline'"
2463 var args-ah/eax: (addr handle cell) <- copy _args-ah
2464 var _args/eax: (addr cell) <- lookup *args-ah
2465 var args/esi: (addr cell) <- copy _args
2467 var args-type/eax: (addr int) <- get args, type
2468 compare *args-type, 0/pair
2470 error trace, "args to 'vline' are not a list"
2473 var empty-args?/eax: boolean <- nil? args
2474 compare empty-args?, 0/false
2477 error trace, "'vline' needs 5 args but got 0"
2480 # screen = args->left
2481 var first-ah/eax: (addr handle cell) <- get args, left
2482 var first/eax: (addr cell) <- lookup *first-ah
2484 var first-type/eax: (addr int) <- get first, type
2485 compare *first-type, 5/screen
2487 error trace, "first arg for 'vline' is not a screen"
2490 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2491 var _screen/eax: (addr screen) <- lookup *screen-ah
2492 var screen/edi: (addr screen) <- copy _screen
2493 # x = args->right->left->value
2494 var rest-ah/eax: (addr handle cell) <- get args, right
2495 var _rest/eax: (addr cell) <- lookup *rest-ah
2496 var rest/esi: (addr cell) <- copy _rest
2498 var rest-type/eax: (addr int) <- get rest, type
2499 compare *rest-type, 0/pair
2501 error trace, "'vline' encountered non-pair"
2505 var rest-nil?/eax: boolean <- nil? rest
2506 compare rest-nil?, 0/false
2508 error trace, "'vline' needs 5 args but got 1"
2511 var second-ah/eax: (addr handle cell) <- get rest, left
2512 var second/eax: (addr cell) <- lookup *second-ah
2514 var second-type/eax: (addr int) <- get second, type
2515 compare *second-type, 1/number
2517 error trace, "second arg for 'vline' is not a number (screen x coordinate)"
2520 var second-value/eax: (addr float) <- get second, number-data
2521 var x/edx: int <- convert *second-value
2522 # y1 = rest->right->left->value
2523 var rest-ah/eax: (addr handle cell) <- get rest, right
2524 var _rest/eax: (addr cell) <- lookup *rest-ah
2527 var rest-type/eax: (addr int) <- get rest, type
2528 compare *rest-type, 0/pair
2530 error trace, "'vline' encountered non-pair"
2534 var rest-nil?/eax: boolean <- nil? rest
2535 compare rest-nil?, 0/false
2537 error trace, "'vline' needs 5 args but got 2"
2540 var third-ah/eax: (addr handle cell) <- get rest, left
2541 var third/eax: (addr cell) <- lookup *third-ah
2543 var third-type/eax: (addr int) <- get third, type
2544 compare *third-type, 1/number
2546 error trace, "third arg for 'vline' is not a number (screen y coordinate of start point)"
2549 var third-value/eax: (addr float) <- get third, number-data
2550 var y1/ebx: int <- convert *third-value
2551 # y2 = rest->right->left->value
2552 var rest-ah/eax: (addr handle cell) <- get rest, right
2553 var _rest/eax: (addr cell) <- lookup *rest-ah
2554 var rest/esi: (addr cell) <- copy _rest
2556 var rest-type/eax: (addr int) <- get rest, type
2557 compare *rest-type, 0/pair
2559 error trace, "'vline' encountered non-pair"
2563 var rest-nil?/eax: boolean <- nil? rest
2564 compare rest-nil?, 0/false
2566 error trace, "'vline' needs 5 args but got 3"
2569 var fourth-ah/eax: (addr handle cell) <- get rest, left
2570 var fourth/eax: (addr cell) <- lookup *fourth-ah
2572 var fourth-type/eax: (addr int) <- get fourth, type
2573 compare *fourth-type, 1/number
2575 error trace, "fourth arg for 'vline' is not a number (screen y coordinate of end point)"
2578 var fourth-value/eax: (addr float) <- get fourth, number-data
2579 var y2/ecx: int <- convert *fourth-value
2580 # color = rest->right->left->value
2581 var rest-ah/eax: (addr handle cell) <- get rest, right
2582 var _rest/eax: (addr cell) <- lookup *rest-ah
2585 var rest-type/eax: (addr int) <- get rest, type
2586 compare *rest-type, 0/pair
2588 error trace, "'vline' encountered non-pair"
2592 var rest-nil?/eax: boolean <- nil? rest
2593 compare rest-nil?, 0/false
2595 error trace, "'vline' needs 5 args but got 5"
2598 var fifth-ah/eax: (addr handle cell) <- get rest, left
2599 var fifth/eax: (addr cell) <- lookup *fifth-ah
2601 var fifth-type/eax: (addr int) <- get fifth, type
2602 compare *fifth-type, 1/number
2604 error trace, "fifth arg for 'vline' is not an int (color; 0..0xff)"
2607 var fifth-value/eax: (addr float) <- get fifth, number-data
2608 var color/eax: int <- convert *fifth-value
2609 draw-vertical-line screen, x, y1, y2, color
2613 fn apply-circle _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2614 trace-text trace, "eval", "apply 'circle'"
2615 var args-ah/eax: (addr handle cell) <- copy _args-ah
2616 var _args/eax: (addr cell) <- lookup *args-ah
2617 var args/esi: (addr cell) <- copy _args
2619 var args-type/eax: (addr int) <- get args, type
2620 compare *args-type, 0/pair
2622 error trace, "args to 'circle' are not a list"
2625 var empty-args?/eax: boolean <- nil? args
2626 compare empty-args?, 0/false
2629 error trace, "'circle' needs 5 args but got 0"
2632 # screen = args->left
2633 var first-ah/eax: (addr handle cell) <- get args, left
2634 var first/eax: (addr cell) <- lookup *first-ah
2636 var first-type/eax: (addr int) <- get first, type
2637 compare *first-type, 5/screen
2639 error trace, "first arg for 'circle' is not a screen"
2642 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2643 var _screen/eax: (addr screen) <- lookup *screen-ah
2644 var screen/edi: (addr screen) <- copy _screen
2645 # cx = args->right->left->value
2646 var rest-ah/eax: (addr handle cell) <- get args, right
2647 var _rest/eax: (addr cell) <- lookup *rest-ah
2648 var rest/esi: (addr cell) <- copy _rest
2650 var rest-type/eax: (addr int) <- get rest, type
2651 compare *rest-type, 0/pair
2653 error trace, "'circle' encountered non-pair"
2657 var rest-nil?/eax: boolean <- nil? rest
2658 compare rest-nil?, 0/false
2660 error trace, "'circle' needs 5 args but got 1"
2663 var second-ah/eax: (addr handle cell) <- get rest, left
2664 var second/eax: (addr cell) <- lookup *second-ah
2666 var second-type/eax: (addr int) <- get second, type
2667 compare *second-type, 1/number
2669 error trace, "second arg for 'circle' is not a number (screen x coordinate of center)"
2672 var second-value/eax: (addr float) <- get second, number-data
2673 var cx/edx: int <- convert *second-value
2674 # cy = rest->right->left->value
2675 var rest-ah/eax: (addr handle cell) <- get rest, right
2676 var _rest/eax: (addr cell) <- lookup *rest-ah
2679 var rest-type/eax: (addr int) <- get rest, type
2680 compare *rest-type, 0/pair
2682 error trace, "'circle' encountered non-pair"
2686 var rest-nil?/eax: boolean <- nil? rest
2687 compare rest-nil?, 0/false
2689 error trace, "'circle' needs 5 args but got 2"
2692 var third-ah/eax: (addr handle cell) <- get rest, left
2693 var third/eax: (addr cell) <- lookup *third-ah
2695 var third-type/eax: (addr int) <- get third, type
2696 compare *third-type, 1/number
2698 error trace, "third arg for 'circle' is not a number (screen y coordinate of center)"
2701 var third-value/eax: (addr float) <- get third, number-data
2702 var cy/ebx: int <- convert *third-value
2703 # r = rest->right->left->value
2704 var rest-ah/eax: (addr handle cell) <- get rest, right
2705 var _rest/eax: (addr cell) <- lookup *rest-ah
2706 var rest/esi: (addr cell) <- copy _rest
2708 var rest-type/eax: (addr int) <- get rest, type
2709 compare *rest-type, 0/pair
2711 error trace, "'circle' encountered non-pair"
2715 var rest-nil?/eax: boolean <- nil? rest
2716 compare rest-nil?, 0/false
2718 error trace, "'circle' needs 5 args but got 3"
2721 var fourth-ah/eax: (addr handle cell) <- get rest, left
2722 var fourth/eax: (addr cell) <- lookup *fourth-ah
2724 var fourth-type/eax: (addr int) <- get fourth, type
2725 compare *fourth-type, 1/number
2727 error trace, "fourth arg for 'circle' is not a number (screen radius)"
2730 var fourth-value/eax: (addr float) <- get fourth, number-data
2731 var r/ecx: int <- convert *fourth-value
2732 # color = rest->right->left->value
2733 var rest-ah/eax: (addr handle cell) <- get rest, right
2734 var _rest/eax: (addr cell) <- lookup *rest-ah
2737 var rest-type/eax: (addr int) <- get rest, type
2738 compare *rest-type, 0/pair
2740 error trace, "'circle' encountered non-pair"
2744 var rest-nil?/eax: boolean <- nil? rest
2745 compare rest-nil?, 0/false
2747 error trace, "'circle' needs 5 args but got 5"
2750 var fifth-ah/eax: (addr handle cell) <- get rest, left
2751 var fifth/eax: (addr cell) <- lookup *fifth-ah
2753 var fifth-type/eax: (addr int) <- get fifth, type
2754 compare *fifth-type, 1/number
2756 error trace, "fifth arg for 'circle' is not an int (color; 0..0xff)"
2759 var fifth-value/eax: (addr float) <- get fifth, number-data
2760 var color/eax: int <- convert *fifth-value
2761 draw-circle screen, cx, cy, r, color
2765 fn apply-bezier _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
2766 trace-text trace, "eval", "apply 'bezier'"
2767 var args-ah/eax: (addr handle cell) <- copy _args-ah
2768 var _args/eax: (addr cell) <- lookup *args-ah
2769 var args/esi: (addr cell) <- copy _args
2771 var args-type/eax: (addr int) <- get args, type
2772 compare *args-type, 0/pair
2774 error trace, "args to 'bezier' are not a list"
2777 var empty-args?/eax: boolean <- nil? args
2778 compare empty-args?, 0/false
2781 error trace, "'bezier' needs 8 args but got 0"
2784 # screen = args->left
2785 var first-ah/eax: (addr handle cell) <- get args, left
2786 var first/eax: (addr cell) <- lookup *first-ah
2788 var first-type/eax: (addr int) <- get first, type
2789 compare *first-type, 5/screen
2791 error trace, "first arg for 'bezier' is not a screen"
2794 var screen-ah/eax: (addr handle screen) <- get first, screen-data
2795 var _screen/eax: (addr screen) <- lookup *screen-ah
2796 var screen/edi: (addr screen) <- copy _screen
2797 # x0 = args->right->left->value
2798 var rest-ah/eax: (addr handle cell) <- get args, right
2799 var _rest/eax: (addr cell) <- lookup *rest-ah
2800 var rest/esi: (addr cell) <- copy _rest
2802 var rest-type/eax: (addr int) <- get rest, type
2803 compare *rest-type, 0/pair
2805 error trace, "'bezier' encountered non-pair"
2809 var rest-nil?/eax: boolean <- nil? rest
2810 compare rest-nil?, 0/false
2812 error trace, "'bezier' needs 8 args but got 1"
2815 var second-ah/eax: (addr handle cell) <- get rest, left
2816 var second/eax: (addr cell) <- lookup *second-ah
2818 var second-type/eax: (addr int) <- get second, type
2819 compare *second-type, 1/number
2821 error trace, "second arg for 'bezier' is not a number (screen x coordinate of start point)"
2824 var second-value/eax: (addr float) <- get second, number-data
2825 var x0/edx: int <- convert *second-value
2826 # y0 = rest->right->left->value
2827 var rest-ah/eax: (addr handle cell) <- get rest, right
2828 var _rest/eax: (addr cell) <- lookup *rest-ah
2831 var rest-type/eax: (addr int) <- get rest, type
2832 compare *rest-type, 0/pair
2834 error trace, "'bezier' encountered non-pair"
2838 var rest-nil?/eax: boolean <- nil? rest
2839 compare rest-nil?, 0/false
2841 error trace, "'bezier' needs 8 args but got 2"
2844 var third-ah/eax: (addr handle cell) <- get rest, left
2845 var third/eax: (addr cell) <- lookup *third-ah
2847 var third-type/eax: (addr int) <- get third, type
2848 compare *third-type, 1/number
2850 error trace, "third arg for 'bezier' is not a number (screen y coordinate of start point)"
2853 var third-value/eax: (addr float) <- get third, number-data
2854 var y0/ebx: int <- convert *third-value
2855 # x1 = rest->right->left->value
2856 var rest-ah/eax: (addr handle cell) <- get rest, right
2857 var _rest/eax: (addr cell) <- lookup *rest-ah
2858 var rest/esi: (addr cell) <- copy _rest
2860 var rest-type/eax: (addr int) <- get rest, type
2861 compare *rest-type, 0/pair
2863 error trace, "'bezier' encountered non-pair"
2867 var rest-nil?/eax: boolean <- nil? rest
2868 compare rest-nil?, 0/false
2870 error trace, "'bezier' needs 8 args but got 3"
2873 var fourth-ah/eax: (addr handle cell) <- get rest, left
2874 var fourth/eax: (addr cell) <- lookup *fourth-ah
2876 var fourth-type/eax: (addr int) <- get fourth, type
2877 compare *fourth-type, 1/number
2879 error trace, "fourth arg for 'bezier' is not a number (screen x coordinate of control point)"
2882 var fourth-value/eax: (addr float) <- get fourth, number-data
2883 var tmp/eax: int <- convert *fourth-value
2886 # y1 = rest->right->left->value
2887 var rest-ah/eax: (addr handle cell) <- get rest, right
2888 var _rest/eax: (addr cell) <- lookup *rest-ah
2891 var rest-type/eax: (addr int) <- get rest, type
2892 compare *rest-type, 0/pair
2894 error trace, "'bezier' encountered non-pair"
2898 var rest-nil?/eax: boolean <- nil? rest
2899 compare rest-nil?, 0/false
2901 error trace, "'bezier' needs 8 args but got 4"
2904 var fifth-ah/eax: (addr handle cell) <- get rest, left
2905 var fifth/eax: (addr cell) <- lookup *fifth-ah
2907 var fifth-type/eax: (addr int) <- get fifth, type
2908 compare *fifth-type, 1/number
2910 error trace, "fifth arg for 'bezier' is not a number (screen y coordinate of control point)"
2913 var fifth-value/eax: (addr float) <- get fifth, number-data
2914 var tmp/eax: int <- convert *fifth-value
2917 # x2 = rest->right->left->value
2918 var rest-ah/eax: (addr handle cell) <- get rest, right
2919 var _rest/eax: (addr cell) <- lookup *rest-ah
2920 var rest/esi: (addr cell) <- copy _rest
2922 var rest-type/eax: (addr int) <- get rest, type
2923 compare *rest-type, 0/pair
2925 error trace, "'bezier' encountered non-pair"
2929 var rest-nil?/eax: boolean <- nil? rest
2930 compare rest-nil?, 0/false
2932 error trace, "'bezier' needs 8 args but got 3"
2935 var sixth-ah/eax: (addr handle cell) <- get rest, left
2936 var sixth/eax: (addr cell) <- lookup *sixth-ah
2938 var sixth-type/eax: (addr int) <- get sixth, type
2939 compare *sixth-type, 1/number
2941 error trace, "sixth arg for 'bezier' is not a number (screen x coordinate of end point)"
2944 var sixth-value/eax: (addr float) <- get sixth, number-data
2945 var tmp/eax: int <- convert *sixth-value
2948 # y2 = rest->right->left->value
2949 var rest-ah/eax: (addr handle cell) <- get rest, right
2950 var _rest/eax: (addr cell) <- lookup *rest-ah
2953 var rest-type/eax: (addr int) <- get rest, type
2954 compare *rest-type, 0/pair
2956 error trace, "'bezier' encountered non-pair"
2960 var rest-nil?/eax: boolean <- nil? rest
2961 compare rest-nil?, 0/false
2963 error trace, "'bezier' needs 8 args but got 4"
2966 var seventh-ah/eax: (addr handle cell) <- get rest, left
2967 var seventh/eax: (addr cell) <- lookup *seventh-ah
2969 var seventh-type/eax: (addr int) <- get seventh, type
2970 compare *seventh-type, 1/number
2972 error trace, "seventh arg for 'bezier' is not a number (screen y coordinate of end point)"
2975 var seventh-value/eax: (addr float) <- get seventh, number-data
2976 var tmp/eax: int <- convert *seventh-value
2979 # color = rest->right->left->value
2980 var rest-ah/eax: (addr handle cell) <- get rest, right
2981 var _rest/eax: (addr cell) <- lookup *rest-ah
2984 var rest-type/eax: (addr int) <- get rest, type
2985 compare *rest-type, 0/pair
2987 error trace, "'bezier' encountered non-pair"
2991 var rest-nil?/eax: boolean <- nil? rest
2992 compare rest-nil?, 0/false
2994 error trace, "'bezier' needs 8 args but got 5"
2997 var eighth-ah/eax: (addr handle cell) <- get rest, left
2998 var eighth/eax: (addr cell) <- lookup *eighth-ah
3000 var eighth-type/eax: (addr int) <- get eighth, type
3001 compare *eighth-type, 1/number
3003 error trace, "eighth arg for 'bezier' is not an int (color; 0..0xff)"
3006 var eighth-value/eax: (addr float) <- get eighth, number-data
3007 var color/eax: int <- convert *eighth-value
3008 draw-monotonic-bezier screen, x0, y0, x1, y1, x2, y2, color
3012 fn apply-wait-for-key _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3013 trace-text trace, "eval", "apply 'key'"
3014 var args-ah/eax: (addr handle cell) <- copy _args-ah
3015 var _args/eax: (addr cell) <- lookup *args-ah
3016 var args/esi: (addr cell) <- copy _args
3018 var args-type/eax: (addr int) <- get args, type
3019 compare *args-type, 0/pair
3021 error trace, "args to 'key' are not a list"
3024 var empty-args?/eax: boolean <- nil? args
3025 compare empty-args?, 0/false
3028 error trace, "'key' needs 1 arg but got 0"
3031 # keyboard = args->left
3032 var first-ah/eax: (addr handle cell) <- get args, left
3033 var first/eax: (addr cell) <- lookup *first-ah
3035 var first-type/eax: (addr int) <- get first, type
3036 compare *first-type, 6/keyboard
3038 error trace, "first arg for 'key' is not a keyboard"
3041 var keyboard-ah/eax: (addr handle gap-buffer) <- get first, keyboard-data
3042 var _keyboard/eax: (addr gap-buffer) <- lookup *keyboard-ah
3043 var keyboard/ecx: (addr gap-buffer) <- copy _keyboard
3044 var result/eax: int <- wait-for-key keyboard
3046 new-integer out, result
3049 fn wait-for-key keyboard: (addr gap-buffer) -> _/eax: int {
3050 # if keyboard is 0, use real keyboard
3052 compare keyboard, 0/real-keyboard
3054 var key/eax: byte <- read-key 0/real-keyboard
3055 var result/eax: int <- copy key
3058 # otherwise read from fake keyboard
3059 var g/eax: code-point-utf8 <- read-from-gap-buffer keyboard
3060 var result/eax: int <- copy g
3064 fn apply-stream _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3065 trace-text trace, "eval", "apply stream"
3069 fn apply-write _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3070 trace-text trace, "eval", "apply 'write'"
3071 var args-ah/eax: (addr handle cell) <- copy _args-ah
3072 var _args/eax: (addr cell) <- lookup *args-ah
3073 var args/esi: (addr cell) <- copy _args
3075 var args-type/eax: (addr int) <- get args, type
3076 compare *args-type, 0/pair
3078 error trace, "args to 'write' are not a list"
3081 var empty-args?/eax: boolean <- nil? args
3082 compare empty-args?, 0/false
3085 error trace, "'write' needs 2 args but got 0"
3088 # stream = args->left
3089 var first-ah/edx: (addr handle cell) <- get args, left
3090 var first/eax: (addr cell) <- lookup *first-ah
3092 var first-type/eax: (addr int) <- get first, type
3093 compare *first-type, 3/stream
3095 error trace, "first arg for 'write' is not a stream"
3098 var stream-data-ah/eax: (addr handle stream byte) <- get first, text-data
3099 var _stream-data/eax: (addr stream byte) <- lookup *stream-data-ah
3100 var stream-data/ebx: (addr stream byte) <- copy _stream-data
3102 var right-ah/eax: (addr handle cell) <- get args, right
3103 var right/eax: (addr cell) <- lookup *right-ah
3105 var right-type/eax: (addr int) <- get right, type
3106 compare *right-type, 0/pair
3108 error trace, "'write' encountered non-pair"
3112 var nil?/eax: boolean <- nil? right
3113 compare nil?, 0/false
3115 error trace, "'write' needs 2 args but got 1"
3118 var second-ah/eax: (addr handle cell) <- get right, left
3119 var second/eax: (addr cell) <- lookup *second-ah
3121 var second-type/eax: (addr int) <- get second, type
3122 compare *second-type, 1/number
3124 error trace, "second arg for 'write' is not a number/code-point-utf8"
3127 var second-value/eax: (addr float) <- get second, number-data
3128 var x-float/xmm0: float <- copy *second-value
3129 var x/eax: int <- convert x-float
3130 var x-code-point-utf8/eax: code-point-utf8 <- copy x
3131 write-code-point-utf8 stream-data, x-code-point-utf8
3133 copy-object first-ah, out
3136 fn apply-rewind _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3137 trace-text trace, "eval", "apply 'rewind'"
3138 var args-ah/eax: (addr handle cell) <- copy _args-ah
3139 var _args/eax: (addr cell) <- lookup *args-ah
3140 var args/esi: (addr cell) <- copy _args
3142 var args-type/eax: (addr int) <- get args, type
3143 compare *args-type, 0/pair
3145 error trace, "args to 'rewind' are not a list"
3148 var empty-args?/eax: boolean <- nil? args
3149 compare empty-args?, 0/false
3152 error trace, "'rewind' needs 1 arg but got 0"
3155 # stream = args->left
3156 var first-ah/edx: (addr handle cell) <- get args, left
3157 var first/eax: (addr cell) <- lookup *first-ah
3159 var first-type/eax: (addr int) <- get first, type
3160 compare *first-type, 3/stream
3162 error trace, "first arg for 'rewind' is not a stream"
3165 var stream-data-ah/eax: (addr handle stream byte) <- get first, text-data
3166 var _stream-data/eax: (addr stream byte) <- lookup *stream-data-ah
3167 var stream-data/ebx: (addr stream byte) <- copy _stream-data
3168 rewind-stream stream-data
3169 copy-object first-ah, out
3172 fn apply-read _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3173 trace-text trace, "eval", "apply 'read'"
3174 var args-ah/eax: (addr handle cell) <- copy _args-ah
3175 var _args/eax: (addr cell) <- lookup *args-ah
3176 var args/esi: (addr cell) <- copy _args
3178 var args-type/eax: (addr int) <- get args, type
3179 compare *args-type, 0/pair
3181 error trace, "args to 'read' are not a list"
3184 var empty-args?/eax: boolean <- nil? args
3185 compare empty-args?, 0/false
3188 error trace, "'read' needs 1 arg but got 0"
3191 # stream = args->left
3192 var first-ah/edx: (addr handle cell) <- get args, left
3193 var first/eax: (addr cell) <- lookup *first-ah
3195 var first-type/eax: (addr int) <- get first, type
3196 compare *first-type, 3/stream
3198 error trace, "first arg for 'read' is not a stream"
3201 var stream-data-ah/eax: (addr handle stream byte) <- get first, text-data
3202 var _stream-data/eax: (addr stream byte) <- lookup *stream-data-ah
3203 var stream-data/ebx: (addr stream byte) <- copy _stream-data
3204 #? rewind-stream stream-data
3205 var result-code-point-utf8/eax: code-point-utf8 <- read-code-point-utf8 stream-data
3206 var result/eax: int <- copy result-code-point-utf8
3207 new-integer out, result
3210 fn apply-lines _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3211 trace-text trace, "eval", "apply 'lines'"
3212 var args-ah/eax: (addr handle cell) <- copy _args-ah
3213 var _args/eax: (addr cell) <- lookup *args-ah
3214 var args/esi: (addr cell) <- copy _args
3216 var args-type/eax: (addr int) <- get args, type
3217 compare *args-type, 0/pair
3219 error trace, "args to 'lines' are not a list"
3222 var empty-args?/eax: boolean <- nil? args
3223 compare empty-args?, 0/false
3226 error trace, "'lines' needs 1 arg but got 0"
3229 # screen = args->left
3230 var first-ah/eax: (addr handle cell) <- get args, left
3231 var first/eax: (addr cell) <- lookup *first-ah
3233 var first-type/eax: (addr int) <- get first, type
3234 compare *first-type, 5/screen
3236 error trace, "first arg for 'lines' is not a screen"
3239 var screen-ah/eax: (addr handle screen) <- get first, screen-data
3240 var _screen/eax: (addr screen) <- lookup *screen-ah
3241 var screen/edx: (addr screen) <- copy _screen
3242 # compute dimensions
3243 var dummy/eax: int <- copy 0
3244 var height/ecx: int <- copy 0
3245 dummy, height <- screen-size screen
3246 var result/xmm0: float <- convert height
3247 new-float out, result
3250 fn apply-columns _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3251 trace-text trace, "eval", "apply 'columns'"
3252 var args-ah/eax: (addr handle cell) <- copy _args-ah
3253 var _args/eax: (addr cell) <- lookup *args-ah
3254 var args/esi: (addr cell) <- copy _args
3256 var args-type/eax: (addr int) <- get args, type
3257 compare *args-type, 0/pair
3259 error trace, "args to 'columns' are not a list"
3262 var empty-args?/eax: boolean <- nil? args
3263 compare empty-args?, 0/false
3266 error trace, "'columns' needs 1 arg but got 0"
3269 # screen = args->left
3270 var first-ah/eax: (addr handle cell) <- get args, left
3271 var first/eax: (addr cell) <- lookup *first-ah
3273 var first-type/eax: (addr int) <- get first, type
3274 compare *first-type, 5/screen
3276 error trace, "first arg for 'columns' is not a screen"
3279 var screen-ah/eax: (addr handle screen) <- get first, screen-data
3280 var _screen/eax: (addr screen) <- lookup *screen-ah
3281 var screen/edx: (addr screen) <- copy _screen
3282 # compute dimensions
3283 var width/eax: int <- copy 0
3284 var dummy/ecx: int <- copy 0
3285 width, dummy <- screen-size screen
3286 var result/xmm0: float <- convert width
3287 new-float out, result
3290 fn apply-width _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3291 trace-text trace, "eval", "apply 'width'"
3292 var args-ah/eax: (addr handle cell) <- copy _args-ah
3293 var _args/eax: (addr cell) <- lookup *args-ah
3294 var args/esi: (addr cell) <- copy _args
3296 var args-type/eax: (addr int) <- get args, type
3297 compare *args-type, 0/pair
3299 error trace, "args to 'width' are not a list"
3302 var empty-args?/eax: boolean <- nil? args
3303 compare empty-args?, 0/false
3306 error trace, "'width' needs 1 arg but got 0"
3309 # screen = args->left
3310 var first-ah/eax: (addr handle cell) <- get args, left
3311 var first/eax: (addr cell) <- lookup *first-ah
3313 var first-type/eax: (addr int) <- get first, type
3314 compare *first-type, 5/screen
3316 error trace, "first arg for 'width' is not a screen"
3319 var screen-ah/eax: (addr handle screen) <- get first, screen-data
3320 var _screen/eax: (addr screen) <- lookup *screen-ah
3321 var screen/edx: (addr screen) <- copy _screen
3322 # compute dimensions
3323 var width/eax: int <- copy 0
3324 var dummy/ecx: int <- copy 0
3325 width, dummy <- screen-size screen
3326 width <- shift-left 3/log2-font-width
3327 var result/xmm0: float <- convert width
3328 new-float out, result
3331 fn apply-height _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3332 trace-text trace, "eval", "apply 'height'"
3333 var args-ah/eax: (addr handle cell) <- copy _args-ah
3334 var _args/eax: (addr cell) <- lookup *args-ah
3335 var args/esi: (addr cell) <- copy _args
3337 var args-type/eax: (addr int) <- get args, type
3338 compare *args-type, 0/pair
3340 error trace, "args to 'height' are not a list"
3343 var empty-args?/eax: boolean <- nil? args
3344 compare empty-args?, 0/false
3347 error trace, "'height' needs 1 arg but got 0"
3350 # screen = args->left
3351 var first-ah/eax: (addr handle cell) <- get args, left
3352 var first/eax: (addr cell) <- lookup *first-ah
3354 var first-type/eax: (addr int) <- get first, type
3355 compare *first-type, 5/screen
3357 error trace, "first arg for 'height' is not a screen"
3360 var screen-ah/eax: (addr handle screen) <- get first, screen-data
3361 var _screen/eax: (addr screen) <- lookup *screen-ah
3362 var screen/edx: (addr screen) <- copy _screen
3363 # compute dimensions
3364 var dummy/eax: int <- copy 0
3365 var height/ecx: int <- copy 0
3366 dummy, height <- screen-size screen
3367 height <- shift-left 4/log2-font-height
3368 var result/xmm0: float <- convert height
3369 new-float out, result
3372 fn apply-new-screen _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3373 trace-text trace, "eval", "apply 'screen'"
3374 var args-ah/eax: (addr handle cell) <- copy _args-ah
3375 var _args/eax: (addr cell) <- lookup *args-ah
3376 var args/esi: (addr cell) <- copy _args
3378 var args-type/eax: (addr int) <- get args, type
3379 compare *args-type, 0/pair
3381 error trace, "args to 'screen' are not a list"
3384 var empty-args?/eax: boolean <- nil? args
3385 compare empty-args?, 0/false
3388 error trace, "'screen' needs 2 args but got 0"
3392 var first-ah/eax: (addr handle cell) <- get args, left
3393 var first/eax: (addr cell) <- lookup *first-ah
3395 var first-type/eax: (addr int) <- get first, type
3396 compare *first-type, 1/number
3398 error trace, "first arg for 'screen' is not a number (screen width in pixels)"
3401 var first-value-a/ecx: (addr float) <- get first, number-data
3402 var first-value/ecx: int <- convert *first-value-a
3403 # args->right->left->value
3404 var right-ah/eax: (addr handle cell) <- get args, right
3405 var right/eax: (addr cell) <- lookup *right-ah
3407 var right-type/eax: (addr int) <- get right, type
3408 compare *right-type, 0/pair
3410 error trace, "'screen' encountered non-pair"
3414 var nil?/eax: boolean <- nil? right
3415 compare nil?, 0/false
3417 error trace, "'screen' needs 2 args but got 1"
3420 var second-ah/eax: (addr handle cell) <- get right, left
3421 var second/eax: (addr cell) <- lookup *second-ah
3423 var second-type/eax: (addr int) <- get second, type
3424 compare *second-type, 1/number
3426 error trace, "second arg for 'screen' is not a number (screen height in pixels)"
3429 var second-value-a/edx: (addr float) <- get second, number-data
3430 var second-value/edx: int <- convert *second-value-a
3431 # create fake screen
3432 new-fake-screen out, first-value, second-value, 1/pixel-graphics
3435 fn apply-blit _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3436 trace-text trace, "eval", "apply 'blit'"
3437 var args-ah/eax: (addr handle cell) <- copy _args-ah
3438 var _args/eax: (addr cell) <- lookup *args-ah
3439 var args/esi: (addr cell) <- copy _args
3441 var args-type/eax: (addr int) <- get args, type
3442 compare *args-type, 0/pair
3444 error trace, "args to 'blit' are not a list"
3447 var empty-args?/eax: boolean <- nil? args
3448 compare empty-args?, 0/false
3451 error trace, "'blit' needs 2 args but got 0"
3454 # screen = args->left
3455 var first-ah/eax: (addr handle cell) <- get args, left
3456 var first/eax: (addr cell) <- lookup *first-ah
3458 var first-type/eax: (addr int) <- get first, type
3459 compare *first-type, 5/screen
3461 error trace, "first arg for 'blit' is not a screen"
3464 var src-ah/eax: (addr handle screen) <- get first, screen-data
3465 var _src/eax: (addr screen) <- lookup *src-ah
3466 var src/ecx: (addr screen) <- copy _src
3468 var right-ah/eax: (addr handle cell) <- get args, right
3469 var right/eax: (addr cell) <- lookup *right-ah
3471 var right-type/eax: (addr int) <- get right, type
3472 compare *right-type, 0/pair
3474 error trace, "'blit' encountered non-pair"
3478 var nil?/eax: boolean <- nil? right
3479 compare nil?, 0/false
3481 error trace, "'blit' needs 2 args but got 1"
3484 var second-ah/eax: (addr handle cell) <- get right, left
3485 var second/eax: (addr cell) <- lookup *second-ah
3487 var second-type/eax: (addr int) <- get second, type
3488 compare *second-type, 5/screen
3490 error trace, "second arg for 'blit' is not a screen"
3493 var dest-ah/eax: (addr handle screen) <- get second, screen-data
3494 var dest/eax: (addr screen) <- lookup *dest-ah
3496 convert-screen-cells-to-pixels src
3497 copy-pixels src, dest
3500 fn apply-array _args-ah: (addr handle cell), _out-ah: (addr handle cell), trace: (addr trace) {
3501 trace-text trace, "eval", "apply 'array'"
3502 var args-ah/eax: (addr handle cell) <- copy _args-ah
3503 var _args/eax: (addr cell) <- lookup *args-ah
3504 var args/esi: (addr cell) <- copy _args
3506 var args-type/eax: (addr int) <- get args, type
3507 compare *args-type, 0/pair
3509 error trace, "args to 'array' are not a list"
3512 var capacity/eax: int <- list-length args
3513 var out-ah/edi: (addr handle cell) <- copy _out-ah
3514 new-array out-ah, capacity
3515 var out/eax: (addr cell) <- lookup *out-ah
3516 var out-data-ah/eax: (addr handle array handle cell) <- get out, array-data
3517 var _out-data/eax: (addr array handle cell) <- lookup *out-data-ah
3518 var out-data/edi: (addr array handle cell) <- copy _out-data
3519 var i/ecx: int <- copy 0
3521 var done?/eax: boolean <- nil? args
3522 compare done?, 0/false
3524 var curr-ah/eax: (addr handle cell) <- get args, left
3525 var dest-ah/edx: (addr handle cell) <- index out-data, i
3526 copy-object curr-ah, dest-ah
3527 # update loop variables
3529 var next-ah/eax: (addr handle cell) <- get args, right
3530 var next/eax: (addr cell) <- lookup *next-ah
3536 fn apply-populate _args-ah: (addr handle cell), _out-ah: (addr handle cell), trace: (addr trace) {
3537 trace-text trace, "eval", "apply 'populate'"
3538 var args-ah/eax: (addr handle cell) <- copy _args-ah
3539 var _args/eax: (addr cell) <- lookup *args-ah
3540 var args/esi: (addr cell) <- copy _args
3542 var args-type/eax: (addr int) <- get args, type
3543 compare *args-type, 0/pair
3545 error trace, "args to 'populate' are not a list"
3548 var empty-args?/eax: boolean <- nil? args
3549 compare empty-args?, 0/false
3552 error trace, "'populate' needs 2 args but got 0"
3556 var first-ah/ecx: (addr handle cell) <- get args, left
3558 var right-ah/eax: (addr handle cell) <- get args, right
3559 var right/eax: (addr cell) <- lookup *right-ah
3561 var right-type/eax: (addr int) <- get right, type
3562 compare *right-type, 0/pair
3564 error trace, "'populate' encountered non-pair"
3568 var nil?/eax: boolean <- nil? right
3569 compare nil?, 0/false
3571 error trace, "'populate' needs 2 args but got 1"
3574 var second-ah/edx: (addr handle cell) <- get right, left
3576 var first/eax: (addr cell) <- lookup *first-ah
3578 var first-type/eax: (addr int) <- get first, type
3579 compare *first-type, 1/number
3581 error trace, "first arg for 'populate' is not a number"
3584 var first-value/eax: (addr float) <- get first, number-data
3585 var capacity/ecx: int <- convert *first-value
3586 var out-ah/edi: (addr handle cell) <- copy _out-ah
3587 new-array out-ah, capacity
3588 var out/eax: (addr cell) <- lookup *out-ah
3589 var data-ah/eax: (addr handle array handle cell) <- get out, array-data
3590 var data/eax: (addr array handle cell) <- lookup *data-ah
3591 var i/ebx: int <- copy 0
3595 var curr-ah/ecx: (addr handle cell) <- index data, i
3596 copy-object second-ah, curr-ah
3602 fn apply-index _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3603 trace-text trace, "eval", "apply 'index'"
3604 var args-ah/eax: (addr handle cell) <- copy _args-ah
3605 var _args/eax: (addr cell) <- lookup *args-ah
3606 var args/esi: (addr cell) <- copy _args
3608 var args-type/eax: (addr int) <- get args, type
3609 compare *args-type, 0/pair
3611 error trace, "args to 'index' are not a list"
3614 var empty-args?/eax: boolean <- nil? args
3615 compare empty-args?, 0/false
3618 error trace, "'index' needs 2 args but got 0"
3622 var first-ah/ecx: (addr handle cell) <- get args, left
3624 var right-ah/eax: (addr handle cell) <- get args, right
3625 var right/eax: (addr cell) <- lookup *right-ah
3627 var right-type/eax: (addr int) <- get right, type
3628 compare *right-type, 0/pair
3630 error trace, "'index' encountered non-pair"
3634 var nil?/eax: boolean <- nil? right
3635 compare nil?, 0/false
3637 error trace, "'index' needs 2 args but got 1"
3640 var second-ah/edx: (addr handle cell) <- get right, left
3642 var _first/eax: (addr cell) <- lookup *first-ah
3643 var first/ecx: (addr cell) <- copy _first
3645 var first-type/eax: (addr int) <- get first, type
3646 compare *first-type, 7/array
3648 error trace, "first arg for 'index' is not an array"
3651 var second/eax: (addr cell) <- lookup *second-ah
3653 var second-type/eax: (addr int) <- get second, type
3654 compare *second-type, 1/number
3656 error trace, "second arg for 'index' is not a number"
3659 var second-value/eax: (addr float) <- get second, number-data
3660 var index/edx: int <- truncate *second-value
3661 var data-ah/eax: (addr handle array handle cell) <- get first, array-data
3662 var data/eax: (addr array handle cell) <- lookup *data-ah
3664 var len/eax: int <- length data
3667 error trace, "index: too few elements in array"
3675 var offset/edx: (offset handle cell) <- compute-offset data, index
3676 var src/eax: (addr handle cell) <- index data, offset
3677 copy-object src, out
3680 fn apply-iset _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3681 trace-text trace, "eval", "apply 'iset'"
3682 var args-ah/eax: (addr handle cell) <- copy _args-ah
3683 var _args/eax: (addr cell) <- lookup *args-ah
3684 var args/esi: (addr cell) <- copy _args
3686 var args-type/eax: (addr int) <- get args, type
3687 compare *args-type, 0/pair
3689 error trace, "args to 'iset' are not a list"
3692 var empty-args?/eax: boolean <- nil? args
3693 compare empty-args?, 0/false
3696 error trace, "'iset' needs 3 args but got 0"
3699 # array = args->left
3700 var first-ah/eax: (addr handle cell) <- get args, left
3701 var first/eax: (addr cell) <- lookup *first-ah
3703 var first-type/eax: (addr int) <- get first, type
3704 compare *first-type, 7/array
3706 error trace, "first arg for 'iset' is not an array"
3709 var array-ah/eax: (addr handle array handle cell) <- get first, array-data
3710 var _array/eax: (addr array handle cell) <- lookup *array-ah
3711 var array/ecx: (addr array handle cell) <- copy _array
3712 # idx = args->right->left->value
3713 var rest-ah/eax: (addr handle cell) <- get args, right
3714 var _rest/eax: (addr cell) <- lookup *rest-ah
3715 var rest/esi: (addr cell) <- copy _rest
3717 var rest-type/eax: (addr int) <- get rest, type
3718 compare *rest-type, 0/pair
3720 error trace, "'iset' encountered non-pair"
3724 var rest-nil?/eax: boolean <- nil? rest
3725 compare rest-nil?, 0/false
3727 error trace, "'iset' needs 3 args but got 1"
3730 var second-ah/eax: (addr handle cell) <- get rest, left
3731 var second/eax: (addr cell) <- lookup *second-ah
3733 var second-type/eax: (addr int) <- get second, type
3734 compare *second-type, 1/number
3736 error trace, "second arg for 'iset' is not an int (index)"
3739 var second-value/eax: (addr float) <- get second, number-data
3740 var idx/eax: int <- truncate *second-value
3741 # offset based on idx after bounds check
3742 var max/edx: int <- length array
3746 error trace, "iset: too few elements in array"
3749 var offset/edx: (offset handle cell) <- compute-offset array, idx
3750 # val = rest->right->left
3751 var rest-ah/eax: (addr handle cell) <- get rest, right
3752 var _rest/eax: (addr cell) <- lookup *rest-ah
3755 var rest-type/eax: (addr int) <- get rest, type
3756 compare *rest-type, 0/pair
3758 error trace, "'iset' encountered non-pair"
3762 var rest-nil?/eax: boolean <- nil? rest
3763 compare rest-nil?, 0/false
3765 error trace, "'iset' needs 3 args but got 2"
3768 var val-ah/eax: (addr handle cell) <- get rest, left
3770 var dest/edi: (addr handle cell) <- index array, offset
3771 copy-object val-ah, dest
3775 fn apply-render-image _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {
3776 trace-text trace, "eval", "apply 'img'"
3777 var args-ah/eax: (addr handle cell) <- copy _args-ah
3778 var _args/eax: (addr cell) <- lookup *args-ah
3779 var args/esi: (addr cell) <- copy _args
3781 var args-type/eax: (addr int) <- get args, type
3782 compare *args-type, 0/pair
3784 error trace, "args to 'img' are not a list"
3787 var empty-args?/eax: boolean <- nil? args
3788 compare empty-args?, 0/false
3791 error trace, "'img' needs 6 args but got 0"
3794 # screen = args->left
3795 var first-ah/eax: (addr handle cell) <- get args, left
3796 var first/eax: (addr cell) <- lookup *first-ah
3798 var first-type/eax: (addr int) <- get first, type
3799 compare *first-type, 5/screen
3801 error trace, "first arg for 'img' is not a screen"
3804 var screen-ah/eax: (addr handle screen) <- get first, screen-data
3805 var _screen/eax: (addr screen) <- lookup *screen-ah
3806 var screen/edi: (addr screen) <- copy _screen
3807 # x1 = args->right->left->value
3808 var rest-ah/eax: (addr handle cell) <- get args, right
3809 var _rest/eax: (addr cell) <- lookup *rest-ah
3810 var rest/esi: (addr cell) <- copy _rest
3812 var rest-type/eax: (addr int) <- get rest, type
3813 compare *rest-type, 0/pair
3815 error trace, "'img' encountered non-pair"
3819 var rest-nil?/eax: boolean <- nil? rest
3820 compare rest-nil?, 0/false
3822 error trace, "'img' needs 6 args but got 1"
3825 var second-ah/eax: (addr handle cell) <- get rest, left
3826 var second/eax: (addr cell) <- lookup *second-ah
3828 var second-type/eax: (addr int) <- get second, type
3829 compare *second-type, 3/stream
3831 error trace, "second arg for 'img' is not a stream (image data in ascii netpbm)"
3834 var img-data-ah/eax: (addr handle stream byte) <- get second, text-data
3835 var img-data/eax: (addr stream byte) <- lookup *img-data-ah
3836 var img-h: (handle cell)
3837 var img-ah/ecx: (addr handle cell) <- address img-h
3838 new-image img-ah, img-data
3839 # x = rest->right->left->value
3840 var rest-ah/eax: (addr handle cell) <- get rest, right
3841 var _rest/eax: (addr cell) <- lookup *rest-ah
3844 var rest-type/eax: (addr int) <- get rest, type
3845 compare *rest-type, 0/pair
3847 error trace, "'img' encountered non-pair"
3851 var rest-nil?/eax: boolean <- nil? rest
3852 compare rest-nil?, 0/false
3854 error trace, "'img' needs 6 args but got 2"
3857 var third-ah/eax: (addr handle cell) <- get rest, left
3858 var third/eax: (addr cell) <- lookup *third-ah
3860 var third-type/eax: (addr int) <- get third, type
3861 compare *third-type, 1/number
3863 error trace, "third arg for 'img' is not a number (screen x coordinate of top left)"
3866 var third-value/eax: (addr float) <- get third, number-data
3867 var x/ebx: int <- convert *third-value
3868 # y = rest->right->left->value
3869 var rest-ah/eax: (addr handle cell) <- get rest, right
3870 var _rest/eax: (addr cell) <- lookup *rest-ah
3871 var rest/esi: (addr cell) <- copy _rest
3873 var rest-type/eax: (addr int) <- get rest, type
3874 compare *rest-type, 0/pair
3876 error trace, "'img' encountered non-pair"
3880 var rest-nil?/eax: boolean <- nil? rest
3881 compare rest-nil?, 0/false
3883 error trace, "'img' needs 6 args but got 3"
3886 var fourth-ah/eax: (addr handle cell) <- get rest, left
3887 var fourth/eax: (addr cell) <- lookup *fourth-ah
3889 var fourth-type/eax: (addr int) <- get fourth, type
3890 compare *fourth-type, 1/number
3892 error trace, "fourth arg for 'img' is not a number (screen x coordinate of end point)"
3895 var fourth-value/eax: (addr float) <- get fourth, number-data
3896 var y/ecx: int <- convert *fourth-value
3897 # w = rest->right->left->value
3898 var rest-ah/eax: (addr handle cell) <- get rest, right
3899 var _rest/eax: (addr cell) <- lookup *rest-ah
3902 var rest-type/eax: (addr int) <- get rest, type
3903 compare *rest-type, 0/pair
3905 error trace, "'img' encountered non-pair"
3909 var rest-nil?/eax: boolean <- nil? rest
3910 compare rest-nil?, 0/false
3912 error trace, "'img' needs 6 args but got 4"
3915 var fifth-ah/eax: (addr handle cell) <- get rest, left
3916 var fifth/eax: (addr cell) <- lookup *fifth-ah
3918 var fifth-type/eax: (addr int) <- get fifth, type
3919 compare *fifth-type, 1/number
3921 error trace, "fifth arg for 'img' is not a number (screen y coordinate of end point)"
3924 var fifth-value/eax: (addr float) <- get fifth, number-data
3925 var tmp/eax: int <- convert *fifth-value
3928 # h = rest->right->left->value
3929 var rest-ah/eax: (addr handle cell) <- get rest, right
3930 var _rest/eax: (addr cell) <- lookup *rest-ah
3933 var rest-type/eax: (addr int) <- get rest, type
3934 compare *rest-type, 0/pair
3936 error trace, "'img' encountered non-pair"
3940 var rest-nil?/eax: boolean <- nil? rest
3941 compare rest-nil?, 0/false
3943 error trace, "'img' needs 6 args but got 5"
3946 var sixth-ah/eax: (addr handle cell) <- get rest, left
3947 var sixth/eax: (addr cell) <- lookup *sixth-ah
3949 var sixth-type/eax: (addr int) <- get sixth, type
3950 compare *sixth-type, 1/number
3952 error trace, "sixth arg for 'img' is not an int (height)"
3955 var sixth-value/eax: (addr float) <- get sixth, number-data
3956 var tmp/eax: int <- convert *sixth-value
3960 var img-cell-ah/eax: (addr handle cell) <- address img-h
3961 var img-cell/eax: (addr cell) <- lookup *img-cell-ah
3962 var img-ah/eax: (addr handle image) <- get img-cell, image-data
3963 var img/eax: (addr image) <- lookup *img-ah
3964 render-image screen, img, x y, w h
3968 fn apply-abort _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) {