/ UNIX RL01/2 disk block 0 bootstrap / Can only boot from unit zero. / Assumes controller at standard address (0174400). nop = 240 core = 24. .. = [core*2048.]-512. / establish sp, then check to see if running in low memory; if so, copy / bootstrap up to 'core' K words. start: nop / cflg mov $..,sp mov sp,r1 clr r0 cmp pc,r1 bhis 2f / if not relocated yet, see if a.out header present, if so skip it cmp (r0),$407 bne 1f mov $20,r0 1: mov (r0)+,(r1)+ cmp r1,$core*2048. blo 1b jmp (sp) / clear memory 2: clr (r0)+ cmp r0,sp blo 2b / print prompt mov $'@,r0 jsr pc,putc / get file name mov $names,r2 1: mov r2,r1 2: jsr pc,getc cmp r0,$'\n beq 1f cmp r0,$'/ beq 3f movb r0,(r1)+ br 2b 3: cmp r2,r1 beq 2b add $14.,r2 br 1b / now read directories to find target file 1: mov $names,r2 mov $1,r0 / r0 holds inode, start with root directory 1: clr bno / start at first block of each directory jsr pc,iget tst (r2) / no names left? beq 1f / must have inode # of file, go read it in 2: jsr pc,rmblk / read a chunk of directory br start / at end, didn't find the name, restart mov $buf,r1 3: mov r2,r3 mov r1,r4 add $16.,r1 tst (r4)+ / blank directory entry? beq 5f 4: cmpb (r3)+,(r4)+ bne 5f cmp r4,r1 / end of name field? blo 4b mov -16.(r1),r0 / get inode number add $14.,r2 / advance to next element of name (if any) br 1b 5: cmp r1,$buf+512. / end of block? blo 3b / no, try next directory entry in this block br 2b / yes, get next block of directory / read file into memory / bno is cleared when we get here (so file read starts at first block / of file), as a side-effect of the logic of the directory-reading loop 1: clr r2 1: jsr pc,rmblk br 1f mov $buf,r1 2: mov (r1)+,(r2)+ cmp r1,$buf+512. blo 2b br 1b / if a.out header present, relocate code to get rid of it 1: clr r0 cmp (r0),$407 bne 2f 1: mov 20(r0),(r0)+ cmp r0,sp blo 1b / start program (restart if return) 2: mov $..,-(sp) clr pc / read inode / called with inode number in r0 iget: add $31.,r0 / convert inode number to block number mov r0,r5 ash $-4.,r0 jsr pc,rblk bic $!17,r5 / compute pointer to inode within buffer ash $5,r5 add $buf,r5 mov $inod,r4 / copy inode data out 1: mov (r5)+,(r4)+ cmp r4,$addr+16. blo 1b rts pc / read a mapped (i.e. possibly through an indirect block) block of a file / block number within file is kept in a global, and incremented on each / call here to step through the file / success return is a skip LRG = 10000 rmblk: add $2,(sp) mov bno,r0 inc bno bit $LRG,mode bne 2f asl r0 mov addr(r0),r0 / does this block exist in the file? bne rblk 1: sub $2,(sp) rts pc / large file 2: clr -(sp) movb r0,(sp) clrb r0 swab r0 asl r0 mov addr(r0),r0 beq 1b jsr pc,rblk mov (sp)+,r0 asl r0 mov buf(r0),r0 beq 1b / RL driver / called with desired block number in r0 rladdr = 174400 rlcsr = rladdr rlmpr = rladdr+6 nblks = 20. / number of blocks per track seek = 6 / command codes rdhdr = 10 read = 14 cylsurf = 77700 direct = 4 / seek direction surf = 20 rblk: mov r0,r1 / convert block number to cylinder+surface clr r0 / and block number within track div $nblks,r0 / leaves desired cylinder+surface in r0 asl r1 / and block number in r1 mov r1,-(sp) / save sector number mov ocylsurf,r1 / try and get current cylinder+surface into r1 bge 2f / fall through on unknown drive situation mov $rdhdr,*$rlcsr / ask the drive where it is at the moment 1: tstb *$rlcsr bpl 1b mov *$rlmpr,r1 / get current cylinder+surface bic $!cylsurf,r1 ash $-6,r1 2: mov r0,ocylsurf / save target cylinder+surface for future asr r0 asr r1 sub r0,r1 / diff between current cylinder and target mov $rlmpr,r0 / start to construct disk address register mov $1,-(r0) / contents for seek bit $1,ocylsurf / seek also needs to select surface beq 3f bis $surf,(r0) 3: tst r1 / see which direction the head needs to move bge 4f neg r1 bis $direct,(r0) 4: ash $7,r1 / finish constructing disk address register bis r1,(r0) / contents with target cylinder mov $seek,*$rlcsr 1: tstb *$rlcsr bpl 1b mov $rlmpr,r0 / now set up for actual read mov $-256.,(r0) mov ocylsurf,r1 / start constructing disk address register ash $6,r1 / contents for read bis (sp)+,r1 / bring back sector mov r1,-(r0) mov $buf,-(r0) mov $read,-(r0) 1: tstb (r0) bpl 1b rts pc / tty routines tks = 177560 tkb = 177562 tps = 177564 tpb = 177566 getc: tstb *$tks bge getc mov tkb,r0 bic $!177,r0 cmp r0,$'A blo putc cmp r0,$'Z bhi putc add $'a-'A,r0 / fall through to echo putc: tstb tps bpl putc mov r0,tpb cmp r0,$'\r bne 1f mov $'\n,r0 jsr pc,putc 1: rts pc .data ocylsurf: -1 / cylinder+surface of last seek .bss end: inod = ..-1024. mode = inod addr = inod+8. buf = inod+32. bno = buf+514. names = bno+2