/ / Long seek. / .globl flseek / / flseek(fp, seek, type); / FILE *fp; / long seek; / type = 0 for front of file. / type = 1 for current position. / type = 2 for end of file. / flseek: jsr r0,__csav / Make stack frame. mov 12(r5),r4 / File pointer. mov $VF_REC,r0 / Fix the bis $VF_OUT,r0 / Assembler!!!! bit r0,(r4) / Will it seek? beq 0f / Yes. bis $VF_ERR,(r4) / Set error flag and clr r0 / Return a br 2f / NULL. 0: clr r0 / Default seek origin clr r1 / is front of file. cmp 20(r5),$1 / Seek from here? bne 0f / No. mov V_RBLK(r4),r0 / Grab the mov V_RBLK+2(r4),r1 / current block number. call fixbn / Convert to bytes. add V_RBYT(r4),r1 / Add in adc r0 / byte number. br 1f / Go seek. 0: cmp 20(r5),$2 / Seek from EOF. bne 1f / No. mov V_EFBK(r4),r0 / Grab the mov V_EFBK+2(r4),r1 / end of file block number. call fixbn / Convert to bytes. add V_FFBY(r4),r1 / Add in byte adc r0 / Number. 1: add 16(r5),r1 / Add in the adc r0 / user's add 14(r5),r0 / displacement. mov r1,V_RBYT(r4) / Store the bic $!777,V_RBYT(r4)/ Byte number down. clrb r1 / Simulate ashc $-9.,r0 bisb r0,r1 / To convert to block swab r1 / clrb r0 / swab r0 / ror r0 / Swab clears carry bit. ror r1 / Get this right, Phil !! bit $VF_FIL,(r4) / File or device? beq 0f / Br if device. add $1,r1 / Make adc r0 / Origin 1. 0: cmp r0,V_RBLK(r4) / If the block is bne 0f / Different cmp r1,V_RBLK+2(r4) / Then beq 1f / Set the block buffer 0: bis $VF_BAD,(r4) / Bad flag. 1: mov r0,V_RBLK(r4) / Do mov r1,V_RBLK+2(r4) / Seek bic $VF_EOR,(r4) / Knock down EOF and ERR. mov r4,r0 / Return (fp); 2: jmp __cret / To caller / / Convert a double precision block / number (r0-r1) to a byte number, / taking into account origin 1 / addressing on files. / fixbn: bit $VF_FIL,(r4) / File? beq 0f / No. sub $1,r1 / Convert to origin sbc r0 / Zero. 0: swab r0 / Simulate ashc $9.,r0 clrb r0 / To multiply by 512. swab r1 / bisb r1,r0 / clrb r1 / rol r1 / rol r0 / return / Done.