d .title datasect manipulate data sections .psect $code pic,usr,con,lcl,rel,shr,exe,rd,nowrt , .enable debug  ;alternative way of handling files: in bulk rather than  ;record by record, using the pager to do the I/O X ; to open an existing file (create if none exixts):  ; CALL DSOPENON(vap, alq, filespec, pfc);  ; vap = ptr, datasec will store addr of its control block  ; alq = fixed bin(31), #blocks (512 by) if create  ; filespec = char(*) var L ; pfc = fixed bin(31), size of page fault cluster  ; to open for read only access:  ; STS$VALUE = DSOPENRO(vap, alq, filespec, pfc); x ; to checkpoint, ie force a page-out of all modified page clusters:  ; CALL DSCHKPTW(vap,efn); @ ; vap = as above  ; efn = fixed bin(31) event flag to use to test completion of I/O  ; to close: l ; CALL DSCLOSE(vap);  ; vap = as above; DATASECT will free the memory and set 4 ; vap null  ; to access:  ; DCL DATA CHAR(...) BASED(DSPTR); ` ; DCL DSPTR PTR BASED(vap); ; the FAB is located at vap+16 ( ; the XABFHC is loacated at vap+96 ; dsopenon & dsopenro use the first longword on the stack to flag ; which one of them was entered. this is addressed as -4(fp). T ; the second longword (pushed) is the pagecount, addressed as -8(fp) ;  ; r6 -> control block (=vap) ; r7 -> fab (vap+16) ; see dsget.pli for layout of control block H ; t dow 6/14/82 ************************************* ; version 1a t dow 6/17/82 mods for dsget & dsrewind:  ; init next_rec (vap+8->) to lo_addr(vap->) t ; init last_byte (vap+12->) to lo_addr + file_size_in_bytes -1  ; ( = loaddr-1 if new file) < ;  $jpidef  $ssdef h $secdef  $rmsdef 0x144: .long 144 ;size of control block fabshel:  $fab fac=put,alq=0,fop=,rfm=fix,mrs=512 \fhcshel:  $xabfhc $jpishel:  .word 4  .word jpi$_frep0va P .long 0,0,0,0  .long ^X5FFFFFFF  ; |dsopenro::  .word ^m D pushl #1 ;flag indicating dsopenro not dsopenon  brb dsopn dsopenon:: p .word ^M  pushl #0 ;flag indicating dsopenon not dsopenro 8dsopn: subl2 #4,sp ;get storage for pagecount  pushal @4(ap)  pushal x144 dgetvm: calls #2,lib$get_vm ; allocate heap for control block  blbs r0,11$ ; , brw error 11$: movl @4(ap),r6 ;vap  moval 16(r6),r7 ;r7->fab X movc3 #80,fabshel,(r7)  movc3 #44,fhcshel,80(r7)  movl 12(ap),r8 ;addr file name string desriptor  movl 4(r8),r8 ;addr of length word for filespec  tstl -4(fp)  beql on ro: $fab_store fab=r7,alq=@8(ap),fna=2(r8),fns=(r8),xab=80(r7),-  fac=get,shr=get  brw comn on: $fab_store fab=r7,alq=@8(ap),fna=2(r8),fns=(r8),xab=80(r7) Lcomn: ashl #9,@8(ap),r1 ;max rec size = 512*alq  movl @8(ap),-8(fp) ; init pagecount  movl r1,fab$w_mrs(r7) x movl #-1,12(r6) ;init file size in bytes  tstl -4(fp) ;dsopenon or ...ro @ beql opnc opno: bicl2 #fab$m_cif,fab$l_fop(r7) ;turn off create-if option  $open fab=(r7) l blbs r0,setalq brw error 4!opnc: $create fab=(r7) ;rms opens ! blbs r0,11$ ! brw error `"11$: cmpl r0,#rms$_created " beql crted (#setalq: movl xab$l_ebk+80(r7),@8(ap) # movl @8(ap),-8(fp) # decl @8(ap) ;actual file size = eof blk - 1 T$ ; compute file size in bytes $ ashl #9,@8(ap),r1 % addl2 r1,12(r6) % movzwl xab$w_ffb+80(r7),r1 ; add partial block % addl2 r1,12(r6) H&crted: subl2 #24,sp ;get mem for jpi call & movc3 #24,jpishel,(sp) ;set up itemlist ' moval 16(sp),4(sp) ;addr to hold addr of next free page t' movl sp,r8 'jpi: $getjpi_s itmlst=(r8) <( blbs r0,11$ ( brw error )11$: h) ; ) tstl -4(fp) ;check ...on or ...ro 0* beql mapsc *mapso: $crmpsc_s inadr=16(r8),- ;base addr supplied by getjpi * retadr=(r6),- ;return addr, to control block \+ pagcnt=-8(fp),- ; note section is not writeable + chan=fab$l_stv(r7),- $, pfc=@16(ap) , brw opnret ,mapsc: $crmpsc_s inadr=16(r8),- ;base addr supplied by getjpi P- retadr=(r6),- ;return addr, to control block - pagcnt=-8(fp),- . flags=#sec$m_wrt,- ;section is writeable |. chan=fab$l_stv(r7),- . pfc=@16(ap) D/opnret: blbs r0,11$ / brw error 011$: movl (r6),8(r6) ;init next_rec p0 addl2 (r6),12(r6) ;compute last_byte 0 ret 81 ; 1dschkptw:: 2 .word 0 d2 $clref_s efn=@8(ap) 2 blbc r0,error ,3 movl @4(ap),r1 3 $updsec_s inadr=(r1),efn=@8(ap) 3tstm: cmpl r0,#ss$_notmodified X4 bneq 1$ 4 ret ;ie, no modified pages since last system pageout 51$: cmpl r0,#ss$_normal ;if we were being defensive 5 bneq error 5 $waitfr_s efn=@8(ap) ; wait for completion of pageouts L6 ret 6 ; 7dsclose:: x7 .word ^m 7 movl @4(ap),r6 @8 $deltva_s inadr=(r6) ;release the virtual addr space 8 blbc r0,error 9 $dassgn_s chan=16+fab$l_stv(r6) l9 blbc r0,error 9 pushal @4(ap) 4: pushal x144 : calls #2,lib$free_vm ;free the control block : blbc r0,error `; clrl @4(ap) ;null out the ptr ; ret ( movl sp,r1 > $putmsg_s msgvec=(r1) > movl r6,r0 ;restore calling error code ? clrl @4(ap) H? ret ? .end