.global main
.section ".text"
.align 4
.proc 4
main:
save %sp,-120,%sp
st %g0,[%fp+-24]
set next,%i5
st %g0,[%i5]
ba .L3; nop
.L2:
add -20,%fp,%o0
add -24,%fp,%o1
call lookup; nop
ld [%o0],%i4
add %i4,1,%i4
st %i4,[%o0]
.L3:
add -20,%fp,%o0
call getword; nop
cmp %o0,0; bne .L2; nop
ld [%fp+-24],%o0
call tprint; nop
mov %g0,%i0
.L1:
ret; restore
.global err
.align 4
.proc 4
err:
save %sp,-96,%sp
set .L9,%o0
mov %i0,%o1
call printf; nop
set 1,%o0
call exit; nop
.L8:
ret; restore
.global getword
.align 4
.proc 4
getword:
save %sp,-96,%sp
.L11:
.L12:
call getchar; nop
mov %o0,%i3
mov %i3,%i5
cmp %i3,-1; be .L14; nop
mov %i5,%o0
call isletter; nop
cmp %o0,0; be .L11; nop
.L14:
mov %i0,%i4
ba .L18; nop
.L15:
mov %i4,%i3
add %i3,1,%i4
stb %i5,[%i3]
.L16:
call getchar; nop
mov %o0,%i5
.L18:
mov %i5,%o0
call isletter; nop
mov %o0,%i5
cmp %o0,0; bne .L15; nop
stb %g0,[%i4]
cmp %i4,%i0; bleu .L19; nop
set 1,%i0
ba .L10; nop
.L19:
mov %g0,%i0
.L10:
ret; restore
.global isletter
.align 4
.proc 4
isletter:
cmp %o0,65; bl .L27; nop
cmp %o0,90; bg .L27; nop
add %o0,32,%o0
.L27:
cmp %o0,97; bl .L29; nop
cmp %o0,122; bg .L29; nop
ba .L26; nop
.L29:
mov %g0,%o0
.L26:
retl; nop
.global lookup
.align 4
.proc 4
lookup:
save %sp,-96,%sp
ld [%i1],%i4
cmp %i4,%g0; be .L32; nop
mov %i0,%o0
ld [%i1],%i4
ld [%i4+12],%o1
call strcmp; nop
mov %o0,%i5
cmp %i5,0; bge .L34; nop
mov %i0,%o0
ld [%i1],%i4
add %i4,4,%o1
call lookup; nop
mov %o0,%i0
ba .L31; nop
.L34:
cmp %i5,0; ble .L36; nop
mov %i0,%o0
ld [%i1],%i4
add %i4,8,%o1
call lookup; nop
mov %o0,%i0
ba .L31; nop
.L36:
ld [%i1],%i4
mov %i4,%i0
ba .L31; nop
.L32:
set next,%i4
ld [%i4],%i4
cmp %i4,2000; bl .L38; nop
set .L40,%o0
call err; nop
.L38:
set next,%i4
ld [%i4],%i4
sll %i4,4,%i4
set words,%i3
st %g0,[%i4+%i3]
set next,%i4
ld [%i4],%i4
sll %i4,4,%i4
set words+8,%i2
st %g0,[%i4+%i2]
set words+4,%i2
st %g0,[%i4+%i2]
mov %i0,%o0
call strlen; nop
mov %o0,%i4
add %i4,1,%o0
call malloc; nop
set next,%i3
ld [%i3],%i3
sll %i3,4,%i3
set words+12,%i2
st %o0,[%i3+%i2]
set next,%i4
ld [%i4],%i4
sll %i4,4,%i4
set words+12,%i3
ld [%i4+%i3],%i4
cmp %i4,%g0; bne .L44; nop
set .L47,%o0
call err; nop
.L44:
set next,%i4
ld [%i4],%i4
sll %i4,4,%i4
set words+12,%i3
ld [%i4+%i3],%o0
mov %i0,%o1
call strcpy; nop
set next,%i4
ld [%i4],%i3
add %i3,1,%i2
st %i2,[%i4]
sll %i3,4,%i4
set words,%i3
add %i4,%i3,%i4
st %i4,[%i1]
mov %i4,%i0
.L31:
ret; restore
.global tprint
.align 4
.proc 4
tprint:
save %sp,-96,%sp
cmp %i0,%g0; be .L60; nop
ld [%i0+4],%o0
call tprint; nop
set .L62,%o0
ld [%i0],%o1
ld [%i0+12],%o2
call printf; nop
ld [%i0+8],%o0
call tprint; nop
.L60:
.L59:
ret; restore
.global strcmp
.align 4
.proc 4
strcmp:
ba .L65; nop
.L64:
mov %o0,%o5
add %o5,1,%o0
ldsb [%o5],%o5
cmp %o5,0; bne .L67; nop
mov %g0,%o0
ba .L63; nop
.L67:
add %o1,1,%o1
.L65:
ldsb [%o0],%o5
ldsb [%o1],%o4
cmp %o5,%o4; be .L64; nop
ldsb [%o0],%o5
cmp %o5,0; bne .L69; nop
set -1,%o0
ba .L63; nop
.L69:
ldsb [%o1],%o5
cmp %o5,0; bne .L71; nop
set 1,%o0
ba .L63; nop
.L71:
ldsb [%o0],%o5
ldsb [%o1],%o4
sub %o5,%o4,%o0
.L63:
retl; nop
.section ".bss"
.global next
.type next,#object
.common next,4,4
.global words
.type words,#object
.common words,32000,4
.section ".rodata"
.align 1
.L62:
.byte 37
.byte 100
.byte 9
.byte 37
.byte 115
.byte 10
.byte 0
.align 1
.L47:
.byte 111
.byte 117
.byte 116
.byte 32
.byte 111
.byte 102
.byte 32
.byte 119
.byte 111
.byte 114
.byte 100
.byte 32
.byte 115
.byte 116
.byte 111
.byte 114
.byte 97
.byte 103
.byte 101
.byte 0
.align 1
.L40:
.byte 111
.byte 117
.byte 116
.byte 32
.byte 111
.byte 102
.byte 32
.byte 110
.byte 111
.byte 100
.byte 101
.byte 32
.byte 115
.byte 116
.byte 111
.byte 114
.byte 97
.byte 103
.byte 101
.byte 0
.align 1
.L9:
.byte 63
.byte 32
.byte 37
.byte 115
.byte 10
.byte 0
