From 5efca3695a1f4261020c793c8474f5d62af0b010 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 9 Jan 2021 08:11:52 -0800 Subject: 7482 --- html/407right-justify.mu.html | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 html/407right-justify.mu.html (limited to 'html/407right-justify.mu.html') diff --git a/html/407right-justify.mu.html b/html/407right-justify.mu.html new file mode 100644 index 00000000..460f9def --- /dev/null +++ b/html/407right-justify.mu.html @@ -0,0 +1,76 @@ + + + + +Mu - 407right-justify.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/407right-justify.mu +
+ 1 # print 'n' with enough leading spaces to be right-justified in 'width'
+ 2 fn right-justify screen: (addr screen), n: int, _width: int {
+ 3   # tweak things for negative numbers
+ 4   var n-width/eax: int <- decimal-size n
+ 5   var width/ecx: int <- copy _width
+ 6   {
+ 7     compare n-width, width
+ 8     break-if->=
+ 9     print-grapheme screen, 0x20  # space
+10     width <- decrement
+11     loop
+12   }
+13   print-int32-decimal screen, n
+14 }
+
+ + + -- cgit 1.4.1-2-gfad0