home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / demo / readsect.s65 < prev    next >
Text File  |  1993-01-19  |  3KB  |  96 lines

  1.       .include #system
  2.       .include #macros
  3.       .include #cio
  4.       .include #os
  5.       .include #16bit
  6.  
  7. _string1 == $F0
  8. _value   == $F2
  9. _tmp1    == $F4
  10.  
  11. maxsecs = 32
  12. :more   = @special + @s2 + @p1 + @p2 + @p3   ; len will be ignored
  13.  
  14. ;; This is more or less an example, not written for beauty or
  15. ;; anything. Maybe you can pick up some ideas about using STDIO
  16.  
  17. main:
  18.       print       0,"SD sector reader -- 1991 Natürlich!"
  19.       print       0,"Input diskette in drive 1",0,:more  ; same IOCB chan.
  20.       print       0,"Press פדקרפמ to continue",0,:more   ; so we can use
  21.       getc        0,@special                             ; @special to save
  22. :again1
  23.       bput        0,p_start,p_end-p_start    ; some bytes
  24.       input       0,filename,4               ; get 4 chars into filename
  25.       dpoke       _string1,filename          ; convert &filename number
  26.       jsr         atoi                       ; try to convert ATASCII->16bit
  27.       bcc         :again1                    ; CC: failure
  28.       dmove       _value,startsec            ; get atoi val
  29.  
  30. :again2
  31.       bput        0,p_end,p_output-p_end     ; some bytes
  32.       input       0,filename,4
  33.       dpoke       _string1,filename
  34.       jsr         atoi
  35.       bcc         :again2
  36.       cmp.w       maxsecs+1,_value,@p1
  37.       bcc         :alrite
  38.       jsr         :toomany
  39.       jmp         :again2     
  40.  
  41. :alrite
  42.       move        _value,size+1
  43.       tay                                    ; get #sectors in Y
  44.       lsr.w       size                       ; size = value * $80
  45.  
  46.       setup_sio   1,SIOREAD,startsec,buffer,@p1+@p2+@p4
  47. :loop
  48.       jsr         sd_secs
  49.       bpl         :fine
  50.       jmp         :failure
  51.  
  52. :fine
  53.       bput        0,p_output,size-p_output,@p1+@p2+@p3
  54.       input       0,filename,buffer-filename,@p1+@p2+@p3+@special
  55.       open        1,8,0,filename,@p1+@p2+@p3+@p4
  56.       bmi         :noopen
  57.       bput        1,buffer,size,@p1+@p2+@special
  58.       php
  59.       close       1,@p1+@special
  60.       plp
  61.       bpl         :ok
  62.       jsr         :diskfull
  63.       jmp         :fine
  64.  
  65. :ok
  66.       print       0,"Done"
  67.       rts
  68.  
  69.  
  70. :failure:
  71.       print       0,"Couldn't read sectors"
  72.       rts
  73.  
  74. :noopen:
  75.       print       0,"Couldn't open output file"
  76.       rts
  77.  
  78. :diskfull:
  79.       print       0,"Disk full ? Retry with another..."
  80.       rts
  81.  
  82. :toomany
  83.       print       0,"Too many sectors requested"
  84.       rts
  85.  
  86. p_start:    .byte "Enter first sector no: "
  87. p_end:      .byte "      Sectors to read: "
  88. p_output:   .byte "Output file name: "
  89.  
  90. size:       .word 0
  91. endsec:     .ds   2
  92. startsec:   .ds   2
  93. filename:   .ds   64
  94. buffer:     .ds   128*maxsecs
  95.  
  96.