home *** CD-ROM | disk | FTP | other *** search
- !
- ! echo command line arguments
- !
- add %sp,64,%l0
- ld [%l0],%l1 ! argc
- inc 4,%l0
- L1:
- call print_string
- ld [%l0],%o0
- deccc %l1
- bg L1
- inc 4,%l0
-
- ld [%sp+64],%o0 ! exit with status = argc
- mov 1,%g1
- ta 0
- nop
-
- .seg "data"
- cr:
- .ascii "\n"
-
- .seg "text"
- !
- ! write string pointed to by %o0 to stdout,
- ! followed by newline
- !
- print_string:
- save %sp,-96,%sp
- call strlen
- mov %i0,%o0
- mov %o0,%o2 ! length count
- mov 1,%o0 ! write to stdout
- mov %i0,%o1 ! buffer
- mov 4,%g1
- ta 0
- mov 1,%o0 ! now write newline
- set cr,%o1
- mov 1,%o2 ! 1 byte
- ta 0
- ret
- restore
-
- !
- ! determine length of string pointed to by %o0
- !
- strlen:
- mov %o0,%l3
- clr %o0
- L2:
- ldub [%l3],%l4
- inc %l3
- tst %l4
- bne,a L2
- inc %o0
- retl
- nop
-