diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-01-09 18:28:27 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-01-09 18:29:04 -0800 |
commit | 0518944e379f343542c872a20d3d5a2aee744297 (patch) | |
tree | c79fa2a0dd3a45c61f835796fb0b5f74f58c23d5 /baremetal | |
parent | 7f8770ae082a723faae89faea0dce6635feb7cdb (diff) | |
download | mu-0518944e379f343542c872a20d3d5a2aee744297.tar.gz |
7491 - baremetal: draw ASCII text to screen
Diffstat (limited to 'baremetal')
-rw-r--r-- | baremetal/313index-bounds-check.subx | 11 | ||||
-rw-r--r-- | baremetal/401draw-text-rightward.mu | 16 | ||||
-rw-r--r-- | baremetal/ex5.mu | 14 |
3 files changed, 41 insertions, 0 deletions
diff --git a/baremetal/313index-bounds-check.subx b/baremetal/313index-bounds-check.subx new file mode 100644 index 00000000..8380d741 --- /dev/null +++ b/baremetal/313index-bounds-check.subx @@ -0,0 +1,11 @@ +# TODO: bring this back + +__check-mu-array-bounds: # index: int, elem-size: int, arr-size: int, function-name: (addr array byte), array-name: (addr array byte) + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp +$__check-mu-array-bounds:end: + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return diff --git a/baremetal/401draw-text-rightward.mu b/baremetal/401draw-text-rightward.mu new file mode 100644 index 00000000..089c5d5c --- /dev/null +++ b/baremetal/401draw-text-rightward.mu @@ -0,0 +1,16 @@ +fn draw-text-rightward screen: (addr screen), _text: (addr array byte), x: int, y: int, color: int { + var text/esi: (addr array byte) <- copy _text + var len/ecx: int <- length text + var i/edx: int <- copy 0 + { + compare i, len + break-if->= + var g/eax: (addr byte) <- index text, i + var g2/eax: byte <- copy-byte *g + var g3/eax: grapheme <- copy g2 + draw-grapheme screen, g3, x, y, color + add-to x, 8 # font-width + i <- increment + loop + } +} diff --git a/baremetal/ex5.mu b/baremetal/ex5.mu new file mode 100644 index 00000000..30e5b69c --- /dev/null +++ b/baremetal/ex5.mu @@ -0,0 +1,14 @@ +# Draw an ASCII string using the built-in font (GNU unifont) +# +# To build a disk image: +# ./translate_mu_baremetal baremetal/ex5.mu # emits disk.img +# To run: +# qemu-system-i386 disk.img +# Or: +# bochs -f baremetal/boot.bochsrc # boot.bochsrc loads disk.img +# +# Expected output: text in green near the top-left corner of screen + +fn main { + draw-text-rightward 0, "hello from baremetal Mu!", 0x10, 0x10, 0xa +} |