https://github.com/akkartik/mu/blob/main/apps/texture.mu
1
2
3
4
5
6
7
8
9 fn main -> _/ebx: int {
10
11
12 var width/esi: int <- copy 0xff
13 var height/edi: int <- copy 0xff
14 print-string 0, "P3\n"
15 print-int32-decimal 0, width
16 print-string 0, " "
17 print-int32-decimal 0, height
18 print-string 0, "\n"
19 print-string 0, "255\n"
20 var row/ecx: int <- copy 0
21 {
22 compare row, height
23 break-if->=
24 var col/edx: int <- copy 0
25 {
26 compare col, width
27 break-if->=
28
29 var tmp/eax: int <- copy col
30 tmp <- multiply row
31 tmp <- and 0x7f
32 tmp <- add 0x80
33 tmp <- copy 0xff
34 print-int32-decimal 0, tmp
35 print-string 0, " "
36
37 tmp <- copy row
38 tmp <- multiply col
39 tmp <- and 0x7f
40 tmp <- add 0x80
41
42 print-int32-decimal 0, tmp
43 print-string 0, " "
44
45 tmp <- copy row
46 tmp <- multiply col
47 tmp <- and 0x7f
48 tmp <- add 0x80
49 print-int32-decimal 0, tmp
50 print-string 0, "\n"
51 col <- increment
52 loop
53 }
54 row <- increment
55 loop
56 }
57 return 0
58 }