diff options
Diffstat (limited to 'quine.asm')
| -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. |