projects
/
vvhitespace
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6b5e4b3
)
Updated `printmagnitudeofnumber` to handle most negative number.
author
Aaron Taylor
<ataylor@subgeniuskitty.com>
Wed, 31 Jul 2019 21:38:15 +0000
(14:38 -0700)
committer
Aaron Taylor
<ataylor@subgeniuskitty.com>
Wed, 31 Jul 2019 21:38:15 +0000
(14:38 -0700)
stdlib/stdio.pvvs
patch
|
blob
|
blame
|
history
diff --git
a/stdlib/stdio.pvvs
b/stdlib/stdio.pvvs
index
54bb2ac
..
8637d67
100644
(file)
--- a/
stdlib/stdio.pvvs
+++ b/
stdlib/stdio.pvvs
@@
-97,8
+97,17
@@
NTN | RTS
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#include <math.pvvs>
NSSVTSSSSTTN | Mark: 1000011 (print magnitude of number from stack)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#include <math.pvvs>
NSSVTSSSSTTN | Mark: 1000011 (print magnitude of number from stack)
-NSTTSSSTN | JSR > 10001 (absolute value)
+@ Catch -(2^63) as a special case since its absolute value will overflow
+@ a twos-complement 64-bit word.
+SNS | DUP
+SSTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSN | -(2^63)
+TSST | SUBTRACT
+NTSSTSSSSTTSSSSSSTSN | BRZ > 01000011 00000010
+
+@ No special case applies. Prepare for computation by converting the number
+@ to absolute value and preparing a string on the stack.
+NSTTSSSTN | JSR > 10001 (absolute value)
SSSSN | PUSH ASCII '\0'
SNT | SWAP
SSSSN | PUSH ASCII '\0'
SNT | SWAP
@@
-126,6
+135,12
@@
SNN | DROP
NSTTSSSTSSN | JSR > 1000100 (print string from stack)
NTN | RTS
NSTTSSSTSSN | JSR > 1000100 (print string from stack)
NTN | RTS
+@ Replace the number on the stack with its decimal ASCII representation.
+NSSVSTSSSSTTSSSSSSTSN | BRZ > 01000011 00000010
+SNN | DROP
+A"-9223372036854775808"
+NSNSTSSSSTTSSSSSSSTN | JMP > 01000011 00000001
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Name:
@ printf
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Name:
@ printf