; RDDISK -- Subroutine for reading 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 RDDISK, DISK'NUMBER, BLOCK'NUMBER, INPUT'BUFFER, BUFFER'ADDRESS, &
;    ERROR'CODE

       OBJNAM  RDDISK.SBR              ;assemble with this name
       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     READ                    ;yes, set up for the read
       ORB     #D$ERC,D.FLG(A0)        ;return even if errors
       MOVW    #[DSK],D.DEV(A0)        ;device: "DSK"
       MOV     #512,D.SIZ(A0)          ;default buffer size
       ORB     #D$INI,D.FLG(A0)        ;indicate DDB is initialized
READ:   MOV     4(A3),A1                ;get address of driver
       MOVW    @A1,D.DVR(A0)           ;enter driver # in DDB
       MOV     14(A3),A1               ;get address of block #
       MOVW    @A1,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
       READ    @A0                     ;read disk block
       MOV     44(A3),A1               ;return error code
       MOVB    D.ERR(A0),@A1           ;return error code
       RTN

       EVEN
DDB:    BLKB    D.DDB
       END