home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1992 / number2 / boot.asm < prev    next >
Assembly Source File  |  1991-07-22  |  9KB  |  227 lines

  1.                         ASSUME CS:_TEXT, DS:_TEXT, SS:_TEXT
  2. _TEXT                   SEGMENT BYTE PUBLIC 'CODE'
  3.                         ORG 0
  4.  
  5. ProgramStart:           jmp  ProgramSetup
  6.  
  7. BPB                     STRUC
  8. OEM                     db   49h,42h,4Dh,20h,59h,55h,4Bh,21h
  9. BytesPerSector          dw   512
  10. SectorsPerCluster       db   1
  11. ReservedSectors         dw   1
  12. NumberOfFATs            db   2
  13. NumberOfDirEntries      dw   224
  14. TotalSectors            dw   2400
  15. MediaDescriptor         db   0F9h
  16. SectorsPerFAT           dw   7
  17. SectorsPerTrack         dw   15
  18. NumberOfHeads           dw   2
  19. NumberOfHiddenSectors   dw   0
  20. BPB                     ENDS
  21.  
  22. BIOS_Parameter_Block    BPB  <>
  23.  
  24. SkyAttribute            EQU  1Fh
  25. CompanyAttribute        EQU  1Bh
  26. OOPSAttribute           EQU  4Eh
  27. MsgAttribute            EQU  4Fh
  28. InstrucAttribute        EQU  4Bh
  29. ShadowAttribute         EQU  0Bh
  30.  
  31. OOPS_Line1              db   'OOPS!'
  32. OOPS_Line1_Row          EQU  6
  33. OOPS_Line1_Col          EQU  37
  34.  
  35. OOPS_Line2              db   'You''ve accidentally left a data disk'
  36. OOPS_Line2_Row          EQU  7
  37. OOPS_Line2_Col          EQU  22
  38.  
  39. OOPS_Line3              db   'in diskette drive A: while booting.'
  40. OOPS_Line3_Row          EQU  8
  41. OOPS_Line3_Col          EQU  23
  42.  
  43. OOPS_Line4              db   'Please open the drive bay door!'
  44. OOPS_Line4_Row          EQU  10
  45. OOPS_Line4_Col          EQU  25
  46.  
  47. Company_Line1           db   'My Company, Inc.'
  48. Company_Line1_Row       EQU  19
  49. Company_Line1_Col       EQU  33
  50.  
  51. Company_Line2           db   'P.O. Box 100'
  52. Company_Line2_Row       EQU  20
  53. Company_Line2_Col       EQU  34
  54.  
  55. Company_Line3           db   'Mytown, USA 11111'
  56. Company_Line3_Row       EQU  21
  57. Company_Line3_Col       EQU  32
  58.  
  59. MonochromeMode   EQU    7
  60.  
  61.  
  62.                  IDEAL                      ; allow SIZE operator
  63.  
  64. ProgramSetup:    sti
  65.                  mov    ax,0                ; initialize...
  66.                  mov    ss,ax               ; stack...
  67.                  mov    sp,ax               ; registers
  68.  
  69.                  mov    ax,07C0h            ; trick to set...
  70.                  push   ax                  ; CS & IP...
  71.                  mov    ax,OFFSET CS_Loaded ; to appropriate...
  72.                  push   ax                  ; values
  73.                  retf
  74.                                             ; set DS = CS
  75. CS_Loaded:       mov    ax,cs
  76.                  mov    ds,ax
  77.  
  78. Sky:             mov    ah,6                ; Init window
  79.                  mov    al,0                ; Blank entire window
  80.                  mov    bh,SkyAttribute     ; Attribute
  81.                  mov    cx,0                ; Top, left = 0
  82.                  mov    dh,18               ; bottom row
  83.                  mov    dl,79               ; right column
  84.                  int    10h                 ; video services
  85.  
  86.                  mov    bh,CompanyAttribute ; New attribute
  87.                  mov    ch,19               ; top row
  88.                  mov    dh,24               ; bottom row
  89.                  int    10h                 ; video services
  90.  
  91. CheckDisplayMode:
  92.                  mov    ah,0Fh              ; Get display mode
  93.                  int    10h                 ; video services
  94.                  cmp    al,MonochromeMode   ; if mono...
  95.                  je     MonochromeOOPS      ; jump
  96.  
  97. ColorOOPS:       mov    ah,6                ; Init window
  98.                  mov    al,0                ; Blank entire window
  99.                  mov    bh,OOPSAttribute    ; Attribute
  100.                  mov    ch,6                ; Top row
  101.                  mov    cl,20               ; Left column
  102.                  mov    dh,ch               ; bottom row
  103.                  mov    dl,60               ; right column
  104.                  int    10h                 ; video services
  105.  
  106.                  mov    bh,MsgAttribute     ; Attribute
  107.                  mov    ch,7                ; Top row
  108.                  mov    dh,9                ; Bottom row
  109.                  int    10h                 ; video services
  110.  
  111.                  mov    bh,InstrucAttribute ; Attribute
  112.                  mov    ch,10               ; Top row
  113.                  mov    dh,ch               ; Bottom row
  114.                  int    10h                 ; video services
  115.  
  116.                  mov    bh,ShadowAttribute  ; Attribute
  117.                  mov    ch,7                ; Top row
  118.                  mov    cl,61               ; Left column
  119.                  mov    dh,10               ; Bottom row
  120.                  mov    dl,62               ; Right column
  121.                  int    10h                 ; video services
  122.  
  123.                  mov    ch,11               ; Top row
  124.                  mov    cl,22               ; Left column
  125.                  mov    dh,ch               ; Bottom row
  126.                  mov    dl,62               ; Right column
  127.                  int    10h                 ; video services
  128.  
  129.                  jmp    DisplayText
  130.  
  131.  
  132. MonochromeOOPS:  mov    ah,6                ; Init window
  133.                  mov    al,0                ; Blank entire window
  134.                  mov    bh,070h             ; Black on white
  135.                  mov    ch,6                ; Top row
  136.                  mov    cl,20               ; Left column
  137.                  mov    dh,10               ; bottom row
  138.                  mov    dl,60               ; right column
  139.                  int    10h                 ; video services
  140.  
  141. DisplayText:     mov    bp,OFFSET OOPS_Line1  ; Message
  142.                  mov    cx,SIZE OOPS_Line1    ; byte count
  143.                  mov    dh,OOPS_Line1_Row     ; row
  144.                  mov    dl,OOPS_Line1_Col     ; column
  145.                  call   PrintString           ; do it
  146.  
  147.                  mov    bp,OFFSET OOPS_Line2  ; Message
  148.                  mov    cx,SIZE OOPS_Line2    ; byte count
  149.                  mov    dh,OOPS_Line2_Row     ; row
  150.                  mov    dl,OOPS_Line2_Col     ; column
  151.                  call   PrintString           ; do it
  152.  
  153.                  mov    bp,OFFSET OOPS_Line3  ; Message
  154.                  mov    cx,SIZE OOPS_Line3    ; byte count
  155.                  mov    dh,OOPS_Line3_Row     ; row
  156.                  mov    dl,OOPS_Line3_Col     ; column
  157.                  call   PrintString           ; do it
  158.  
  159.                  mov    bp,OFFSET OOPS_Line4  ; Message
  160.                  mov    cx,SIZE OOPS_Line4    ; byte count
  161.                  mov    dh,OOPS_Line4_Row     ; row
  162.                  mov    dl,OOPS_Line4_Col     ; column
  163.                  call   PrintString           ; do it
  164.  
  165.                  mov    bp,OFFSET Company_Line1 ; Message
  166.                  mov    cx,SIZE Company_Line1   ; byte count
  167.                  mov    dh,Company_Line1_Row    ; row
  168.                  mov    dl,Company_Line1_Col    ; column
  169.                  call   PrintString             ; do it
  170.  
  171.                  mov    bp,OFFSET Company_Line2 ; Message
  172.                  mov    cx,SIZE Company_Line2   ; byte count
  173.                  mov    dh,Company_Line2_Row    ; row
  174.                  mov    dl,Company_Line2_Col    ; column
  175.                  call   PrintString             ; do it
  176.  
  177.                  mov    bp,OFFSET Company_Line3 ; Message
  178.                  mov    cx,SIZE Company_Line3   ; byte count
  179.                  mov    dh,Company_Line3_Row    ; row
  180.                  mov    dl,Company_Line3_Col    ; column
  181.                  call   PrintString             ; do it
  182.  
  183. SetCursorForReboot:
  184.                  mov    ah,2                ; Set cursor
  185.                  mov    bh,0                ; page 0
  186.                  mov    dh,22               ; row
  187.                  mov    dl,0                ; column
  188.                  int    10h                 ; video services
  189.  
  190. Delay2Seconds:   mov    ah,0                ; Read the clock
  191.                  int    1Ah                 ; timer services
  192.                  add    dx,40               ; add about 2 seconds
  193.                  mov    bx,dx               ; save in BX
  194. CheckDelay:      int    1Ah                 ; check the time again
  195.                  cmp    dx,bx               ; 2 seconds yet?
  196.                  jne    CheckDelay          ; if not, try again
  197.  
  198. ProgramEnd:      int    25                  ; re-boot computer
  199.  
  200.  
  201.                  MASM                       ; return from IDEAL
  202.  
  203. PrintString      PROC
  204. ;
  205. ;   Input
  206. ;       ds:bp = pointer to string to be printed
  207. ;       dh = row
  208. ;       dl = column
  209. ;       cx = length of string
  210. ;
  211.  
  212. SetCursor:       mov    ah,2                ; set cursor position
  213.                  mov    bh,0                ; page 0
  214.                  int    10h                 ; video services
  215.  
  216. WriteText:       mov    ah,14               ; write character
  217. PrintNextChar:   mov    al,ds:[bp]          ; load char to write
  218.                  int    10h                 ; video services
  219.                  inc    bp                  ; next character
  220.                  loop   PrintNextChar       ; do again
  221.  
  222.                  ret                        ; done
  223. PrintString      ENDP
  224.  
  225. _TEXT            ENDS
  226.                  END    ProgramStart
  227.