https://github.com/akkartik/mu/blob/main/508circle.mu
 1 fn draw-circle screen: (addr screen), cx: int, cy: int, radius: int, color: int {
 2   var x: int
 3   var y: int
 4   var err: int
 5   # x = -r
 6   var tmp/eax: int <- copy radius
 7   tmp <- negate
 8   copy-to x, tmp
 9   # err = 2 - 2*r
10   tmp <- copy radius
11   tmp <- shift-left 1
12   tmp <- negate
13   tmp <- add 2
14   copy-to err, tmp
15   #
16   var tmpx/ecx: int <- copy 0
17   var tmpy/edx: int <- copy 0
18   {
19     # pixel(cx-x, cy+y)
20     tmpx <- copy cx
21     tmpx <- subtract x
22     tmpy <- copy cy
23     tmpy <- add y
24     pixel screen, tmpx, tmpy, color
25     # pixel(cx-y, cy-x)
26     tmpx <- copy cx
27     tmpx <- subtract y
28     tmpy <- copy cy
29     tmpy <- subtract x
30     pixel screen, tmpx, tmpy, color
31     # pixel(cx+x, cy-y)
32     tmpx <- copy cx
33     tmpx <- add x
34     tmpy <- copy cy
35     tmpy <- subtract y
36     pixel screen, tmpx, tmpy, color
37     # pixel(cx+y, cy+x)
38     tmpx <- copy cx
39     tmpx <- add y
40     tmpy <- copy cy
41     tmpy <- add x
42     pixel screen, tmpx, tmpy, color
43     # r = err
44     tmp <- copy err
45     copy-to radius, tmp
46     # if (r <= y) { ++y; err += (y*2 + 1); }
47     {
48       tmpy <- copy y
49       compare radius, tmpy
50       break-if->
51       increment y
52       tmpy <- copy y
53       tmpy <- shift-left 1
54       tmpy <- increment
55       add-to err, tmpy
56     }
57     # if (r > x || err > y) { ++x; err += (x*2 + 1); }
58     $draw-circle:second-check: {
59       {
60         tmpx <- copy x
61         compare radius, tmpx
62         break-if->
63         tmpy <- copy y
64         compare err, tmpy
65         break-if->
66         break $draw-circle:second-check
67       }
68       increment x
69       tmpx <- copy x
70       tmpx <- shift-left 1
71       tmpx <- increment
72       add-to err, tmpx
73     }
74     # loop termination condition
75     compare x, 0
76     loop-if-<
77   }
78 }
79 
80 fn draw-disc screen: (addr screen), cx: int, cy: int, radius: int, color: int, border-color: int {
81   var r/eax: int <- copy 0
82   {
83     compare r, radius
84     break-if->=
85     draw-circle screen, cx cy, r, color
86     r <- increment
87     loop
88   }
89   draw-circle screen, cx cy, r, border-color
90 }