home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / CLONBOOT.ZIP / BOOT.ASM next >
Assembly Source File  |  1991-09-26  |  3KB  |  206 lines

  1.  
  2. seg_a    segment    byte public
  3.     assume    cs:seg_a, ds:seg_a
  4.   
  5.     org    0
  6.   
  7. boot    proc    far
  8.   
  9. start:
  10.     jmp    short skp
  11.     nop
  12.  
  13.     db    'IBM 20.0'
  14. d_000B    dw    200h
  15. d_000D    db    1
  16. d_000E    dw    1
  17. d_0010    db    2
  18. d_0011    dw    0e0h
  19.     db    40h,0bh,0f0h
  20. d_0016    dw    9
  21. d_0018    dw    12h
  22. d_001A    dw    2
  23. d_001C    dw    0
  24. d_001E    dw    0
  25.     db    0,0,0,0
  26. d_0024    db    0
  27.     db    0, 29h, 51h, 32h, 9Dh, 18h
  28.     db    'NO NAME    FAT     '
  29.  
  30. skp:    xor    ax,ax
  31.     mov    ss,ax
  32.     mov    sp,7C00h
  33.     call    fixdrv
  34.     mov    ds,bx
  35.     mov    al,[d_0010]
  36.     cbw        
  37.     mul    word ptr [d_0016]
  38.     add    ax,[d_000E]
  39.     push    ax
  40.     xchg    ax,cx
  41.     mov    ax,20h
  42.     mul    word ptr [d_0011]
  43.     mov    bx,[d_000B]
  44.     add    ax,bx
  45.     dec    ax
  46.     div    bx
  47.     push    ax
  48.     add    ax,cx
  49.     mov    ds:[ending],ax
  50.     mov    ax,1000h
  51.     mov    es,ax
  52.     xor    di,di
  53.     pop    cx
  54.     pop    ax
  55.     xor    dx,dx
  56.     call    readsec
  57.     xor    bx,bx
  58.     mov    cx,[d_0011]
  59.  
  60. l_0082:
  61.     mov    di,bx
  62.     push    cx
  63.     mov    cx,0Bh
  64.     mov    si,os2ldr
  65.     repe    cmpsb
  66.     pop    cx
  67.     jz    l_0095
  68.     add    bx,20h
  69.     loop    l_0082
  70.   
  71. l_0095:
  72.     jcxz    l_00DB    
  73.     mov    ax,es:[bx+1Ch]
  74.     xor    dx,dx    
  75.     div    word ptr [d_000B]
  76.     inc    al
  77.     mov    cl,al
  78.     mov    dx,es:[bx+1Ah]
  79.     dec    dx
  80.     dec    dx
  81.     mov    al,[d_000D]
  82.     xor    ah,ah
  83.     mul    dx
  84.     add    ax,ds:[ending]
  85.     adc    dx,0
  86.     mov    bx,2000h
  87.     mov    es,bx
  88.     xor    di,di
  89.     push    es
  90.     push    di
  91.     call    readsec
  92.     mov    bx,ds:[ending]
  93.     mov    dl,[d_0024]
  94.     dw    368dh,offset d_000B    ;lea si,[d_000B]
  95.     mov    ax,1000h
  96.     mov    es,ax
  97.     xor    di,di
  98.     xor    dh,dh
  99.     retf
  100. l_00DB:
  101.     mov    si,d_0172
  102.     jmp    short l_00E3
  103. l_00E0:
  104.     mov    si,d_0152
  105. l_00E3:
  106.     call    putstr
  107.     mov    si,d_0197
  108.     call    putstr
  109.     sti
  110. l_00ED:
  111.     jmp    short l_00ED
  112.   
  113. boot    endp
  114.   
  115. putstr    proc    near
  116. displp:    lodsb
  117.     or    al,al
  118.     jz    done
  119.     mov    ah,0Eh
  120.     mov    bx,7
  121.     int    10h            ; write char al, teletype mode
  122.     jmp    short displp
  123. done:    retn
  124. putstr    endp
  125.   
  126.   
  127. readsec    proc    near
  128. readlp:    push    ax
  129.     push    dx
  130.     push    cx
  131.     add    ax,[d_001C]
  132.     adc    dx,[d_001E]
  133.     div    word ptr [d_0018]
  134.     inc    dl
  135.     mov    bl,dl
  136.     xor    dx,dx        
  137.     div    word ptr [d_001A]
  138.     mov    bh,dl
  139.     mov    dx,ax
  140.     mov    ax,[d_0018]
  141.     sub    al,bl
  142.     inc    ax
  143.     push    ax
  144.     mov    ah,2
  145.     mov    cl,6
  146.     shl    dh,cl
  147.     or    dh,bl
  148.     mov    cx,dx
  149.     xchg    ch,cl
  150.     mov    dl,[d_0024]
  151.     mov    dh,bh
  152.     mov    bx,di
  153.     int    13h        ;  read sectors to memory es:bx
  154.     jc    l_00E0
  155.     pop    bx
  156.     pop    cx
  157.     mov    ax,bx
  158.     mul    word ptr [d_000B]
  159.     add    di,ax
  160.     pop    dx
  161.     pop    ax
  162.     add    ax,bx
  163.     adc    dx,0
  164.     sub    cl,bl
  165.     jg    readlp
  166.     retn
  167. readsec    endp
  168.   
  169.     db    1Dh, 0
  170. d_0152:    db    'A disk read error occurred.', 13,10,0
  171.     db    22h, 0
  172. d_0172:    db    'The file OS2LDR cannot be found.',13,10,0
  173.     db    33h, 0
  174. d_0197:    db    'Restart',0
  175.  
  176. fixdrv    proc    near
  177.     cli
  178.     mov    es,ax
  179.     mov    bx,78h
  180.     lds    si,es:[bx]
  181.     mov    di,4f0h            ;a hopefully safe place 0040:00F0
  182.     mov    es:[bx],di
  183.     mov    es:[bx+2],es
  184.     mov    cx,11
  185.     cld
  186.     rep    movsb
  187.     mov    byte ptr es:[di-2],0fh
  188.     mov    byte ptr es:[di-7],12h
  189.     sti
  190.     mov    dl,0
  191.     int    13h
  192.     mov    bx,7C0h
  193.     ret
  194. fixdrv    endp
  195.  
  196. os2ldr:    db    'OS2LDR     '
  197.     db    40 dup (0)
  198.     db    55h, 0AAh
  199.  
  200. ending    label    word
  201.   
  202. seg_a    ends
  203.   
  204.     end    start
  205.  
  206.