home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / EXTRA-ST / CPM-80-E / CPM-0.2 / CPM-0 / cpm-0.2 / z80-sources / mylib / sectorio.mac < prev    next >
Encoding:
Text File  |  1994-06-06  |  2.0 KB  |  90 lines

  1. ;************************************************************************
  2. ;*                                    *
  3. ;*        READ/WRITE-Unterprogramme                *
  4. ;*                                    *
  5. ;************************************************************************
  6.  
  7.         entry _seqrd, _seqwr, _rndrd, _rndwr, _chrrd, _chrwr
  8.         maclib BDOSCALL.MLB    ;
  9.  
  10. _chrrd:        push de            ;
  11.         pop ix            ;
  12.         ld a,(ix-3)        ; count
  13.         and 7fh            ;
  14.         jr nz,noreadsec        ;
  15.         push de            ;
  16.         call _seqrd        ;
  17.         pop ix            ;
  18.         ret nz            ;
  19.         xor a            ;
  20. noreadsec:    inc a            ;
  21.         ld (ix-3),a        ; next count
  22.         dec a            ;
  23.         ld l,(ix-2)        ;
  24.         ld h,(ix-1)        ;
  25.         call _adda##        ;
  26. ret_z:        ld a,(hl)        ;
  27.         cp a            ; set zero
  28.         ret            ;
  29.  
  30. _chrwr:        push de            ;
  31.         pop ix            ;
  32.         set 2,(ix+0)        ; Buffer dirty
  33.         ld a,(ix-3)        ; count
  34.         ld l,(ix-2)        ;
  35.         ld h,(ix-1)        ;
  36.         call _adda##        ;
  37.         ld (hl),c        ;
  38.         ld a,(ix-3)        ;
  39.         inc a            ;
  40.         and 7fh            ;
  41.         ld (ix-3),a        ;
  42.         jr nz,ret_z        ;
  43.  
  44. _seqwr:        ld bc,200h+write_seq    ; BDOS schreiben
  45.         ld a,(de)        ; Buffer not dirty
  46.         and not 4        ;
  47.         ld (de),a        ;
  48.         jr common_io        ;
  49.  
  50. _seqrd:        ld bc,read_seq        ; BDOS-Callnr
  51.  
  52. common_io:    ld a,(de)        ; Statusbyte lesen
  53.         bit 0,a            ; Datei ge|ffnet?
  54.         jr z,io_err        ;
  55.         or b            ; bei write ist Bit 1 gesetzt
  56.         ld (de),a        ; Statusbyte zur}ck
  57.         inc de            ; zeigt jetzt auf BDOS-Teil des FCB
  58.         push bc            ;
  59.         push de            ;
  60.         pop ix            ;
  61.         push de            ;
  62.         ld e,(ix-3)        ;
  63.         ld d,(ix-2)        ;
  64.         bdos set_dma_addr    ;
  65.         pop de            ;
  66.         pop bc            ;
  67.         bdos            ; lies/schreibe Sektor
  68.         or a            ; Fehler aufgetreten?
  69.         ret            ;
  70.  
  71.  
  72. _rndwr:        ld bc,200h+write_random    ; Flag und BDOS-Function
  73.         jr common_rnd_io    ;
  74.  
  75. _rndrd:        ld bc,read_random    ; BDOS-Function
  76.  
  77. common_rnd_io:    push de            ;
  78.         pop ix            ; ix zeigt auf FCB-1
  79.         ld (ix+34),l        ; r0
  80.         ld (ix+35),h        ; r1
  81.         ld (ix+36),0        ; r2
  82.         jr common_io        ; weiter wie sequential I/O
  83.  
  84. io_err:        ld hl,errmsg        ;
  85.         jp _exit##        ;
  86.         dseg            ;
  87. errmsg:        db "MACLIB Err: File not open during I/O",0
  88.         cseg            ;
  89.         end            ;
  90.