; WRDISK -- Subroutine for writing a disk - block by block
;
; Synanon Church
; Mike Vandeman
; May 20, 1983
;
;MAP1 BLOCK'NUMBER,B,4
;MAP1 BUFFER'ADDRESS,B,4
;MAP1 DISK'NUMBER,B,2
;MAP1 ERROR'CODE,B,1
;MAP1 INPUT'BUFFER,X,512
;
;INPUT "DISK? ",DISK'NUMBER
;INPUT "BLOCK #? ", BLOCK'NUMBER
;
;XCALL WRDISK, DISK'NUMBER, BLOCK'NUMBER,INPUT,BUFFER, BUFFER'ADDRESS, &
; ERROR'CODE
OBJNAM WRDISK.SBR
SEARCH SYS
SEARCH SYSSYM
RADIX 10 ;use decimal arithmetic
PHDR -1,PV$RSM,PH$REU
START: LEA A0,DDB
MOV 34(A3),A1 ;return buffer address
MOVW 24(A3),2(A1) ;move high order word
MOVW 26(A3),@A1 ;move low order word
ANDB #D$INI,D.FLG(A0) ;DDB initialized?
BNE WRITE ;YES, set up for the write
ORB #D$ERC,D.DEV ;device "DSK"
MOV #512,D.SIZ(A0) ;default buffer size
ORB #D$INI,D.FLG(A0) ;indicate DDB initialized
WRITE: MOV 4(A3),A1 ;get address of drive #
MOVW @A1,D.DVR(A0) ;enter drive # in DDB
MOV 14(A3),A1 ;get address of block #
MOVW @A2,D.REC+2(A0) ;enter physical record # in DDB (low order word)
MOVW 2(A1),D.REC(A0) ;enter physical record # in DDB (high order word)
MOV 24(A3),D.BUF(A0) ;enter buffer address in DDB
CLRB D.ERR(A0) ;clear errors and flags
WRITE @A0 ;write disk block
MOV 44(A3),A1 ;get address of error code
MOVB D.ERR(A0),@A1 ;return error code
RTN
EVEN
DDB: BLKB D.DDB
END