perm filename HOSTAT.MID[S,NET]1 blob
sn#318462 filedate 1977-11-20 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00007 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 title HOSTAT
C00003 00003 I/O subroutines
C00006 00004 Start of program
C00008 00005 movx x,10. decimal
C00011 00006 hstlup: movx x,10. decimal base
C00014 00007 outstr @[[asciz/ Random
C00015 ENDMK
C⊗;
title HOSTAT
; Mark Crispin, SU-AI, November 1977
; Adapted from the ITS version.
.insrt MACROS[1,MRC]
acdef. [t1 t2 x y z a b] ; accumulators
nd. pdllen==50. ; push down list length
nd. ntibfl==2000. ; words in net input buffer
pdl: block pdllen ; push down list
ntibfr: block ntibfl ; net input buffer
ntiptr: block 1 ; net input pointer
ntictr: block 1 ; net input pointer
; I/O subroutines
; NOUT numeric output
; accepts in x: base to use for outputting the number
; y: number to be output
; returns: +1: always, with y and z clobbered
nout=call .
idivi y,(x) ; snarf a digit
save z ; save the lowest order digit
caxe y,%zeros ; got them all?
nout ; nope
retr y ; get a digit to output
addx y,"0 ; convert to ASCII
outchr y ; output it
return ; and return
; SOUT string output
; accepts in x: pointer to string (0 in LH means ASCIZ string)
; returns +1: always, with updated string pointer in x; 0 clobbered
sout=call .
txnn x,%lhalf ; is there a left half?
hrli x,440700 ; yes, make it a 7 bit pointer
store %zeros,strlen' ; initialize string counter
ildb x ; get a character
jumpe [return] ; return if null
outchr ; output the character
aos strlen' ; bump string length counter
jrst .-4 ; and loop for more
; NIN numeric input
; accepts in x: base of number to be input
; returns +1: always, with number in y, break character in z
nin=call .
movx y,%zeros ; initially zero
bin ; get a character
caxl z,"0 ; non-numeric?
caxl z,"0(x) ; or out of base?
return ; yes, return
imuli y,(x) ; shift over old value
addi y,-"0(z) ; add in new digit
jrst .-6 ; and get next character
; BIN byte input from network
; returns +1: always, with input character in z
bin=call .
call neticw ; read character
move z, ; get the character
return ; and return
; Start of program
hostat: move p,[pdl(-pdllen)] ; load PDP
open [17 ? 'DSK,, ? 0] ; get a disk channel
jrst 4,.-1 ; failed?
movx x,'HOSTS1 ; fn1
movx y,('BIN) ; fn2
movx z,%zeros ; protection trash
movx a,'NETMRC ; ppn
lookup x ; get host table
jrst [ outstr [asciz/Host table gone!/]
jrst 4,.-1]
movs x,a ; get -size
movns x ; positive
addi x,hsttab ; offset for address
movem x,jobff ; prevent I/O from smashing
core x, ; get necessary core
jrst 4,.-1
hrri a,hsttab-1 ; make IOWD pointer
movx b,%zeros ; and stop code
in a ; read file in
skipn x,hsttab ; check first word of host table
jrst 4,.-1 ; didn't read it all or bad?
caxe x,'HOSTS1 ; right first word?
jrst 4,.-1 ; bad file?
outstr [asciz/Getting survey from MIT-DMS.../]
movx x,106 ; DM
movem x,host ; set host
movx x,17 ; socket 15
movem x,icpskt ; foreign socket
call conect ; connect there
outstr [asciz/ Ok
Survey of /]
movx x,10. ; decimal
nin ; get the month
caxe z,<",> ; ended in comma?
jrst 4,.-1
jumple y,[jrst 4,.-2] ; bad month?
caxle y,12. ; bad month?
jrst 4,.-1
outstr @[[asciz/January /]
[asciz/February /]
[asciz/March /]
[asciz/April /]
[asciz/May /]
[asciz/June /]
[asciz/July /]
[asciz/August /]
[asciz/September /]
[asciz/October /]
[asciz/November /]
[asciz/December /]]-1(y); load pointer to month
movx x,10. ; decimal base
nin ; get day
caxe z,<",> ; got a comma?
jrst 4,.-1
jumple y,[jrst 4,.-1] ; bad day?
caxle y,31. ; bad day?
jrst 4,.-1
nout ; output the day of month
outstr [asciz/, /]
movx x,10. ; decimal base
nin ; get the year
caxe z,<",> ; comma?
jrst 4,.1
jumple y,[jrst 4,.-1] ; bad year?
nout ; output the year
outchr [" ]
movx x,10. ; decimal base
nin ; get hours
caxe z,<",> ; comma?
jrst 4,.-1
jumpl y,[jrst 4,.-1] ; bad hours?
caxle y,23. ; bad hours?
jrst 4,.-1
caxge y,10. ; two digits?
outchr ["0] ; no, fill out to two digits
nout ; output hours
outchr [":]
movx x,10. ; decimal base
nin ; get minutes
caxe z,↑M ; terpri?
jrst 4,.-1
jumpl y,[jrst 4,.-1]
caxle y,59. ; bad minutes?
jrst 4,.-1
caxge y,10. ; two digits?
outchr ["0] ; no, fill out to two digits
nout ; output it
outstr [asciz/
Host # Decimal Name Status
/]
bin ; gobble the line feed
caxe z,↑J ; line feed?
jrst 4,.-1
hstlup: movx x,10. ; decimal base
nin ; get a number
jumpe y,[ caxe z,<"-> ; is this the end?
jrst 4,.-1
exit] ; suicide
caxe z,<",> ; followed by a comma?
jrst 4,.-1
caxge y,1000 ; four digit number?
outchr [" ] ; three or less
caxge y,100 ; three digit number?
outchr [" ] ; two or less
caxge y,10 ; two digit number?
outchr [" ] ; one digit
movx x,8. ; octal base
move a,y ; save host number
nout ; output the number
outchr [↑I] ; tab in
move y,a ; get host number back
caxge y,1000. ; four digit number?
outchr [" ] ; three or less
caxge y,100. ; three digit number?
outchr [" ] ; two or less
caxge y,10. ; two digit number?
outchr [" ] ; one digit
movx x,10. ; decimal base
nout ; output host number in decimal
outchr [↑I] ; tab over again
move x,hsttab+7 ; get rel addr of numbers table
movei z,2(x) ; get rel addr of numbers entries
move y,hsttab(x) ; get number of table entries
gethnm: camn a,hsttab(z) ; check for matching host number
jrst gothnm ; got host name
add z,hsttab+1(x) ; go to next entry
sojg y,gethnm ; and loop for more
skipa x,[[asciz/RANDOM-PLACE/]-hsttab]; for unknown hosts
gothnm: hrrz x,hsttab+1(z) ; get host name address
addi x,hsttab ; make absolute address
sout ; output it
skipg x,strlen' ; get length of outputed string
jrst 4,.-1
caxge x,8. ; more than a tab stop?
outchr [↑I] ; no, go to next tab stop
movx x,10. ; decimal base
nin ; get status
caxe z,<",> ; followed by a comma?
jrst 4,.-1
jumpl y,[jrst 4,.-1]
caxle y,7 ; valid code?
jrst 4,.-1
outstr @[[asciz/ Random
/]
[asciz/ Host Dead
/]
[asciz/ NCP Down
/]
[asciz/ Not Responding
/]
[asciz/ Refusing
/]
[asciz/ Host Up
/]
[asciz/ Unknown
/]
[asciz/ Unable to Poll
/]](y) ; get right message
movx x,10. ; any base is okay here
nin ; get a number
caxe z,↑M ; terpri now?
jrst 4,.-1
bin ; get the line feed
caxe z,↑J ; was it a line feed?
jrst 4,.-1
jrst hstlup ; get next host
; Wonderful network subroutines
.insrt NETWRK
; Generate literals
variables ? constants
hsttab: ; start of host table
end HOSTAT