home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / cpmsim / srccpm / boot64.asm < prev    next >
Encoding:
Assembly Source File  |  1992-07-09  |  2.3 KB  |  75 lines

  1. ;       CP/M 2.2 boot-loader for Z80-Simulator
  2. ;
  3. ;       Copyrigth (C) 1988 by Udo Munk
  4. ;
  5.     ORG     0               ; mem base of cp/m
  6. ;
  7. MSIZE   EQU     64              ; mem size in kbytes
  8. ;
  9. BIAS    EQU    (MSIZE-20)*1024    ; offset from 20k system
  10. CCP    EQU    3400H+BIAS    ; base of the ccp
  11. BIOS    EQU    CCP+1600H    ; base of the bios
  12. BIOSL    EQU    0300H        ; length of the bios
  13. BOOT    EQU    BIOS
  14. SIZE    EQU    BIOS+BIOSL-CCP    ; size of cp/m system
  15. SECTS    EQU    SIZE/128    ; # of sectors to load
  16. ;
  17. ;       I/O ports
  18. ;
  19. DRIVE   EQU     10              ; fdc-port: # of drive
  20. TRACK   EQU     11              ; fdc-port: # of track
  21. SECTOR  EQU     12              ; fdc-port: # of sector
  22. FDCOP   EQU     13              ; fdc-port: command
  23. FDCST   EQU     14              ; fdc-port: status
  24. DMAL    EQU     15              ; dma-port: dma address low
  25. DMAH    EQU     16              ; dma-port: dma address high
  26. ;
  27. ;       begin the load operation
  28. ;
  29. COLD:   LD      BC,2            ; b=track 0, c=sector 2
  30.     LD      D,SECTS         ; d=# sectors to load
  31.     LD      HL,CCP          ; base transfer address
  32.     LD      A,0             ; select drive A
  33.     OUT     (DRIVE),A
  34. ;
  35. ;       load the next sector
  36. ;
  37. LSECT:  LD      A,B             ; set track
  38.     OUT     (TRACK),A
  39.     LD      A,C             ; set sector
  40.     OUT     (SECTOR),A
  41.     LD      A,L             ; set dma address low
  42.     OUT     (DMAL),A
  43.     LD      A,H             ; set dma adress high
  44.     OUT     (DMAH),A
  45.     XOR     A               ; read sector
  46.     OUT     (FDCOP),A
  47.     IN      A,(FDCST)       ; get status of fdc
  48.     CP      0               ; read successful ?
  49.     JP      Z,CONT          ; yes, continue
  50.     HALT                    ; no, halt cpu
  51. CONT:
  52.                 ; go to next sector if load is incomplete
  53.     DEC     D               ; sects=sects-1
  54.     JP      Z,BOOT          ; head for the bios
  55. ;
  56. ;       more sectors to load
  57. ;
  58. ;       we aren't using a stack, so use <sp> as scratch register
  59. ;             to hold the load address increment
  60. ;
  61.     LD      SP,128          ; 128 bytes per sector
  62.     ADD     HL,SP           ; <hl> = <hl> + 128
  63. ;
  64.     INC     C               ; sector = sector + 1
  65.     LD      A,C
  66.     CP      27              ; last sector of track ?
  67.     JP      C,LSECT         ; no, go read another
  68. ;
  69. ;       end of track, increment to next track
  70. ;
  71.     LD      C,1             ; sector = 1
  72.     INC     B               ; track = track + 1
  73.     JP      LSECT           ; for another group
  74.     END                     ; of boot loader
  75.