home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / FLOPPIES / FDFORM16.ZIP / FDBOOT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-10-26  |  5.8 KB  |  109 lines

  1.              page      66,128
  2. cseg         segment   para public 'CODE'
  3.              assume    cs:cseg
  4.  
  5.              org       100h                     ;Allow Boot-Sector as COM-File
  6. begin:       jmp       short start              ;Jump
  7.              nop
  8. bpb          db        3FH DUP (0)              ;Reserve enough space for BPB
  9.  
  10. start        proc      far
  11.              mov       ax,cs                    ;Get Code Segment
  12.              cmp       ax,7c00h                 ;Is it 7C00H
  13.              jz        tryboot                  ;Yes, Boot-Sector
  14.              mov       si,offset text3          ;Load Error Message
  15.              call      output                   ;Output text
  16.              int       20h                      ;Terminate Program
  17. tryboot:     cli                                ;Clear Interrupts, while modifying stack
  18.              xor       ax,ax                    ;Zero AX
  19.              mov       ss,ax                    ;Set SS...
  20.              mov       sp,7c00h                 ;..and SP below Code
  21.              mov       ax,7b0h                  ;Set Segment-Registers that Offset is 100H
  22.              push      ax                       ;Push Segment twice
  23.              push      ax
  24.              pop       ds                       ;Get Segment in DS
  25.              pop       es                       ;and also in ES
  26.              mov       si,100h                  ;Set Source to 100H
  27.              mov       di,300h                  ;Set Destination to 300H
  28.              mov       cx,100h                  ;Set Count to 512 Bytes (1 Sector)
  29.              rep       movsw                    ;Move Code
  30.              mov       ax,7d0h                  ;New Segment at 7d0h (+20H)
  31.              push      ax                       ;Push Segment three times
  32.              push      ax
  33.              push      ax
  34.              pop       ds                       ;Get new segment in DS
  35.              pop       es                       ;and also in ES
  36.              mov       ax,offset entry          ;Offset of next instruction
  37.              push      ax                       ;Push to stack
  38.              ret                                ;and pop it to CS:IP
  39. start        endp
  40.  
  41. entry        proc      far
  42.              sti                                ;Start Interrupts again
  43.              mov       si,offset text1          ;Move SI to text
  44.              call      output                   ;display to screen
  45.              mov       ax,201h                  ;AH=2 (read sector), AL=1 (count)
  46.              mov       cx,1                     ;CH=0 (Track), CL=1 (Sector)
  47.              mov       dx,128                   ;DH=0 (Head), DL=128 (Fixed Disk C)
  48.              xor       bx,bx                    ;Segment of Transfer buffer
  49.              push      bx                       ;Push to Stack
  50.              pop       es                       ;Get Segment in ES
  51.              mov       bx,7c00h                 ;Offset of Transfer buffer
  52.              push      es                       ;Push Segment...
  53.              push      bx                       ;And Offset to stack
  54.              int       13h                      ;Read from Harddisk
  55.              jc        error                    ;Jump if error
  56.              cmp       word ptr es:7dfeh,0aa55h ;Valid Boot Secotor?
  57.              jnz       error                    ;No, error
  58.              ret                                ;Continue with Boot-Sector of C:
  59.  
  60. error:       mov       si,offset text2          ;Move SI to text
  61.              call      output                   ;display to screen
  62. loop1:       mov       ah,1                     ;Get Status of...
  63.              int       16h                      ;...Keyboard buffer
  64.              jz        boot_new                 ;if keypressed, reboot
  65.              xor       ah,ah                    ;flush....
  66.              int       16h                      ;...Keyboard Buffer
  67.              jmp       loop1                    ;And try again
  68. boot_new:    xor       ah,ah                    ;flush...
  69.              int       16h                      ;...Keyboard buffer
  70.              xor       dx,dx                    ;Zero DX
  71.              int       19h                      ;Reboot
  72. entry        endp
  73.  
  74. output       proc      near
  75.              mov       al,[si]                  ;Get one character
  76.              or        al,al                    ;Is it zero?
  77.              jnz       weiter                   ;No, continue
  78.              ret                                ;else return
  79. weiter:      push      si                       ;Save SI
  80.              mov       ah,0eh                   ;Output character...
  81.              int       10h                      ;...in AL to screen
  82.              pop       si                       ;restore SI
  83.              inc       si                       ;Next character
  84.              jmp       short output             ;repeat loop
  85. output       endp
  86.  
  87.              IF        LANGUAGE EQ 1
  88. text1        db        'FDFORMAT Version 1.6',10,13
  89.              db        'No Systemdisk. Booting from harddisk.',10,13,0
  90. text2        db        'Cannot load from harddisk.',10,13
  91.              db        'Insert Systemdisk and press any key.',10,13,0
  92. text3        db        'Do not execute this COM-File.',10,13,0
  93.              ENDIF
  94.  
  95.              IF        LANGUAGE EQ 49
  96. text1        db        'FDFORMAT Version 1.6',10,13
  97.              db        'Keine Systemdiskette. Starten von Festplatte.',10,13,0
  98. text2        db        'Kann nicht von der Festplatte starten.',10,13
  99.              db        'System-Diskette in Laufwerk A: einlegen',10,13
  100.              db        'Anschließend eine Taste drücken',10,13,0
  101. text3        db        'Diese Datei nicht ausführen.',7,10,13,0
  102.              ENDIF
  103.  
  104.              org       2feh
  105.              db        55h,0aah
  106.  
  107. cseg         ends
  108.              end          begin
  109.