pengembangan sistem operasi

62
Sistem Operasi Tugas Kecil Sistem Operasi oleh Miftakhul Afrizal Ricko P / 18212014 Rizal Kurnia R / 18212015 Hilman Ramadhan / 18212024 Ghani Ruhman / 18212035 INSTITUT TEKNOLOGI BANDUNG SEKOLAH TEKNIK ELEKTRO DAN INFORMATIKA SISTEM DAN TEKNOLOGI INFORMASI BANDUNG 2014

Upload: ghani-ruhman

Post on 19-Aug-2015

233 views

Category:

Documents


2 download

DESCRIPTION

Pengembangan Sistem Operasi

TRANSCRIPT

Sistem Operasi Tugas Kecil Sistem Operasi oleh Miftakhul Afrizal Ricko P/ 18212014 Rizal Kurnia R/ 18212015 Hilman Ramadhan/ 18212024 Ghani Ruhman/ 18212035 INSTITUT TEKNOLOGI BANDUNG SEKOLAH TEKNIK ELEKTRO DAN INFORMATIKA SISTEM DAN TEKNOLOGI INFORMASI BANDUNG 2014 Tutorial Instalasi Sistem Operasi InstalasisistemoperasidilakukanmenggunakanpanduanyangadapadaBrokenthorn.Berikut merupakanlangkah-langkahyangdiperlukanuntukmenjalankansistemoperasibuatan Brokenthorn. Bootloaders 1 - Tutorial 3 Untuk membuat sebuah Bootloader, digunakan sebuah bahasa assembly untuk mengakses alamat secara langsung. Berikut merupakan syntax dari sebuah Bootloader sederhana. Boot1.asm ;********************************************* ;Boot1.asm ;- A Simple Bootloader ; ;Operating Systems Development Tutorial ;********************************************* org0x7c00; We are loaded by BIOS at 0x7C00 bits16; We are still in 16 bit Real Mode Start: cli; Clear all Interrupts hlt; halt the system times 510 - ($-$$) db 0; We have to be 512 bytes. Clear the rest of the bytes with 0 dw 0xAA55; Boot Signiture NASM Hal berikutnya yang perlu dilakukan adalah dengan melakukan assembly pada Boot1.asm dengan menggunkan NASM.

Cara menggunakan NASM adalah dengan terlebih dahulu menginstalasinya. Installer dari NASM bisa didapatkan dari situs utama NASM. Setelah instalasi dilakukan, masukkan direktori menuju NASMsebagaiPATHpadakomputeranda.Denganbegitukomandonasmdapatdigunakan. Berikut merupakan akhir dari tahap-tahap di atas. Berikut merupakan syntax untuk melakukan assembly pada Boot1.asm Virtual Floppy Drive LangkahberikutnyayangperludilakukanuntukmembuatBootloadersederhanaadalahdengan membuat floppy disk virtual. Terdapat beberapa alternatif yang dapat dilakukan untuk membuat floppy disk virtual, berdasarkan pengalaman, yaitu dengan menggunakan VFD untuk pengembangan sistem operasi pada Windows 732-bitdanImDiskuntukpengembangansistemoperasipadaWindows8.164-bit.Berikut merupakan alternatif pertama, yaitu VFD pada pembuatan Bootloader ini. Berikut merupakan penjelasan alternatif kedua, yaitu ImDisk pada pembuatan Bootloader ini. Copying to the Bootsector Langkah berikutnya adalah dengan mengkopi Boot1.bin, yang merupakan Bootloader yang telah dibuat, kepada floppy disk virtual yang telah dibuat. Dalammelakukanhalinipunterdapatbeberapaalternatif,bergantungkepadasistemoperasi komputer yang digunakan. Untuk Windows 7 32-bit,tools yang dapat digunakan adalah dengan PartCopy.SedangkanuntukWindows8.164-bit,toolsyangdapatdigunakanadalahdengan MKBT. Berikut merupakan penjelasan penggunaan PartCopy. Berikut merupakan penjelasan dari penggunaan MKBT PC Emulator Dalam pengembangan sistem operasi sederhana ini, digunakan PC Emulator untuk mensimulasikan sistem operasi yang dikembangkan. PC Emulator yang digunakan adalah Bochs. Untukpenggunaandanaplikasinyadalampengembangansistemoperasidapatdilihatpada penjelasan berikut. Hasil akhir dari penggunaan langkah-langkah di atas adalah sebagai berikut. Bootloaders 2 - Tutorial 4 Berdasarkan teori tersebut, dihasilkan kode sebagai berikut. Boot1.asm ;********************************************* ;Boot1.asm ;- A Simple Bootloader ; ;Operating Systems Development Tutorial ;********************************************* bits16; We are still in 16 bit Real Mode org0x7c00; We are loaded by BIOS at 0x7C00 start:jmp loader; jump over OEM block ;*************************************************; ;OEM Parameter block ;*************************************************; ; Error Fix 2 - Removing the ugly TIMES directive ------------------------------------- ;;TIMES 0Bh-$+start DB 0; The OEM Parameter Block is exactally 3 bytes ; from where we are loaded at. This fills in those ; 3 bytes, along with 8 more. Why? bpbOEMdb "My OS "; This member must be exactally 8 bytes. It is just ; the name of your OS :) Everything else remains the same. bpbBytesPerSector:DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs:DB 2 bpbRootEntries:DW 224 bpbTotalSectors: DW 2880 bpbMedia:DB 0xF0 bpbSectorsPerFAT:DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder: DW 2 bpbHiddenSectors:DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber: DB 0 bsUnused:DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber:DD 0xa0a1a2a3 bsVolumeLabel: DB "MOS FLOPPY " bsFileSystem:DB "FAT12 " msgdb"Welcome to My Operating System!", 0; the string to print ;*************************************** ;Prints a string ;DS=>SI: 0 terminated string ;*************************************** Print: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPrintDone; Yep, null terminator found-bail out movah,0eh; Nope-Print the character int10h jmpPrint; Repeat until null terminator found PrintDone: ret; we are done, so return ;*************************************************; ;Bootloader Entry Point ;*************************************************; loader: xorax, ax; Setup segments to insure they are 0. Remember that movds, ax; we have ORG 0x7c00. This means all addresses are based moves, ax; from 0x7c00:0. Because the data segments are within the same ; code segment, null em. movsi, msg; our message to print callPrint; call our print function xorax, ax; clear ax int0x12; get the amount of KB from the BIOS cli; Clear all Interrupts hlt; halt the system times 510 - ($-$$) db 0; We have to be 512 bytes. Clear the rest of the bytes with 0 dw 0xAA55; Boot Signiture Lakukan kembali langkah-langkah pada bagian sebelumnya, yaitu: 1.Assembly file Boot1.asm menjadi Boot1.bin 2.Copy Bootloader (Boot1.bin) ke Bootsector (Virtual Floppy) 3.Jalankan pada bochs Hasil akhir dari langkah-langkah tersebut adalah sebagai berikut: Bootloaders 3 - Tutorial 5 Berdasarkan teori tersebut, dihasilkan kode sebagai berikut. Boot1.asm ;********************************************* ;Boot1.asm ;- A Simple Bootloader ; ;Operating Systems Development Tutorial ;********************************************* bits16; We are still in 16 bit Real Mode org0x7c00; We are loaded by BIOS at 0x7C00 start:jmp loader; jump over OEM block ;*************************************************; ;OEM Parameter block / BIOS Parameter Block ;*************************************************; TIMES 0Bh-$+start DB 0 bpbBytesPerSector:DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors:DW 2880 bpbMedia:DB 0xF0 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder: DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber: DB 0 bsUnused:DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber:DD 0xa0a1a2a3 bsVolumeLabel: DB "MOS FLOPPY " bsFileSystem:DB "FAT12 " ;*************************************** ;Prints a string ;DS=>SI: 0 terminated string ;*************************************** Print: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPrintDone; Yep, null terminator found-bail out movah,0eh; Nope-Print the character int10h jmpPrint; Repeat until null terminator found PrintDone: ret; we are done, so return ;*************************************************; ;Bootloader Entry Point ;*************************************************; loader: .Reset: movah, 0; reset floppy disk function movdl, 0; drive 0 is floppy drive int0x13; call BIOS jc.Reset; If Carry Flag (CF) is set, there was an error. Try resetting again movax, 0x1000; we are going to read sector to into address 0x1000:0 moves, ax xorbx, bx movah, 0x02 ; read floppy sector function moval, 1; read 1 sector movch, 1; we are reading the second sector past us, so its still on track 1 movcl, 2; sector to read (The second sector) movdh, 0; head number movdl, 0; drive number. Remember Drive 0 is floppy drive. int0x13; call BIOS - Read the sector jmp0x1000:0x0; jump to execute the sector! times 510 - ($-$$) db 0; We have to be 512 bytes. Clear the rest of the bytes with 0 dw 0xAA55; Boot Signiture ; End of sector 1, beginning of sector 2 --------------------------------- org 0x1000; This sector is loaded at 0x1000:0 by the bootsector cli; just halt the system hlt Lakukan kembali langkah-langkah pada bagian sebelumnya, yaitu: 1.Assembly file Boot1.asm menjadi Boot1.bin 2.Copy Bootloader (Boot1.bin) ke Bootsector (Virtual Floppy) 3.Jalankan pada bochs Hasil akhir dari langkah-langkah tersebut adalah sebagai berikut: Error terjadi karena Boot1.asm belum selesai dikembangkan. Bootloaders 4- Tutorial 6 Berdasarkan teori tersebut, dibutuhkan beberapa file yang harus dibentuk. Berikut merupakan keseluruhan file tersebut. Boot1.asm ;********************************************* ;Boot1.asm ;- A Simple Bootloader ; ;Operating Systems Development Series ;********************************************* bits16; we are in 16 bit real mode org0; we will set regisers later start:jmpmain; jump to start of bootloader ;********************************************* ;BIOS Parameter Block ;********************************************* ; BPB Begins 3 bytes from start. We do a far jump, which is 3 bytes in size. ; If you use a short jump, add a "nop" after it to offset the 3rd byte. bpbOEMdb "My OS "; OEM identifier (Cannot exceed 8 bytes!) bpbBytesPerSector:DW 512 bpbSectorsPerCluster:DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xf8;; 0xF1 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder:DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber:DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber:DD 0xa0a1a2a3 bsVolumeLabel:DB "MOS FLOPPY " bsFileSystem:DB "FAT12 " ;************************************************; ;Prints a string ;DS=>SI: 0 terminated string ;************************************************; Print: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPrintDone; Yep, null terminator found-bail out movah, 0eh ; Nope-Print the character int10h jmpPrint; Repeat until null terminator found PrintDone: ret; we are done, so return ;************************************************; ; Reads a series of sectors ; CX=>Number of sectors to read ; AX=>Starting sector ; ES:BX=>Buffer to read to ;************************************************; ReadSectors: .MAIN mov di, 0x0005; five retries for error .SECTORLOOP pushax pushbx pushcx callLBACHS; convert starting sector to CHS mov ah, 0x02; BIOS read sector mov al, 0x01; read one sector mov ch, BYTE [absoluteTrack]; track mov cl, BYTE [absoluteSector] ; sector mov dh, BYTE [absoluteHead] ; head mov dl, BYTE [bsDriveNumber]; drive int 0x13; invoke BIOS jnc .SUCCESS; test for read error xor ax, ax; BIOS reset disk int 0x13; invoke BIOS dec di; decrement error counter pop cx pop bx pop ax jnz .SECTORLOOP ; attempt to read again int 0x18 .SUCCESS mov si, msgProgress callPrint pop cx pop bx pop ax add bx, WORD [bpbBytesPerSector]; queue next buffer inc ax; queue next sector loop.MAIN ; read next sector ret ;************************************************; ; Convert CHS to LBA ; LBA = (cluster - 2) * sectors per cluster ;************************************************; ClusterLBA: sub ax, 0x0002; zero base cluster number xor cx, cx mov cl, BYTE [bpbSectorsPerCluster] ; convert byte to word mul cx add ax, WORD [datasector] ; base data sector ret ;************************************************; ; Convert LBA to CHS ; AX=>LBA Address to convert ; ; absolute sector = (logical sector / sectors per track) + 1 ; absolute head = (logical sector / sectors per track) MOD number of heads ; absolute track= logical sector / (sectors per track * number of heads) ; ;************************************************; LBACHS: xor dx, dx; prepare dx:ax for operation div WORD [bpbSectorsPerTrack] ; calculate inc dl; adjust for sector 0 mov BYTE [absoluteSector], dl xor dx, dx; prepare dx:ax for operation div WORD [bpbHeadsPerCylinder]; calculate mov BYTE [absoluteHead], dl mov BYTE [absoluteTrack], al ret ;********************************************* ;Bootloader Entry Point ;********************************************* main: ;---------------------------------------------------- ; code located at 0000:7C00, adjust segment registers ;---------------------------------------------------- cli; disable interrupts mov ax, 0x07C0; setup registers to point to our segment mov ds, ax mov es, ax mov fs, ax mov gs, ax ;---------------------------------------------------- ; create stack ;---------------------------------------------------- mov ax, 0x0000; set the stack mov ss, ax mov sp, 0xFFFF sti; restore interrupts ;---------------------------------------------------- ; Display loading message ;---------------------------------------------------- mov si, msgLoading callPrint

;---------------------------------------------------- ; Load root directory table ;---------------------------------------------------- LOAD_ROOT: ; compute size of root directory and store in "cx" xor cx, cx xor dx, dx mov ax, 0x0020 ; 32 byte directory entry mul WORD [bpbRootEntries]; total size of directory div WORD [bpbBytesPerSector] ; sectors used by directory xchgax, cx

; compute location of root directory and store in "ax" mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT] ; sectors used by FATs add ax, WORD [bpbReservedSectors] ; adjust for bootsector mov WORD [datasector], ax ; base of root directory add WORD [datasector], cx

; read root directory into memory (7C00:0200) mov bx, 0x0200; copy root dir above bootcode callReadSectors ;---------------------------------------------------- ; Find stage 2 ;---------------------------------------------------- ; browse root directory for binary image mov cx, WORD [bpbRootEntries] ; load loop counter mov di, 0x0200; locate first root entry .LOOP: pushcx mov cx, 0x000B; eleven character name mov si, ImageName ; image name to find pushdi repcmpsb ; test for entry match pop di jeLOAD_FAT pop cx add di, 0x0020; queue next directory entry loop.LOOP jmp FAILURE ;---------------------------------------------------- ; Load FAT ;---------------------------------------------------- LOAD_FAT: ; save starting cluster of boot image mov si, msgCRLF callPrint mov dx, WORD [di + 0x001A] mov WORD [cluster], dx; file's first cluster

; compute size of FAT and store in "cx" xor ax, ax mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT] ; sectors used by FATs mov cx, ax ; compute location of FAT and store in "ax" mov ax, WORD [bpbReservedSectors] ; adjust for bootsector

; read FAT into memory (7C00:0200) mov bx, 0x0200; copy FAT above bootcode callReadSectors ; read image file into memory (0050:0000) mov si, msgCRLF callPrint mov ax, 0x0050 mov es, ax; destination for image mov bx, 0x0000; destination for image pushbx ;---------------------------------------------------- ; Load Stage 2 ;---------------------------------------------------- LOAD_IMAGE: mov ax, WORD [cluster]; cluster to read pop bx; buffer to read into callClusterLBA; convert cluster to LBA xor cx, cx mov cl, BYTE [bpbSectorsPerCluster] ; sectors to read callReadSectors pushbx

; compute next cluster mov ax, WORD [cluster]; identify current cluster mov cx, ax; copy current cluster mov dx, ax; copy current cluster shr dx, 0x0001; divide by two add cx, dx; sum for (3/2) mov bx, 0x0200; location of FAT in memory add bx, cx; index into FAT mov dx, WORD [bx] ; read two bytes from FAT testax, 0x0001 jnz .ODD_CLUSTER

.EVEN_CLUSTER: and dx, 0000111111111111b ; take low twelve bits jmp .DONE .ODD_CLUSTER: shr dx, 0x0004; take high twelve bits

.DONE: mov WORD [cluster], dx; store new cluster cmp dx, 0x0FF0; test for end of file jbLOAD_IMAGE

DONE: mov si, msgCRLF callPrint pushWORD 0x0050 pushWORD 0x0000 retf

FAILURE: mov si, msgFailure callPrint mov ah, 0x00 int 0x16; await keypress int 0x19; warm boot computer absoluteSector db 0x00 absoluteHead db 0x00 absoluteTrackdb 0x00 datasectordw 0x0000 cluster dw 0x0000 ImageName db "KRNLDRSYS" msgLoadingdb 0x0D, 0x0A, "Loading Boot Image ", 0x0D, 0x0A, 0x00 msgCRLF db 0x0D, 0x0A, 0x00 msgProgress db ".", 0x00 msgFailuredb 0x0D, 0x0A, "ERROR : Press Any Key to Reboot", 0x0A, 0x00 TIMES 510-($-$$) DB 0 DW 0xAA55 Stage2.asm ;********************************************* ;Stage2.asm ;- Second Stage Bootloader ; ;Operating Systems Development Series ;********************************************* org 0x0; offset to 0, we will set segments later bits 16; we are still in real mode ; we are loaded at linear address 0x10000 jmp main; jump to main ;*************************************************; ;Prints a string ;DS=>SI: 0 terminated string ;************************************************; Print: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPrintDone; Yep, null terminator found-bail out movah,0eh; Nope-Print the character int10h jmpPrint; Repeat until null terminator found PrintDone: ret; we are done, so return ;*************************************************; ;Second Stage Loader Entry Point ;************************************************; main: cli; clear interrupts pushcs; Insure DS=CS popds movsi, Msg callPrint cli; clear interrupts to prevent triple faults hlt; hault the syst ;*************************************************; ;Data Section ;************************************************; Msgdb"Preparing to load operating system...",13,10,0 Lakukan kembali langkah-langkah seperti pada bagian Bootloaders1, yaitu: 1.Assembly file Boot1.asm menjadi Boot1.bin 2.Copy Bootloader (Boot1.bin) ke Bootsector (Virtual Floppy) 3.Assembly file Stage2.asm menjadi KRNLDR.SYS 4.Copy KRNLDR.SYS 5.Jalankan pada bochs Hasil akhir dari langkah-langkah tersebut adalah sebagai berikut: Enabling A20 - Tutorial 9 Berdasarkan teori tersebut, dibutuhkan beberapa file yang harus dibentuk. Berikut merupakan keseluruhan file tersebut. Boot1.asm ;********************************************* ;Boot1.asm ;- A Simple Bootloader ; ;Operating Systems Development Tutorial ;********************************************* bits16; we are in 16 bit real mode org0; we will set regisers later start:jmpmain; jump to start of bootloader ;********************************************* ;BIOS Parameter Block ;********************************************* ; BPB Begins 3 bytes from start. We do a far jump, which is 3 bytes in size. ; If you use a short jump, add a "nop" after it to offset the 3rd byte. bpbOEMdb "My OS " bpbBytesPerSector:DW 512 bpbSectorsPerCluster:DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xf0;; 0xF1 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder:DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber:DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber:DD 0xa0a1a2a3 bsVolumeLabel:DB "MOS FLOPPY " bsFileSystem:DB "FAT12 " ;************************************************; ;Prints a string ;DS=>SI: 0 terminated string ;************************************************; Print: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPrintDone; Yep, null terminator found-bail out movah, 0eh ; Nope-Print the character int10h jmpPrint; Repeat until null terminator found PrintDone: ret; we are done, so return absoluteSector db 0x00 absoluteHead db 0x00 absoluteTrackdb 0x00 ;************************************************; ; Convert CHS to LBA ; LBA = (cluster - 2) * sectors per cluster ;************************************************; ClusterLBA: sub ax, 0x0002; zero base cluster number xor cx, cx mov cl, BYTE [bpbSectorsPerCluster] ; convert byte to word mul cx add ax, WORD [datasector] ; base data sector ret ;************************************************; ; Convert LBA to CHS ; AX=>LBA Address to convert ; ; absolute sector = (logical sector / sectors per track) + 1 ; absolute head = (logical sector / sectors per track) MOD number of heads ; absolute track= logical sector / (sectors per track * number of heads) ; ;************************************************; LBACHS: xor dx, dx; prepare dx:ax for operation div WORD [bpbSectorsPerTrack] ; calculate inc dl; adjust for sector 0 mov BYTE [absoluteSector], dl xor dx, dx; prepare dx:ax for operation div WORD [bpbHeadsPerCylinder]; calculate mov BYTE [absoluteHead], dl mov BYTE [absoluteTrack], al ret ;************************************************; ; Reads a series of sectors ; CX=>Number of sectors to read ; AX=>Starting sector ; ES:BX=>Buffer to read to ;************************************************; ReadSectors: .MAIN mov di, 0x0005; five retries for error .SECTORLOOP pushax pushbx pushcx callLBACHS; convert starting sector to CHS mov ah, 0x02; BIOS read sector mov al, 0x01; read one sector mov ch, BYTE [absoluteTrack]; track mov cl, BYTE [absoluteSector] ; sector mov dh, BYTE [absoluteHead] ; head mov dl, BYTE [bsDriveNumber]; drive int 0x13; invoke BIOS jnc .SUCCESS; test for read error xor ax, ax; BIOS reset disk int 0x13; invoke BIOS dec di; decrement error counter pop cx pop bx pop ax jnz .SECTORLOOP ; attempt to read again int 0x18 .SUCCESS mov si, msgProgress callPrint pop cx pop bx pop ax add bx, WORD [bpbBytesPerSector]; queue next buffer inc ax; queue next sector loop.MAIN ; read next sector ret ;********************************************* ;Bootloader Entry Point ;********************************************* main: ;---------------------------------------------------- ; code located at 0000:7C00, adjust segment registers ;---------------------------------------------------- cli; disable interrupts mov ax, 0x07C0; setup registers to point to our segment mov ds, ax mov es, ax mov fs, ax mov gs, ax ;---------------------------------------------------- ; create stack ;---------------------------------------------------- mov ax, 0x0000; set the stack mov ss, ax mov sp, 0xFFFF sti; restore interrupts ;---------------------------------------------------- ; Display loading message ;---------------------------------------------------- mov si, msgLoading callPrint

;---------------------------------------------------- ; Load root directory table ;---------------------------------------------------- LOAD_ROOT: ; compute size of root directory and store in "cx" xor cx, cx xor dx, dx mov ax, 0x0020 ; 32 byte directory entry mul WORD [bpbRootEntries]; total size of directory div WORD [bpbBytesPerSector] ; sectors used by directory xchgax, cx

; compute location of root directory and store in "ax" mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT] ; sectors used by FATs add ax, WORD [bpbReservedSectors] ; adjust for bootsector mov WORD [datasector], ax ; base of root directory add WORD [datasector], cx

; read root directory into memory (7C00:0200) mov bx, 0x0200; copy root dir above bootcode callReadSectors ;---------------------------------------------------- ; Find stage 2 ;---------------------------------------------------- ; browse root directory for binary image mov cx, WORD [bpbRootEntries] ; load loop counter mov di, 0x0200; locate first root entry .LOOP: pushcx mov cx, 0x000B; eleven character name mov si, ImageName ; image name to find pushdi repcmpsb ; test for entry match pop di jeLOAD_FAT pop cx add di, 0x0020; queue next directory entry loop.LOOP jmp FAILURE ;---------------------------------------------------- ; Load FAT ;---------------------------------------------------- LOAD_FAT: ; save starting cluster of boot image mov si, msgCRLF callPrint mov dx, WORD [di + 0x001A] mov WORD [cluster], dx; file's first cluster

; compute size of FAT and store in "cx" xor ax, ax mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT] ; sectors used by FATs mov cx, ax ; compute location of FAT and store in "ax" mov ax, WORD [bpbReservedSectors] ; adjust for bootsector

; read FAT into memory (7C00:0200) mov bx, 0x0200; copy FAT above bootcode callReadSectors ; read image file into memory (0050:0000) mov si, msgCRLF callPrint mov ax, 0x0050 mov es, ax; destination for image mov bx, 0x0000; destination for image pushbx ;---------------------------------------------------- ; Load Stage 2 ;---------------------------------------------------- LOAD_IMAGE: mov ax, WORD [cluster]; cluster to read pop bx; buffer to read into callClusterLBA; convert cluster to LBA xor cx, cx mov cl, BYTE [bpbSectorsPerCluster] ; sectors to read callReadSectors pushbx

; compute next cluster mov ax, WORD [cluster]; identify current cluster mov cx, ax; copy current cluster mov dx, ax; copy current cluster shr dx, 0x0001; divide by two add cx, dx; sum for (3/2) mov bx, 0x0200; location of FAT in memory add bx, cx; index into FAT mov dx, WORD [bx] ; read two bytes from FAT testax, 0x0001 jnz .ODD_CLUSTER

.EVEN_CLUSTER: and dx, 0000111111111111b ; take low twelve bits jmp .DONE .ODD_CLUSTER: shr dx, 0x0004; take high twelve bits

.DONE: mov WORD [cluster], dx; store new cluster cmp dx, 0x0FF0; test for end of file jbLOAD_IMAGE

DONE: mov si, msgCRLF callPrint pushWORD 0x0050 pushWORD 0x0000 retf

FAILURE: mov si, msgFailure callPrint mov ah, 0x00 int 0x16; await keypress int 0x19; warm boot computer datasectordw 0x0000 cluster dw 0x0000 ImageName db "KRNLDRSYS" msgLoadingdb 0x0D, 0x0A, "Loading Boot Image ", 0x0D, 0x0A, 0x00 msgCRLF db 0x0D, 0x0A, 0x00 msgProgress db ".", 0x00 msgFailuredb 0x0D, 0x0A, "MISSING OR CURRUPT KRNLDR. Press Any Key to Reboot", 0x0D, 0x0A, 0x00 TIMES 510-($-$$) DB 0 DW 0xAA55 Stage2.asm ;******************************************************* ; ;Stage2.asm ;Stage2 Bootloader ; ;OS Development Series ;******************************************************* bits16 ; Remember the memory map-- 0x500 through 0x7bff is unused above the BIOS data area. ; We are loaded at 0x500 (0x50:0) org 0x500 jmpmain; go to start ;******************************************************* ;Preprocessor directives ;******************************************************* %include "stdio.inc"; basic i/o routines %include "Gdt.inc"; Gdt routines %include "A20.inc" ;******************************************************* ;Data Section ;******************************************************* LoadingMsg db "Preparing to load operating system...", 0x0D, 0x0A, 0x00 ;******************************************************* ;STAGE 2 ENTRY POINT ; ;-Store BIOS information ;-Load Kernel ;-Install GDT; go into protected mode (pmode) ;-Jump to Stage 3 ;******************************************************* main: ;-------------------------------; ; Setup segments and stack; ;-------------------------------; cli; clear interrupts xorax, ax; null segments movds, ax moves, ax movax, 0x9000; stack begins at 0x9000-0xffff movss, ax movsp, 0xFFFF sti; enable interrupts ;-------------------------------; ; Print loading message; ;-------------------------------; movsi, LoadingMsg callPuts16 ;-------------------------------; ; Install our GDT; ;-------------------------------; callInstallGDT; install our GDT ;-------------------------------; ; Enable A20; ;-------------------------------; callEnableA20_KKbrd_Out ;-------------------------------; ; Go into pmode; ;-------------------------------; cli; clear interrupts moveax, cr0; set bit 0 in cr0--enter pmode oreax, 1 movcr0, eax jmpCODE_DESC:Stage3; far jump to fix CS. ; Note: Do NOT re-enable interrupts! Doing so will triple fault! ; We will fix this in Stage 3. ;****************************************************** ;ENTRY POINT FOR STAGE 3 ;****************************************************** bits 32 Stage3: ;-------------------------------; ; Set registers ; ;-------------------------------; movax, DATA_DESC; set data segments to data selector (0x10) movds, ax movss, ax moves, ax movesp, 90000h; stack begins from 90000h cli hlt A20.inc ;******************************************** ;Enable A20 address line ; ;OS Development Series ;******************************************** %ifndef __A20_INC_67343546FDCC56AAB872_INCLUDED__ %define __A20_INC_67343546FDCC56AAB872_INCLUDED__ bits16 ;---------------------------------------------- ; Enables a20 line through keyboard controller ;---------------------------------------------- EnableA20_KKbrd: cli pushax moval, 0xdd; send enable a20 address line command to controller out0x64, al popax ret ;-------------------------------------------- ; Enables a20 line through output port ;-------------------------------------------- EnableA20_KKbrd_Out: cli pusha callwait_input mov al,0xAD out 0x64,al; disable keyboard callwait_input mov al,0xD0 out 0x64,al; tell controller to read output port callwait_output inal,0x60 pusheax ; get output port data and store it callwait_input mov al,0xD1 out 0x64,al; tell controller to write output port callwait_input pop eax oral,2; set bit 1 (enable a20) out 0x60,al; write out data back to the output port callwait_input mov al,0xAE; enable keyboard out 0x64,al callwait_input popa sti ret ; wait for input buffer to be clear wait_input: inal,0x64 testal,2 jnz wait_input ret ; wait for output buffer to be clear wait_output: inal,0x64 testal,1 jzwait_output ret ;-------------------------------------- ; Enables a20 line through bios ;-------------------------------------- EnableA20_Bios: pusha movax, 0x2401 int0x15 popa ret ;------------------------------------------------- ; Enables a20 line through system control port A ;------------------------------------------------- EnableA20_SysControlA: pushax moval, 2 out0x92, al popax ret %endif Gdt.inc ;************************************************* ;Gdt.inc ;-GDT Routines ; ;OS Development Series ;************************************************* %ifndef __GDT_INC_67343546FDCC56AAB872_INCLUDED__ %define __GDT_INC_67343546FDCC56AAB872_INCLUDED__ bits16 ;******************************************* ; InstallGDT() ;- Install our GDT ;******************************************* InstallGDT: cli; clear interrupts pusha; save registers lgdt [toc]; load GDT into GDTR sti ; enable interrupts popa ; restore registers ret ; All done! ;******************************************* ; Global Descriptor Table (GDT) ;******************************************* gdt_data:dd 0; null descriptor dd 0 ; gdt code:; code descriptor dw 0FFFFh ; limit low dw 0; base low db 0; base middle db 10011010b; access db 11001111b; granularity db 0; base high ; gdt data:; data descriptor dw 0FFFFh ; limit low (Same as code)10:56 AM 7/8/2007 dw 0; base low db 0; base middle db 10010010b; access db 11001111b; granularity db 0; base high end_of_gdt: toc:dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT) dd gdt_data ; base of GDT ; give the descriptor offsets names %define NULL_DESC 0 %define CODE_DESC 0x8 %define DATA_DESC 0x10 %endif ;__GDT_INC_67343546FDCC56AAB872_INCLUDED__ stdio.inc ;************************************************* ;stdio.inc ;-Input/Output routines ; ;OS Development Series ;************************************************* %ifndef __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ %define __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ ;************************************************; ;Puts16 () ;-Prints a null terminated string ;DS=>SI: 0 terminated string ;************************************************; bits16 Puts16: pusha; save registers .Loop1: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPuts16Done; Yep, null terminator found-bail out movah, 0eh ; Nope-Print the character int10h; invoke BIOS jmp.Loop1 ; Repeat until null terminator found Puts16Done: popa; restore registers ret; we are done, so return %endif ;__STDIO_INC_67343546FDCC56AAB872_INCLUDED__ Lakukan kembali langkah-langkah seperti pada bagian Bootloaders1, yaitu: 1.Assembly file Boot1.asm menjadi Boot1.bin 2.Copy Bootloader (Boot1.bin) ke Bootsector (Virtual Floppy) 3.Assembly file Stage2.asm menjadi KRNLDR.SYS 4.Copy KRNLDR.SYS 5.Jalankan pada bochs Hasil akhir dari langkah-langkah tersebut adalah sebagai berikut: Prepare for the Kernel Berdasarkanteoritersebut,dibutuhkanbeberapafileyangharusdibentuk.Fileyangdibutuhkan tidakterlaluberbedadibandingkandenganlangkahsebelumnya.Tambahanfilepadabagianini adalah sebagai berikut. common.inc %ifndef _COMMON_INC_INCLUDED %define _COMMON_INC_INCLUDED ; where the kernel is to be loaded to in protected mode %define IMAGE_PMODE_BASE 0x100000 ; where the kernel is to be loaded to in real mode %define IMAGE_RMODE_BASE 0x3000 ; kernel name (Must be 11 bytes) ImageName db "KRNLSYS" ; size of kernel image in bytes ImageSize db 0 %endif Fat12.inc ;******************************************************* ; ;Fat12.inc ;FAT12 filesystem for 3-1/2 floppies ; ;OS Development Series ;******************************************************* %ifndef __FAT12_INC_67343546FDCC56AAB872_INCLUDED__ %define __FAT12_INC_67343546FDCC56AAB872_INCLUDED__ bits16 %include "Floppy16.inc"; the erm.. floppy driver %define ROOT_OFFSET 0x2e00 %define FAT_SEG 0x2c0 %define ROOT_SEG 0x2e0 ;******************************************* ; LoadRoot () ;- Load Root Directory Table to 0x7e00 ;******************************************* LoadRoot: pusha; store registers pushes ; compute size of root directory and store in "cx" xor cx, cx; clear registers xor dx, dx mov ax, 32; 32 byte directory entry mul WORD [bpbRootEntries]; total size of directory div WORD [bpbBytesPerSector]; sectors used by directory xchgax, cx; move into AX ; compute location of root directory and store in "ax" mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT]; sectors used by FATs add ax, WORD [bpbReservedSectors] mov WORD [datasector], ax; base of root directory add WORD [datasector], cx ; read root directory into 0x7e00 pushword ROOT_SEG popes mov bx, 0; copy root dir callReadSectors; read in directory table popes popa; restore registers and return ret ;******************************************* ; LoadFAT () ;- Loads FAT table to 0x7c00 ; ;Parm/ ES:DI => Root Directory Table ;******************************************* LoadFAT: pusha; store registers pushes ; compute size of FAT and store in "cx" xor ax, ax mov al, BYTE [bpbNumberOfFATs]; number of FATs mul WORD [bpbSectorsPerFAT]; sectors used by FATs mov cx, ax ; compute location of FAT and store in "ax" mov ax, WORD [bpbReservedSectors] ; read FAT into memory (Overwrite our bootloader at 0x7c00) pushword FAT_SEG popes xorbx, bx callReadSectors popes popa; restore registers and return ret ;******************************************* ; FindFile () ;- Search for filename in root table ; ; parm/ DS:SI => File name ; ret/ AX => File index number in directory table. -1 if error ;******************************************* FindFile: pushcx; store registers pushdx pushbx movbx, si; copy filename for later ; browse root directory for binary image mov cx, WORD [bpbRootEntries]; load loop counter mov di, ROOT_OFFSET; locate first root entry at 1 MB mark cld; clear direction flag .LOOP: pushcx mov cx, 11; eleven character name. Image name is in SI movsi, bx; image name is in BX pushdi repcmpsb; test for entry match pop di je.Found pop cx add di, 32; queue next directory entry loop.LOOP .NotFound: popbx; restore registers and return popdx popcx movax, -1; set error code ret .Found: popax; return value into AX contains entry of file popbx; restore registers and return popdx popcx ret ;******************************************* ; LoadFile () ;- Load file ; parm/ ES:SI => File to load ; parm/ EBX:BP => Buffer to load file to ; ret/ AX => -1 on error, 0 on success ; ret/ CX => number of sectors read ;******************************************* LoadFile: xorecx, ecx; size of file in sectors pushecx .FIND_FILE: pushbx; BX=>BP points to buffer to write to; store it for later pushbp callFindFile; find our file. ES:SI contains our filename cmpax, -1 jne.LOAD_IMAGE_PRE popbp popbx popecx movax, -1 ret .LOAD_IMAGE_PRE: subedi, ROOT_OFFSET subeax, ROOT_OFFSET ; get starting cluster pushword ROOT_SEG;root segment loc popes movdx, WORD [es:di + 0x001A]; DI points to file entry in root directory table. Refrence the table... movWORD [cluster], dx; file's first cluster popbx; get location to write to so we dont screw up the stack popes pushbx; store location for later again pushes callLoadFAT .LOAD_IMAGE: ; load the cluster movax, WORD [cluster]; cluster to read popes; bx:bp=es:bx popbx callClusterLBA xorcx, cx mov cl, BYTE [bpbSectorsPerCluster] callReadSectors popecx incecx; add one more sector to counter pushecx pushbx pushes movax, FAT_SEG;start reading from fat moves, ax xorbx, bx ; get next cluster mov ax, WORD [cluster]; identify current cluster mov cx, ax; copy current cluster mov dx, ax shr dx, 0x0001; divide by two add cx, dx; sum for (3/2) movbx, 0;location of fat in memory addbx, cx movdx, WORD [es:bx] testax, 0x0001; test for odd or even cluster jnz.ODD_CLUSTER .EVEN_CLUSTER: anddx, 0000111111111111b; take low 12 bits jmp.DONE .ODD_CLUSTER: shrdx, 0x0004; take high 12 bits .DONE: movWORD [cluster], dx cmpdx, 0x0ff0; test for end of file marker jb.LOAD_IMAGE .SUCCESS: popes popbx popecx xorax, ax ret %endif ;__FAT12_INC_67343546FDCC56AAB872_INCLUDED__ Floppy16.inc ;******************************************************* ; ;Floppy16.inc ;Floppy drive interface routines ; ;OS Development Series ;******************************************************* %ifndef __FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__ %define __FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__ bits16 bpbOEMdb "My OS " bpbBytesPerSector:DW 512 bpbSectorsPerCluster:DB 1 bpbReservedSectors: DW 1 bpbNumberOfFATs: DB 2 bpbRootEntries: DW 224 bpbTotalSectors: DW 2880 bpbMedia: DB 0xf0;; 0xF1 bpbSectorsPerFAT: DW 9 bpbSectorsPerTrack: DW 18 bpbHeadsPerCylinder:DW 2 bpbHiddenSectors: DD 0 bpbTotalSectorsBig: DD 0 bsDriveNumber:DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber:DD 0xa0a1a2a3 bsVolumeLabel:DB "MOS FLOPPY " bsFileSystem:DB "FAT12 " datasectordw 0x0000 cluster dw 0x0000 absoluteSector db 0x00 absoluteHead db 0x00 absoluteTrackdb 0x00 ;************************************************; ; Convert CHS to LBA ; LBA = (cluster - 2) * sectors per cluster ;************************************************; ClusterLBA: sub ax, 0x0002; zero base cluster number xor cx, cx mov cl, BYTE [bpbSectorsPerCluster] ; convert byte to word mul cx add ax, WORD [datasector] ; base data sector ret ;************************************************; ; Convert LBA to CHS ; AX=>LBA Address to convert ; ; absolute sector = (logical sector / sectors per track) + 1 ; absolute head = (logical sector / sectors per track) MOD number of heads ; absolute track= logical sector / (sectors per track * number of heads) ; ;************************************************; LBACHS: xor dx, dx; prepare dx:ax for operation div WORD [bpbSectorsPerTrack] ; calculate inc dl; adjust for sector 0 mov BYTE [absoluteSector], dl xor dx, dx; prepare dx:ax for operation div WORD [bpbHeadsPerCylinder]; calculate mov BYTE [absoluteHead], dl mov BYTE [absoluteTrack], al ret ;************************************************; ; Reads a series of sectors ; CX=>Number of sectors to read ; AX=>Starting sector ; ES:EBX=>Buffer to read to ;************************************************; ReadSectors: .MAIN mov di, 0x0005; five retries for error .SECTORLOOP pushax pushbx pushcx callLBACHS; convert starting sector to CHS mov ah, 0x02; BIOS read sector mov al, 0x01; read one sector mov ch, BYTE [absoluteTrack]; track mov cl, BYTE [absoluteSector] ; sector mov dh, BYTE [absoluteHead] ; head mov dl, BYTE [bsDriveNumber]; drive int 0x13; invoke BIOS jnc .SUCCESS; test for read error xor ax, ax; BIOS reset disk int 0x13; invoke BIOS dec di; decrement error counter pop cx pop bx pop ax jnz .SECTORLOOP ; attempt to read again int 0x18 .SUCCESS pop cx pop bx pop ax add bx, WORD [bpbBytesPerSector]; queue next buffer inc ax; queue next sector loop.MAIN ; read next sector ret %endif ;__FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__ Stage3.asm ;******************************************************* ; ;Stage3.asm ;A basic 32 bit binary kernel running ; ;OS Development Series ;******************************************************* org0x100000; Kernel starts at 1 MB bits32; 32 bit code jmpStage3; jump to entry point %include "stdio.inc" msg db0x0A, 0x0A, " - OS Development Series -" db0x0A, 0x0A, " MOS 32 Bit Kernel Executing", 0x0A, 0 Stage3: ;-------------------------------; ; Set registers ; ;-------------------------------; movax, 0x10; set data segments to data selector (0x10) movds, ax movss, ax moves, ax movesp, 90000h; stack begins from 90000h ;---------------------------------------; ; Clear screen and print success; ;---------------------------------------; callClrScr32 movebx, msg callPuts32 ;---------------------------------------; ; Stop execution; ;---------------------------------------; cli hlt stdio.inc ;************************************************* ;stdio.inc ;-Input/Output routines ; ;OS Development Series ;************************************************* %ifndef __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ %define __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ ;========================================================== ; ; 16 Bit Real Mode Routines ;========================================================== ;************************************************; ;Puts16 () ;-Prints a null terminated string ;DS=>SI: 0 terminated string ;************************************************; bits16 Puts16: pusha; save registers .Loop1: lodsb; load next byte from string from SI to AL oral, al; Does AL=0? jzPuts16Done; Yep, null terminator found-bail out movah, 0eh ; Nope-Print the character int10h; invoke BIOS jmp.Loop1 ; Repeat until null terminator found Puts16Done: popa; restore registers ret; we are done, so return ;========================================================== ; ; 32 Bit Protected Mode Routines ;========================================================== bits 32 %defineVIDMEM0xB8000; video memory %defineCOLS80; width and height of screen %defineLINES 25 %defineCHAR_ATTRIB 63; character attribute (White text on light blue background) _CurX db 0; current x/y location _CurY db 0 ;**************************************************; ;Putch32 () ;- Prints a character to screen ;BL => Character to print ;**************************************************; Putch32: pusha; save registers movedi, VIDMEM; get pointer to video memory ;-------------------------------; ; Get current position; ;-------------------------------; xoreax, eax; clear eax ;-------------------------------- ; Remember: currentPos = x + y * COLS! x and y are in _CurX and _CurY. ; Because there are two bytes per character, COLS=number of characters in a line. ; We have to multiply this by 2 to get number of bytes per line. This is the screen width, ; so multiply screen with * _CurY to get current line ;-------------------------------- movecx, COLS*2; Mode 7 has 2 bytes per char, so its COLS*2 bytes per line moval, byte [_CurY]; get y pos mulecx; multiply y*COLS pusheax; save eax--the multiplication ;-------------------------------- ; Now y * screen width is in eax. Now, just add _CurX. But, again remember that _CurX is relative ; to the current character count, not byte count. Because there are two bytes per character, we ; have to multiply _CurX by 2 first, then add it to our screen width * y. ;-------------------------------- moval, byte [_CurX]; multiply _CurX by 2 because it is 2 bytes per char movcl, 2 mulcl popecx; pop y*COLS result addeax, ecx ;------------------------------- ; Now eax contains the offset address to draw the character at, so just add it to the base address ; of video memory (Stored in edi) ;------------------------------- xorecx, ecx addedi, eax; add it to the base address ;-------------------------------; ; Watch for new line; ;-------------------------------; cmpbl, 0x0A; is it a newline character? je.Row; yep--go to next row ;-------------------------------; ; Print a character ; ;-------------------------------; movdl, bl; Get character movdh, CHAR_ATTRIB; the character attribute movword [edi], dx; write to video display ;-------------------------------; ; Update next position; ;-------------------------------; incbyte [_CurX]; go to next character ;cmpbyte [_CurX], COLS; are we at the end of the line? ;je.Row; yep-go to next row jmp.done; nope, bail out ;-------------------------------; ; Go to next row; ;-------------------------------; .Row: movbyte [_CurX], 0; go back to col 0 incbyte [_CurY]; go to next row ;-------------------------------; ; Restore registers & return; ;-------------------------------; .done: popa; restore registers and return ret ;**************************************************; ;Puts32 () ;- Prints a null terminated string ;parm\ EBX = address of string to print ;**************************************************; Puts32: ;-------------------------------; ; Store registers ; ;-------------------------------; pusha; save registers pushebx; copy the string address popedi .loop: ;-------------------------------; ; Get character ; ;-------------------------------; movbl, byte [edi]; get next character cmpbl, 0; is it 0 (Null terminator)? je.done; yep-bail out ;-------------------------------; ; Print the character ; ;-------------------------------; callPutch32; Nope-print it out ;-------------------------------; ; Go to next character; ;-------------------------------; incedi; go to next character jmp.loop .done: ;-------------------------------; ; Update hardware cursor; ;-------------------------------; ; Its more efficiant to update the cursor after displaying ; the complete string because direct VGA is slow movbh, byte [_CurY]; get current position movbl, byte [_CurX] callMovCur; update cursor popa; restore registers, and return ret ;**************************************************; ;MoveCur () ;- Update hardware cursor ;parm/ bh = Y pos ;parm/ bl = x pos ;**************************************************; bits 32 MovCur: pusha; save registers (aren't you getting tired of this comment?) ;-------------------------------; ; Get current position; ;-------------------------------; ; Here, _CurX and _CurY are relitave to the current position on screen, not in memory. ; That is, we don't need to worry about the byte alignment we do when displaying characters, ; so just follow the forumla: location = _CurX + _CurY * COLS xoreax, eax movecx, COLS moval, bh; get y pos mulecx; multiply y*COLS addal, bl; Now add x movebx, eax ;--------------------------------------; ; Set low byte index to VGA register ; ;--------------------------------------; moval, 0x0f movdx, 0x03D4 outdx, al moval, bl movdx, 0x03D5 outdx, al; low byte ;---------------------------------------; ; Set high byte index to VGA register ; ;---------------------------------------; xoreax, eax moval, 0x0e movdx, 0x03D4 outdx, al moval, bh movdx, 0x03D5 outdx, al; high byte popa ret ;**************************************************; ;ClrScr32 () ;- Clears screen ;**************************************************; bits 32 ClrScr32: pusha cld movedi, VIDMEM movcx, 2000 movah, CHAR_ATTRIB moval, ' ' repstosw movbyte [_CurX], 0 movbyte [_CurY], 0 popa ret ;**************************************************; ;GotoXY () ;- Set current X/Y location ;parm\AL=X position ;parm\AH=Y position ;**************************************************; bits 32 GotoXY: pusha mov[_CurX], al; just set the current position mov[_CurY], ah popa ret %endif ;__STDIO_INC_67343546FDCC56AAB872_INCLUDED__ Lakukan kembali langkah-langkah seperti pada bagian Bootloaders1, yaitu: 1.Assembly file Boot1.asm menjadi Boot1.bin 2.Copy Bootloader (Boot1.bin) ke Bootsector (Virtual Floppy) 3.Assembly file Stage2.asm menjadi KRNLDR.SYS 4.Copy KRNLDR.SYS 5.Assembly file Stage3.asm menjadi KRNL.SYS 6.Copy KRNLDR.SYS 7.Jalankan pada bochs Hasil akhir dari langkah-langkah tersebut adalah sebagai berikut: Kendala Kendalayangdidapatkanselamapengerjaantugasiniadalahadanyaketerbatasaninformasi tentang tools yang harus digunakan pada situs tutorial. Hal ini mengakibatkan adanya beberapa kali kegagalan dalam percobaan. Tools utama yang ada pada situs tersebut hanya dapat digunakan pada lingkunganWindows732-bit.Sedangkanuntuk Windows8.164-bit,harusmenggunakantools lain. Oleh karena itu, waktu yang tersedia, habis karena percobaan berbagai macam tools. Tools yang tepat untuk Windows 8,1 64-bit akhirnya berhasil ditemukan dan tutorial pun dapat dilakukan dalam bentuk yang sederhana. Berikut merupakan salah satu contoh percobaan penggunaan tools yang tidak tepat pada suatau sistem operasi sehingga menimbulkan kesalahan. Kendala yang paling menghambat adalah tools untuk mengerjakan tutorial 14. Hal ini dikarenakan ukuran tools atau program dengan ukuran yang sangat besar sehingga membutuhkan waktu yang lama untuk diunduh. Akibatnya, tutorial 14 tidak dapat dikerjakan dengan baik. Sumber TipeNamaTautan ProgramMKBThttp://www.nu2.nu/mkbt ProgramNASMhttp://superuser.com/questions/183335/how-to-create-a-virtual-floppy-drive ProgramBochshttp://sourceforge.net/projects/bochs/ ProgramVFDhttp://sourceforge.net/projects/vfd/ ProgramPartCopyhttp://stahlworks.com/dev/index.php?tool=partcopy TeoriPengembangan OS http://www.brokenthorn.com/Resources/OSDevIndex.html Simpulan Beberapa kesimpulan yang didapatkan dalam melaksanakan tugas ini adalah sebagai berikut. 1.Pengembangan sistem operasi dapat disimulasikan 2.Dalam mengembangkan suatu sistem operasi, perlu memerhatikan perangkat keras yang akan dijadikan tempat implementasi 3.Dalam menyimulasikan sistem operasi, perlu memerhatikan environment yang digunakan karena dapat berdampak pada persiapan, khususnya untuk tools. 4.Dalam mengikuti tutorial, seluruh petunjuk pengerjaan, tools yang dibutuhkan, syarat-syarat tutorial, dan lain-lain yang berkaitan dengan tutorial harus diperhatikan. Saran Sebelum pelaksanaan praktikum, akan sangat lebih baik apabila dijelaskan terlebih dahulu ilmu dan alat dasar yang dapat atau perlu digunakan untuk melakukan suatu modul. Dengan begitu terdapat pemahaman dasar dan persiapan alat untuk melaksanakan modul tersebut. Hal ini juga berpengaruh terhadap waktu yang dibutuhkan untuk melaksanakan praktikum atau modul.