home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / disk / fdformat / fdboot.asm < prev    next >
Encoding:
Assembly Source File  |  1991-06-26  |  5.4 KB  |  107 lines

  1. ;-----------------------------------------------------------
  2.              PAGE      66,128
  3. CSEG         SEGMENT   PARA PUBLIC 'CODE'
  4.              ASSUME    CS: CSEG
  5.  
  6.              ORG       100H                     ;Allow Boot-Sector as COM-File
  7. Begin:       JMP       SHORT Start              ;Jump
  8.              NOP
  9. bpb          DB        3FH DUP (0)              ;Reserve enough space for BPB
  10.  
  11. Start        PROC      FAR
  12. ;            mov       ax,cs                    ;Get Code Segment
  13. ;            cmp       ax,7c00h                 ;Is it 7C00H
  14. ;            jz        tryboot                  ;Yes, Boot-Sector
  15. ;            mov       si,offset text3          ;Load Error Message
  16. ;            call      output                   ;Output text
  17. ;            int       20h                      ;Terminate Program
  18. Tryboot:     CLI                                ;Clear Interrupts, while modifying stack
  19.              XOR       AX,AX                    ;Zero AX
  20.              MOV       SS,AX                    ;Set SS...
  21.              MOV       SP,7C00H                 ;..and SP below Code
  22.              MOV       AX,7B0H                  ;Set Segment-Registers that Offset is 100H
  23.              PUSH      AX                       ;Push Segment twice
  24.              PUSH      AX
  25.              POP       DS                       ;Get Segment in DS
  26.              POP       ES                       ;and also in ES
  27.              MOV       SI,100H                  ;Set Source to 100H
  28.              MOV       DI,300H                  ;Set Destination to 300H
  29.              MOV       CX,100H                  ;Set Count to 512 Bytes (1 Sector)
  30.              REP       MOVSW                    ;Move Code
  31.              MOV       AX,7D0H                  ;New Segment at 7d0h (+20H)
  32.              PUSH      AX                       ;Push Segment three times
  33.              PUSH      AX
  34.              PUSH      AX
  35.              POP       DS                       ;Get new segment in DS
  36.              POP       ES                       ;and also in ES
  37.              MOV       AX,OFFSET Entry          ;Offset of next instruction
  38.              PUSH      AX                       ;Push to stack
  39.              RET                                ;and pop it to CS:IP
  40. Start        ENDP
  41.  
  42. Entry        PROC      FAR
  43.              STI                                ;Start Interrupts again
  44.              MOV       SI,OFFSET Text1          ;Move SI to text
  45.              CALL      Output                   ;display to screen
  46.              MOV       AX,201H                  ;AH=2 (read sector), AL=1 (count)
  47.              MOV       CX,1                     ;CH=0 (Track), CL=1 (Sector)
  48.              MOV       DX,128                   ;DH=0 (Head), DL=128 (Fixed Disk C)
  49.              XOR       BX,BX                    ;Segment of Transfer buffer
  50.              PUSH      BX                       ;Push to Stack
  51.              POP       ES                       ;Get Segment in ES
  52.              MOV       BX,7C00H                 ;Offset of Transfer buffer
  53.              PUSH      ES                       ;Push Segment...
  54.              PUSH      BX                       ;And Offset to stack
  55.              INT       13H                      ;Read from Harddisk
  56.              JC        Error                    ;Jump if error
  57.              CMP       WORD PTR ES:7DFEH,0AA55H ;Valid Boot Secotor?
  58.              JNZ       Error                    ;No, error
  59.              RET                                ;Continue with Boot-Sector of C:
  60.  
  61. Error:       MOV       SI,OFFSET Text2          ;Move SI to text
  62.              CALL      Output                   ;display to screen
  63. Loop1:       MOV       AH,1                     ;Get Status of...
  64.              INT       16H                      ;...Keyboard buffer
  65.              JZ        Boot_New                 ;if keypressed, reboot
  66.              XOR       AH,AH                    ;flush....
  67.              INT       16H                      ;...Keyboard Buffer
  68.              JMP       Loop1                    ;And try again
  69. Boot_New:    XOR       AH,AH                    ;flush...
  70.              INT       16H                      ;...Keyboard buffer
  71.              XOR       DX,DX                    ;Zero DX
  72.              INT       19H                      ;Reboot
  73. Entry        ENDP
  74.  
  75. Output       PROC      NEAR
  76.              MOV       AL,[SI]                  ;Get one character
  77.              OR        AL,AL                    ;Is it zero?
  78.              JNZ       Weiter                   ;No, continue
  79.              RET                                ;else return
  80. Weiter:      PUSH      SI                       ;Save SI
  81.              MOV       AH,0EH                   ;Output character...
  82.              INT       10H                      ;...in AL to screen
  83.              POP       SI                       ;restore SI
  84.              INC       SI                       ;Next character
  85.              JMP       SHORT Output             ;repeat loop
  86. Output       ENDP
  87.  
  88.  
  89.  
  90. Text1     DB  'System wird von Platte geladen...',              0
  91. Text2     DB  13, 10, 'Kann nicht von der Festplatte starten.', 10, 13
  92.           DB  'System-Diskette in Laufwerk A: einlegen',        10, 13
  93.           DB  'dann eine Taste drücken.',                       10, 13, 0
  94. Text3     DB  7 ,0
  95.  
  96. ORG       2FDH
  97. CRCSum    DB  0FFH
  98.  
  99. ORG       2FEH
  100.           DB        55H, 0AAH
  101.  
  102. CSEG      ENDS
  103.           END Begin
  104.  
  105. ;-----------------------------------------------------------
  106.  
  107.