https://github.com/akkartik/mu/blob/main/316colors.subx
  1 # Some information about the default palette of 256 colors provided by the
  2 # BIOS on x86 computers.
  3 
  4 == code
  5 
  6 # Return the r/g/b for color [0, 256) in ecx/edx/ebx respectively.
  7 color-rgb:  # color: int -> _/ecx: int, _/edx: int, _/ebx: int
  8     # . prologue
  9     55/push-ebp
 10     89/<- %ebp 4/r32/esp
 11     # . save registers
 12     50/push-eax
 13     56/push-esi
 14     # esi = color
 15     8b/-> *(ebp+8) 6/r32/esi
 16     #
 17     81 7/subop/compare %esi 0x100/imm32
 18     {
 19       7c/jump-if-< break/disp8
 20       (abort "invalid color")
 21     }
 22     # var color/esi: int = Colors-rgb[color]
 23     b8/copy-to-eax Colors-rgb/imm32
 24     8b/-> *(eax+esi<<2+4) 6/r32/esi
 25     # var red/ecx: int = color & 0xff
 26     89/<- %eax 6/r32/esi
 27     25/and-eax-with 0xff/imm32
 28     89/<- %ecx 0/r32/eax
 29     # var green/edx: int = (color >> 8) & 0xff
 30     89/<- %eax 6/r32/esi
 31     c1 5/subop/shift-right-logical %eax 8/imm8
 32     25/and-eax-with 0xff/imm32
 33     89/<- %edx 0/r32/eax
 34     # var blue/ebx: int = (color >> 16)
 35     89/<- %eax 6/r32/esi
 36     c1 5/subop/shift-right-logical %eax 0x10/imm8
 37     89/<- %ebx 0/r32/eax
 38 $colors-rgb:end:
 39     # . restore registers
 40     5e/pop-to-esi
 41     58/pop-to-eax
 42     # . epilogue
 43     89/<- %esp 5/r32/ebp
 44     5d/pop-to-ebp
 45     c3/return
 46 
 47 test-color-rgb:
 48     # . prologue
 49     55/push-ebp
 50     89/<- %ebp 4/r32/esp
 51     #
 52     (color-rgb 0x10)  # => eax ecx edx
 53     (check-ints-equal %ecx 0 "F - test-color-rgb/0x10/r")
 54     (check-ints-equal %edx 0 "F - test-color-rgb/0x10/g")
 55     (check-ints-equal %ebx 0 "F - test-color-rgb/0x10/b")
 56     (color-rgb 1)  # => eax ecx edx
 57     (check-ints-equal %ecx 0 "F - test-color-rgb/1/r")
 58     (check-ints-equal %edx 0 "F - test-color-rgb/1/g")
 59     (check-ints-equal %ebx 0xaa "F - test-color-rgb/1/b")
 60     (color-rgb 0xf)  # => eax ecx edx
 61     (check-ints-equal %ecx 0xff "F - test-color-rgb/0xf/r")
 62     (check-ints-equal %edx 0xff "F - test-color-rgb/0xf/g")
 63     (check-ints-equal %ebx 0xff "F - test-color-rgb/0xf/b")
 64     # . epilogue
 65     89/<- %esp 5/r32/ebp
 66     5d/pop-to-ebp
 67     c3/return
 68 
 69 == data
 70 
 71 Colors-rgb:
 72   0x400/imm32
 73   00 00 00 00
 74   00 00 aa 00
 75   00 aa 00 00
 76   00 aa aa 00
 77   aa 00 00 00
 78   aa 00 aa 00
 79   aa 55 00 00
 80   aa aa aa 00
 81   55 55 55 00
 82   55 55 ff 00
 83   55 ff 55 00
 84   55 ff ff 00
 85   ff 55 55 00
 86   ff 55 ff 00
 87   ff ff 55 00
 88   ff ff ff 00
 89   00 00 00 00
 90   14 14 14 00
 91   20 20 20 00
 92   2c 2c 2c 00
 93   38 38 38 00
 94   45 45 45 00
 95   51 51 51 00
 96   61 61 61 00
 97   71 71 71 00
 98   82 82 82 00
 99   92 92 92 00
100   a2 a2 a2 00
101   b6 b6 b6 00
102   cb cb cb 00
103   e3 e3 e3 00
104   ff ff ff 00
105   00 00 ff 00
106   41 00 ff 00
107   7d 00 ff 00
108   be 00 ff 00
109   ff 00 ff 00
110   ff 00 be 00
111   ff 00 7d 00
112   ff 00 41 00
113   ff 00 00 00
114   ff 41 00 00
115   ff 7d 00 00
116   ff be 00 00
117   ff ff 00 00
118   be ff 00 00
119   7d ff 00 00
120   41 ff 00 00
121   00 ff 00 00
122   00 ff 41 00
123   00 ff 7d 00
124   00 ff be 00
125   00 ff ff 00
126   00 be ff 00
127   00 7d ff 00
 *, const char *, size_t);

char   *fgetln(FILE *, size_t *);
char   *fparseln(FILE *, size_t *, size_t *, const char [3], int);

long long strtonum(const char *, long long, long long, const char **);

int	fmt_scaled(long long number, char *result);

#ifndef WAIT_ANY
#define WAIT_ANY		(-1)
#endif

/* there is no limit to ulrich drepper's crap */
#ifndef TAILQ_END
#define	TAILQ_END(head)			NULL
#endif

#ifndef TAILQ_FOREACH_SAFE
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
	for ((var) = TAILQ_FIRST(head);                                 \
	    (var) != TAILQ_END(head) &&                                 \
	    ((tvar) = TAILQ_NEXT(var, field), 1);                       \
	    (var) = (tvar))
#endif

/*
 * fmt_scaled(3) specific flags. (from OpenBSD util.h)
 */
#define FMT_SCALED_STRSIZE	7	/* minus sign, 4 digits, suffix, null byte */

int getpeereid(int s, uid_t *euid, gid_t *gid);
id="L204" class="LineNr">204 61 38 71 00 205 71 38 71 00 206 71 38 61 00 207 71 38 55 00 208 71 38 45 00 209 71 38 38 00 210 71 45 38 00 211 71 55 38 00 212 71 61 38 00 213 71 71 38 00 214 61 71 38 00 215 55 71 38 00 216 45 71 38 00 217 38 71 38 00 218 38 71 45 00 219 38 71 55 00 220 38 71 61 00 221 38 71 71 00 222 38 61 71 00 223 38 55 71 00 224 38 45 71 00 225 51 51 71 00 226 59 51 71 00 227 61 51 71 00 228 69 51 71 00 229 71 51 71 00 230 71 51 69 00 231 71 51 61 00 232 71 51 59 00 233 71 51 51 00 234 71 59 51 00 235 71 61 51 00 236 71 69 51 00 237 71 71 51 00 238 69 71 51 00 239 61 71 51 00 240 59 71 51 00 241 51 71 51 00 242 51 71 59 00 243 51 71 61 00 244 51 71 69 00 245 51 71 71 00 246 51 69 71 00 247 51 61 71 00 248 51 59 71 00 249 00 00 41 00 250 10 00 41 00 251 20 00 41 00 252 30 00 41 00 253 41 00 41 00 254 41 00 30 00 255 41 00 20 00 256 41 00 10 00 257 41 00 00 00 258 41 10 00 00 259 41 20 00 00 260 41 30 00 00 261 41 41 00 00 262 30 41 00 00 263 20 41 00 00 264 10 41 00 00 265 00 41 00 00 266 00 41 10 00 267 00 41 20 00 268 00 41 30 00 269 00 41 41 00 270 00 30 41 00 271 00 20 41 00 272 00 10 41 00 273 20 20 41 00 274 28 20 41 00 275 30 20 41 00 276 38 20 41 00 277 41 20 41 00 278 41 20 38 00 279 41 20 30 00 280 41 20 28 00 281 41 20 20 00 282 41 28 20 00 283 41 30 20 00 284 41 38 20 00 285 41 41 20 00 286 38 41 20 00 287 30 41 20 00 288 28 41 20 00 289 20 41 20 00 290 20 41 28 00 291 20 41 30 00 292 20 41 38 00 293 20 41 41 00 294 20 38 41 00 295 20 30 41 00 296 20 28 41 00 297 2c 2c 41 00 298 30 2c 41 00 299 34 2c 41 00 300 3c 2c 41 00 301 41 2c 41 00 302 41 2c 3c 00 303 41 2c 34 00 304 41 2c 30 00 305 41 2c 2c 00 306 41 30 2c 00 307 41 34 2c 00 308 41 3c 2c 00 309 41 41 2c 00 310 3c 41 2c 00 311 34 41 2c 00 312 30 41 2c 00 313 2c 41 2c 00 314 2c 41 30 00 315 2c 41 34 00 316 2c 41 3c 00 317 2c 41 41 00 318 2c 3c 41 00 319 2c 34 41 00 320 2c 30 41 00 321 00 00 00 00 322 00 00 00 00 323 00 00 00 00 324 00 00 00 00 325 00 00 00 00 326 00 00 00 00 327 00 00 00 00 328 00 00 00 00