Skip to content

Commit

Permalink
some printing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
danmey committed Mar 23, 2010
1 parent 48c0a14 commit 53b1a6b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
18 changes: 17 additions & 1 deletion bootstrap.4k
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ variable #section
: 0= 0 = ;
: cr 10 emit ;
: space 32 emit ;
: . . space ;


: begin here@ ; immediate

Expand Down Expand Up @@ -375,3 +375,19 @@ variable #ithere
| dump



variable savebase
base @ savebase !
16 const b16
10 const b10

: base! base @ savebase ! base ! ;
: hex b16 base! ;
: dec b10 base! ;
: [hex] hex ; immediate
: [dec] dec ; immediate
: switch-base savebase @ base ! ;

: [switch-base] res-base ; immediate

| : . . space ;
13 changes: 13 additions & 0 deletions print.4k
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
forget mark

variable pad
0 pad !
variable pad-frac
0 pad-frac

: r1+ postpone r> postpone 1+ postpone >r ; immediate
: n[ -1 -1 ;
: %n dup -1 <> if pad ! dup -1 <> if pad-frac ! else drop then else drop then ;
: .n dup dup 0= if 1 ;; then 0 >r begin dup 0 <> while 10 / r> 1 + >r repeat drop r>
pad @ swap - dup 0 > if 1 do 0 . loop else drop then . ;
: ]n begin dup -1 = while drop repeat ;
2 changes: 1 addition & 1 deletion src/4k.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ ifdef([DEBUG],[
next_word:
jmp .fetchbyte # this is called by every asm word at the end

fmt_dec: .ASCIZ "%d\n"
fmt_dec: .ASCIZ "%d"


include(import.m4)
Expand Down

0 comments on commit 53b1a6b

Please sign in to comment.