Skip to content

Commit

Permalink
improve "Hello, World." examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dalnefre committed Jan 25, 2025
1 parent 96822fb commit f936911
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
6 changes: 2 additions & 4 deletions apps/debugger/examples/hello.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.import
dev: "https://ufork.org/lib/dev.asm"
std: "https://ufork.org/lib/std.asm"

hello: ; +72,+101,+108,+108,+111,+63,+10,#nil
pair_t 'H'
Expand All @@ -18,11 +19,8 @@ boot: ; _ <- {caps}
msg 0 ; value {caps}
push dev.debug_key ; value {caps} dev.debug_key
dict get ; value debug_dev
; msg 0 ; ... debug_dev {caps}
; push dev.clock_key ; ... debug_dev {caps} dev.clock_key
; dict get ; ... cust=debug_dev clock_dev
actor send ; --
end commit
ref std.commit

.export
boot
35 changes: 21 additions & 14 deletions apps/debugger/examples/hello_io.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ hello: ; +72,+101,+108,+108,+111,+63,+10,#nil
pair_t '\n'
ref #nil

str_out: ; cb,out,str <- result
str_out: ; cb,out,str <- ok,value
msg 1 ; ok
if_not str_end ; --

state -2 ; str
typeq #pair_t ; is_pair(str)
if_not str_end
if_not str_end ; --

state 0 ; cb,out,str
part 3 ; rest first out cb
Expand All @@ -33,22 +36,26 @@ str_out: ; cb,out,str <- result
ref std.commit

str_end: ; --
msg 0 ; result
state 1 ; result cb
msg 0 ; ok,value
state 1 ; ok,value cb
ref std.send_msg

boot: ; _ <- {caps}
push #? ; #?
push hello ; #? str
msg 0 ; #? str {caps}
push dev.io_key ; #? str {caps} dev.io_key
dict get ; #? str io_dev
push #? ; #? str io_dev #?
push std.sink_beh ; #? str io_dev #? sink_beh
actor create ; #? str out=io_dev cb=sink_beh.#?
pair 2 ; #? cb,out,str
push str_out ; #? cb,out,str str_out
actor create ; #? str_out.cb,out,str
push #t ; #t
pair 1 ; #t,#?

push hello ; #t,#? str
msg 0 ; #t,#? str {caps}
push dev.io_key ; #t,#? str {caps} dev.io_key
dict get ; #t,#? str io_dev
push #? ; #t,#? str io_dev #?
push std.sink_beh ; #t,#? str io_dev #? sink_beh
actor create ; #t,#? str out=io_dev cb=sink_beh.#?

pair 2 ; #t,#? cb,out,str
push str_out ; #t,#? cb,out,str str_out
actor create ; #t,#? str_out.cb,out,str
ref std.send_msg

.export
Expand Down

0 comments on commit f936911

Please sign in to comment.