home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ZSYS / SIMTEL20 / SYSLIB / SLIB3.LBR / SRWRITE.Z80 < prev    next >
Text File  |  2000-06-30  |  1KB  |  56 lines

  1. ;
  2. ; SYSLIB Module Name:  SRWRITE
  3. ; Author:  Richard Conn
  4. ; SYSLIB Version Number:  3.6
  5. ; Module Version Number:  1.1
  6.  
  7.     public    r$write
  8.  
  9. ;
  10. ;  Equates
  11. ;
  12. bdos    equ    5
  13. ranrec    equ    33    ; offset to random record number
  14. writran    equ    34    ; function code for random read
  15.  
  16. ;
  17. ;  Macros
  18. ;
  19. putrg    macro
  20.     push    hl
  21.     push    de
  22.     push    bc
  23.     endm
  24. getrg    macro
  25.     pop    bc
  26.     pop    de
  27.     pop    hl
  28.     endm
  29.  
  30. ;
  31. ;    R$WRITE writes the random record whose number is given in HL of
  32. ; the file whose FCB is pointed to by DE.  It is assumed that the file
  33. ; has been previously opened by a routine like F$OPEN.
  34. ;
  35. ;    On exit, A=0 and Z if OK
  36. ;
  37. r$write:
  38.     putrg        ; save registers
  39.     push    de    ; save FCB ptr
  40.     ex    de,hl    ; HL pts to FCB, DE = record number
  41.     ld    bc,ranrec    ; BC = offset to random record number
  42.     add    hl,bc    ; HL pts to random record number
  43.     ld    (hl),e    ; store low-order value
  44.     inc    hl
  45.     ld    (hl),d    ; store high-order value
  46.     inc    hl
  47.     ld    (hl),0    ; store 0
  48.     pop    de    ; get FCB ptr
  49.     ld    c,writran    ; function code
  50.     call    bdos    ; perform function
  51.     getrg        ; restore registers
  52.     or    a    ; set flags
  53.     ret
  54.  
  55.     end
  56.