diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-04-05 09:36:16 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-04-05 09:37:40 -0700 |
| commit | 1c18c7b90b64563c884cee5f74c2799e885f3ba5 (patch) | |
| tree | cae0b6c8889e6a5da87e2f8466e4d82ac3b8c9c1 | |
| parent | d0719919ed754048263c6dd7845c6ae67504e8e8 (diff) | |
add width-padded variants of dot
Force-Push: yes Change-Id: Idba4d4bc1f77a6dc34196673d7760461f9f99bb8
| -rw-r--r-- | quine.asm | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/quine.asm b/quine.asm index 5c5f95b..66bb2cd 100644 --- a/quine.asm +++ b/quine.asm @@ -3773,7 +3773,15 @@ defword emitstring, 0 defword dot, 0 dq docol, lit, 10, dotbase, exit defword dothex, 0 - dq docol, lit, 16, dotbase_unsigned, exit + dq docol, lit, 16, lit, 0, dotbase_unsigned, exit +defword dothex8, 0 + dq docol, lit, 16, lit, 2, dotbase_unsigned, exit +defword dothex16, 0 + dq docol, lit, 16, lit, 4, dotbase_unsigned, exit +defword dothex32, 0 + dq docol, lit, 16, lit, 8, dotbase_unsigned, exit +defword dothex64, 0 + dq docol, lit, 16, lit, 16, dotbase_unsigned, exit ; In: ; integer to print @@ -3789,18 +3797,27 @@ defword dotbase, 0 dq lit, -1, mul dq litstring, "-", emitstring - dq swap, dotbase_unsigned, exit + dq swap, lit, 0, dotbase_unsigned, exit ; In: ; integer to print ; base to print in +; width to zero-pad to defword dotbase_unsigned, 0 dq docol - ; (input, base) + ; (input, base, width) ; Compute how many digits we need to display. Because we use logfloor, the ; logic of always printing at least one digit is already handled for us. - dq swap, dup2, logfloor, lit, 1, add + dq unroll3, swap, dup2, logfloor, lit, 1, add + ; (width, base, input, number of digits if no padding) + dq lit, 4, roll, dup2, gt, zbranch, 5*8 + ; (base, input, number of digits if no padding, width) + ; If we're here, we should use the padded width + dq swap, drop, branch, 2*8 + ; (base, input, number of digits if no padding, width) + ; If we're here, we should use the unpadded width + dq drop ; (base, input, number of digits remaining) ; This is the start of the loop. |