mov r2,i.size / yes, increase the f11e size to file offset + / no. of data bytes jsr r0,setimod / set imod=1 (i.e., core inode has been / modified), stuff tlme of modification into / core image of i-node 1: jsr r0,mget / get the block no. in which to write the next data / byte bit *u.fofp,$777 / test the lower 9 bits of the file offset bne 2f / if its non-zero, branch; if zero, file offset = 0, / 512, 1024,...(i.e., start of new block) cmp u.count,$512. / if zero, is there enough data to fill an / entire block? (i.e., no. of bhis 3f / bytes to be written greater than 512.? Yes, branch. / Don't have to read block 2: / in as no past info. is to be saved (the entire block will be / overwritten). jsr r0,dskrd / no, must retain old info.. Hence, read block 'r1' / into an I/O buffer 3: jsr r0,wslot / set write and inhibit bits in I/O queue, proc. / status=0, r5 points to 1st word of data jsr r0,sioreg / r3 = no. of bytes of data, r1 = address of data, / r2 points to location in buffer in which to / start writing data 2: movb (r1 )+,(r2)+ / transfer a byte of data to the I/O buffer dec r3 / decrement no. of bytes to be written bne 2b / have all bytes been transferred? No, branch jsr r0,dskwr / yes, write the block and the i-node tst u.count / any more data to write? bne 1b / yes, branch jmp ret / no, return to the caller via 'ret' cpass: / get next character from user area of core and put it in r1 tst u.count / have all the characters been transferred (i.e., / u.count, # of chars. left beq 1f / to be transferred = 0?) yes, branch dec u.count / no, decrement u.count movb *u.base,r1 / take the character pointed to by u.base and / put it in r1 inc u.nread / increment no. of bytes transferred inc u.base / increment the buffer address to point to the rts r0 / next byte 1: mov (sp)+,r0 / put return address of calling routine into r0 mov (sp)+,r1 / i-number in r1 rts r0 / non-local return sioreg: mov *u.fofp,r2 / file offset (in bytes) is moved to r2 mov r2,r3 / and also to r3 bis $177000,r3 / set bits 9,...,15. of file offset in r3 bic $!777,r2 / calculate file offset mod 512. add r5,r2 / r2 now points to 1st byte in system buffer where / data is to be placed