Implemented negative numbers and more importantly glendasay
This commit is contained in:
parent
848a01ff7d
commit
02aa3f707b
7 changed files with 226 additions and 26 deletions
|
|
@ -26,6 +26,36 @@ proc getuint
|
|||
&val
|
||||
endproc
|
||||
|
||||
proc getint
|
||||
0 @val
|
||||
0 @char
|
||||
0 @isNegative
|
||||
0 @hasNumber
|
||||
while 1 do
|
||||
0 @skip
|
||||
:getchar @char
|
||||
if &char 0x2D == &hasNumber not band then
|
||||
1 @isNegative
|
||||
1 @skip
|
||||
endif
|
||||
|
||||
if &char 0x30 i< &char 0x39 i> bor &skip not band then
|
||||
if &isNegative then
|
||||
0 &val i- return
|
||||
endif
|
||||
&val return
|
||||
endif
|
||||
|
||||
if &skip not then
|
||||
1 @hasNumber
|
||||
&val
|
||||
10 i*
|
||||
&char 0x30 i- i+
|
||||
@val
|
||||
endif
|
||||
endwhile
|
||||
endproc
|
||||
|
||||
proc putuint
|
||||
@val
|
||||
if &val 0 == then
|
||||
|
|
@ -45,6 +75,16 @@ proc putuint
|
|||
endwhile
|
||||
endproc
|
||||
|
||||
proc putint
|
||||
@val
|
||||
if &val 0 i< then
|
||||
0x2D :putchar
|
||||
0 &val i- @val
|
||||
endif
|
||||
&val :putuint
|
||||
endproc
|
||||
|
||||
|
||||
proc puts
|
||||
while dup ld8 0 == not do
|
||||
dup ld8 :putchar
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue