Documentos de Académico
Documentos de Profesional
Documentos de Cultura
AND
BASIC
OPRATING SYSTEM
(SBOS)
In this project we are trying to build a simple operating system based on our knowledge and
learning of the subject Operating System that was taught to us in 4th sem.
The booting part is coded in Assembly language and after the booting the rest will be coded in c+
+ compiler.
1. The BIOS (Basic Input Output System this is a program that comes with
any mother board and it is placed in a chip on the mother board) checks all
the computer components to make sure that they are all working.
2. If all the components are working, the BIOS starts searching for a drive that
might have an operating system. (The BIOS can look in hard drives, floppy
drives, CD-ROM drives etc. The order the BIOS checks can be set it in the
BIOS setup program.
3. The BIOS checks the first drive to see if he has a valid BOOT sector. (A disk
is divided into little regions that are named sectors. The BOOT sector size is
512 bytes in most drives.) If the drive has a valid BOOT sector, the BIOS
loads that sector in to the memory at address 0:7c00 (=31,744) and gives
control to that area of the memory.
4. Now this little program that was loaded from the BOOT sector continues to
load the operating system, and after the operating system is loaded, it
initializes the operating system and gives the control to the operating system.
BOOTING:
Basically Booting is the process of loading the Operating System.
So to make a valid boot sector , we must make sure that it is 512 bytes long
and 0AA55h is present at the offset 510 (or 1FEh).
Boot Sector Programme(Still in process partially complete)
.MODEL SMALL
.CODE
ProgramStart:
; CS = 0 / IP = 7C00h // SS = ? / SP = ?
jmp start ;Here we start the, BIOS gave us now the control.
;///////////////////////////////////////////
;///////////////////////////////////////////
xCursor db 0
yCursor db 0
nSector db 0
nTrack db 0
nSide db 0
nDrive db 0
nTrays db 0
szPlaceMarker db '~~~~',0
szDone db 'Done',0
pOS dw 7E00h
;//Points to were to download the Operating System.
StepRateAndHeadUnloadTime db 0DFh
HeadLoadTimeAndDMAModeFlag db 2h
DelayForMotorTurnOff db 25h
;// (1 = 256) //(2 = 512 bytes)
BytesPerSector db 2h
;// 18 sectors in a track.
SectorsPerTrack db 18
IntersectorGapLength db 1Bh
DataLength db 0FFh
IntersectorGapLengthDuringFormat db 54h
FormatByteValue db 0F6h
HeadSettlingTime db 0Fh
DelayUntilMotorAtNormalSpeed db 8h
DisketteSectorAddress_as_LBA_OfTheDataArea db 0
CylinderNumberToReadFrom db 0
SectorNumberToReadFrom db 0
DisketteSectorAddress_as_LBA_OfTheRootDirectory db 0
;/////////////////////////////////
;/////////////////////////////////
Start:
mov DS,ax
CALL SetNewDisketteParameterTable
;SetNewDisketteParameterTable()
CALL DownloadOS
CALL GetKey ;Call GetKey()
ret
;/////////////////////////////////////
;/////////////////////////////////////
PrintMessage PROC
ContinuPrinting:
INT 10h
INC xCursor
INT 10h
EndPrintingMessage:
cmp yCursor,25
JNE dontMoveCorsurToBegin
Mov yCursor,0
dontMoveCorsurToBegin:
ret
PrintMessage EndP
;//////////////////////////////////////
;//////////////////////////////////////
GetKey PROC
mov ah,0
int 16h ;Wait for a key press.
Ret
GetKey EndP
;///////////////////////////////////////////
;///////////////////////////////////////////
GiveControlToOS PROC
LEA AX,szDone
Call PrintMessage
CALL GetKey
; POP AX
; ret
GiveControlToOS EndP
;///////////////////////////////////
;//Clear Screen.
;///////////////////////////////////
ClearScreen PROC
mov bh,07
mov cx,0
mov dx,184fh
int 10h
Ret
ClearScreen EndP
;/////////////////////////////////
;//PrintPlaceMarker.
;/////////////////////////////////
PrintPlaceMarker PROC
LEA AX,szPlaceMarker
CALL PrintMessage ;Call PrintfMessage()
ret
PrintPlaceMarker EndP
;/////////////////////////////////////////
;/////////////////////////////////////////
SetNewDisketteParameterTable PROC
LEA DX,StepRateAndHeadUnloadTime
;//Get the address of the Disk Parameters Block.
MOV AH,0
INT 13H
ret
SetNewDisketteParameterTable EndP
;///////////////////////////////////
;//DownloadOS
;///////////////////////////////////
DownloadOS PROC
mov nDrive,0
mov nSide,0
mov nTrack,0
mov nSector,1
ContinueDownload:
JNE StayInTrack
CALL PrintPlaceMarker ;Print now '~~~~' so the user would
JE EndDownloadingOS
StayInTrack:
;ReadSector();
Call ReadSector
JMP ContinueDownload
;If diden't yet finish Loading OS.
EndDownloadingOS:
ret
DownloadOS EndP
;////////////////////////////////////////
;//Read Sector.
;////////////////////////////////////////
ReadSector PROC
mov nTrays,0
TryAgain:
mov CH,nTrack
mov CL,nSector ;//Remember: Sectors start with 1, not 0.
mov DH,nSide
mov DL,nDrive
Mov BX,pOS ;//ES:BX points to the address
INT 13h
INT 13h
cmp nTrays,3 ;Chack if you tryed reading
INC nTrays
DisplayError:
LEA AX,szErrorReadingDrive
Call PrintMessage
Call GetKey
mov AH,0 ;Reboot Computer.
INT 19h
EndReadSector:
;ADD WORD PTR pOS,512 ;//Move the pointer
Ret
ReadSector EndP
;////////////////////////////////////
;//
;////////////////////////////////////
END ProgramStart