home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / ASSEMBLY / SECTORS.S < prev    next >
Text File  |  1989-04-06  |  2KB  |  52 lines

  1. ;
  2. ; Accessing sectors (including the bootsector) using the XBIOS
  3. ; (c)1993 Glenn Edwards
  4. ;
  5. ; From studying this source code, you should be able to work out how
  6. ; to read/write sectors using 68000.
  7. ;
  8. ; *** If you are using Devpac 1 then delete the line 'section bss' ***
  9. ;
  10.  
  11.     opt    o+
  12.  
  13. start    movem.l    d0-d7/a0-a6,-(sp)    ;Store registers
  14.     moveq.w    #1,d4            ;Read 1 sector
  15.     moveq.w    #0,d3            ;Side 0
  16.     moveq.w    #0,d2            ;Track 0
  17.     moveq.w    #1,d1            ;Start reading from sector 1
  18.     moveq.w    #0,d0            ;Drive 0
  19.     lea    buffer(pc),a0        ;Buffer address
  20.     bsr.s    read            ;Read sector(s)
  21.     movem.l    (sp)+,d0-d7/a0-a6    ;Restore registers
  22. exit    clr.w    -(sp)            ;Exit to desktop
  23.     trap    #1
  24.  
  25. read    ;d0=drive, d1=start_sec, d2=track, d3=side, d4=num_sec, a0=buffer
  26.     move.w    d4,-(sp)        ;Number of sectors to read
  27.     move.w    d3,-(sp)        ;Side number (0 or 1)
  28.     move.w    d2,-(sp)        ;Track number(0 to ??)
  29.     move.w    d1,-(sp)        ;Start sector (1 to ??)
  30.     move.w    d0,-(sp)        ;Drive (0 or 1)
  31.     clr.l    -(sp)
  32.     move.l    a0,-(sp)        ;Buffer address
  33.     move.w    #8,-(sp)        ;XBIOS _floprd
  34.     trap    #14
  35.     lea    20(sp),sp
  36.     rts
  37.  
  38. write    ;d0=drive, d1=start_sec, d2=track, d3=side, d4=num_sec, a0=buffer
  39.     move.w    d4,-(sp)        ;Number of sectors to read
  40.     move.w    d3,-(sp)        ;Side number (0 or 1)
  41.     move.w    d2,-(sp)        ;Track number(0 to ??)
  42.     move.w    d1,-(sp)        ;Start sector (1 to ??)
  43.     move.w    d0,-(sp)        ;Drive (0 or 1)
  44.     clr.l    -(sp)
  45.     move.l    a0,-(sp)        ;Buffer address
  46.     move.w    #9,-(sp)        ;XBIOS _flopwr
  47.     trap    #14
  48.     lea    20(sp),sp
  49.     rts
  50.  
  51.     section    bss
  52. buffer    ds.b    512            ;Read/write buffer