https://github.com/akkartik/mu/blob/main/linux/raytracing/color.mu

     1 type rgb {
     2   # components normalized to within [0.0, 1.0]
     3   r: float
     4   g: float
     5   b: float
     6 }
     7
     8 # print translating to [0, 256)
     9 fn print-rgb screen: (addr screen), _c: (addr rgb) {
    10   var c/esi: (addr rgb) <- copy _c
    11   var xn: float
    12   var xn-addr/ecx: (addr float) <- address xn
    13   fill-in-rational xn-addr, 0x3e7ff, 0x3e8  # 255999 / 1000
    14   # print 255.999 * c->r
    15   var result/xmm0: float <- copy xn
    16   var src-addr/eax: (addr float) <- get c, r
    17   result <- multiply *src-addr
    18   var result-int/edx: int <- truncate result
    19   print-int32-decimal screen, result-int
    20   print-string screen, " "
    21   # print 255.999 * c->g
    22   src-addr <- get c, g
    23   result <- copy xn
    24   result <- multiply *src-addr
    25   result-int <- truncate result
    26   print-int32-decimal screen, result-int
    27   print-string screen, " "
    28   # print 255.999 * c->b
    29   src-addr <- get c, b
    30   result <- copy xn
    31   result <- multiply *src-addr
    32   result-int <- truncate result
    33   print-int32-decimal screen, result-int
    34   print-string screen, "\n"
    35 }