19
COMPUTER ARCHITECTURE AND ASSEMBLY LANGUAGE COURSE INSTRUCTOR : SIR AAZAM KHAN MADE BY: SHAHZEB PIRZADA(5701) MUHAMMAD FAIZ(55903)

BOOTABLE OPERATING SYSTEM PPT

Embed Size (px)

Citation preview

COMPUTER ARCHITECTURE AND ASSEMBLY LANGUAGE COURSE

COMPUTER ARCHITECTURE AND ASSEMBLY LANGUAGE COURSEINSTRUCTOR :SIR AAZAM KHAN

MADE BY:SHAHZEB PIRZADA(5701)MUHAMMAD FAIZ(55903)

BOOTABLE OPERATING SYSTEM

BOOT DISK

A boot disk is actually not a computer disk in the shape of a boot. If it was, most disk drives would have a difficult time reading it. Instead, a boot disk is a disk that a computer can start up or "boot" from. The most common type of boot disk is an internal hard drive, which most computers use to start up from. The operating system installed on the hard drive is loaded during the boot process.

BOOT DISKHowever, most computers allow you to boot from other disks, including external Firewire hard drives, CD-ROMs, DVD-ROMs, and floppy disks. In order to function as boot disks, these disks need to have an operating system installed that is understandable by the computer. This can either be a full-blown operating system like Windows or Mac OS X, or a small utility operating system, such as Norton Utilities or Disk Warrior.

BOOT DISKCD and DVD boot disks are often used to start up a computer when the operating system on the internal hard drive won't load. This can happen when bad data blocks or other errors occur on the disk. By running a disk repair utility from the CD or DVD, you can often fix the hard drive and restart from it, using the full operating system.

What is Boot Loader

Boot loaderis a program situated at the first sector of the hard drive; and it is the sector where the boot starts from. BIOS automatically read all content of the first sector to the memory just after the power is turned on, and jump to it. The first sector is also calledMaster Boot Record.Actually it is not obligatory for the first sector of the hard drive to boot something. This name has been formed historically because developers used to boot their operating systems with such mechanism.

How system boots

In order to solve our task we should recall how the system is booting.Lets consider briefly how the system components are interacting when the system is booting (see Fig.1).

After the control has been passed to the address 0000:7C00,Master Boot Record (MBR)starts its work and triggers the Operating System boot.

Lets code

In the next sections we will be directly occupied with the low-level programming we will develop our own boot loader.

Source Code of BOOT LOADER

[BITS 16] ; 16 bit code generation[ORG 0x7C00] ; Origin location; Main programmain:; Label for the start of the main program mov ax,0x0000; Setup the Data Segment register; Location of data is DS:Offset mov ds,ax; This can not be loaded directly it has to be in two steps.; 'mov ds, 0x0000' will NOT work due to limitations on the CPU mov si, HelloWorld; Load the string into position for the procedure. call PutStr; Call/start the procedurejmp $; Never ending loop

Source Code of BOOT LOADER; ProceduresPutStr:; Procedure label/start ; Set up the registers for the interrupt call mov ah,0x0E; The function to display a chacter (teletype) mov bh,0x00; Page number mov bl,0x07; Normal text attribute.nextchar; Internal label (needed to loop round for the next character) lodsb; I think of this as Load String Block ; (Not sure if that's the real meaning though); Loads [SI] into AL and increases SI by one ; Check for end of string '0' or al,al; Sets the zero flag if al = 0 ; (OR outputs 0's where there is a zero bit in the register) jz .return; If the zero flag has been set go to the end of the procedure.; Zero flag gets set when an instruction returns 0 as the answer. int 0x10; Run the BIOS video interrupt jmp .nextchar; Loop back round tothe top.return; Label at the end to jump to when complete ret; Return to main program

Source Code of BOOT LOADER; DataHelloWorld db 'C:\Windows',13,10,0; End Mattertimes 510-($-$$) db 0; Fill the rest with zerosdw 0xAA55The Boot Loader that we have made Assembly Is totally depend on the above Piece of codenasm -f bin -o floppy.img new.asm

Assembly languages Assembly languages are a type of low-level languages for programming computers, microprocessors, micro controllers, and other (usually) integrated circuits. They implement a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on abbreviations (called mnemonics) that help the programmer remember individual instructions, registers, etc. An assembly language family is thus specific to a certain physical (or virtual) computer architecture. This is in contrast to most high-level languages, which are (ideally) portable.

Explanation of Source Code

[BITS 16] [ORG 7C00h]------- An operating System can be 16bit , 32 bit 64bitwe have made the boot loader of 16BIT operating System

--------This is the Address where we want to Run the Operating System. Origin, tells the compiler where the code is going to be in memory after it has been loaded. (hex number)

Command Discription

mov ah,0Eh ------ These are the TeleType Functions.. It will print What is in RegisterMov:: The mnemonic "mov" represents the opcode 10110000 which actually copies the value in the second operand into the register indicated by the first operandAH - 0x0E