"30 days to write operating system" How to make USB drive boot

Source: Internet
Author: User

The author read the "30 days to write the operating system", I would like to install a B, so I have been very much want to "30 days to write operating system" program is not just running in the virtual machine, but also want to put this OS on the U disk, starting from the U disk, the online search for a variety of methods have not realized my great ideal So I can do it by myself. Below is my test computer screen is broken, but still see clearly


The following is the step


First to http://zhidao.baidu.com/share/cc93285a8dc709f2cbd8af39eaae61bd.html download the USB drive format into a floppy disk tool, format the USB drive

2--Replace your IPL code with the following IPL code (in fact the entire porting to the USB drive core is to modify the IPL code)

; Haribote-ipl
; Tab=4
Cyls EQU 10 ; 10 Cylinders
ORG 0x7c00; MBR in memory position (DS=0,0X07C00=DS+0X7C00)


; System-related setup information
JMP Entry
Db 0x90
Db "HELLOIPL"; Name of the boot sector
Dw 512; Size of Sector
Db 1; F
Dw 1; FAT First Sector
Db 2; FAT number
Dw 224; Root dir size
Dw 2880; Disk size in Sector
Db 0xf0; Disk type
Dw 9; FAT length
Dw 18; Sector each Road
Dw 2; Disk Up Down
Dd 0; No partition
Dd 2880; Reclaim the disk size
Db 0,0,0x29; Reserve
Dd 0xFFFFFFFF; Might be column
Db "Hello-os"; Disk Name
Db "FAT12"; Disk FS Type
Resb 18; Reserve byte


; Init Program Entry


Entry
MOV ax,0;
MOV Ss,ax
MOV Sp,0x7c00; Heap Stack Init
MOV Ds,ax; Initialize code snippet base address in 0x00000


; Read disk-to-memory 0x08200 location


MOV ax,0x0820
MOV Es,ax
MOV ch,0; Cylinder number
MOV dh,0; Disk Head number
MOV cl,2; Sector number
Readloop:
MOVsi,0; Failed times
; Retry to read disk if failed, read one sector
Retry
MOV ah,0x02; AH=0X02: Read disk
MOV al,1; 1 sectors
MOV bx,0
; MOV dl,0x00; A drive
MOV dl,0x80
Int 0x13; function routines that call the BIOS
JNC Next
ADD si,1
Cmpsi,5
JAE Error
MOVah,0x00
; MOVdl,0x00
MOVdl,0x80
Int 0x13
JMPRetry
Next
MOV Ax,es
ADD ax,0x0020; backward offset per sector memory read (es+=0x0020) <<4
MOV Es,ax
ADD cl,1
Cmpcl,62; 62 sectors
Jbe Readloop
MOVcl,1
ADDdh,1
Cmpdh,2
Jb Readloop
MOVdh,0
ADDch,1
Cmp ch,4
JbReadloop
MOV [0x0ff0],ch
JMP0xc200
Error
MOV Si,msg
JMPPutloop
Ok:
MOV Si,msg1
Putloop:
MOV AL,[SI]
ADD si,1; Si set to 1
Cmp al,0
JE Fin
MOV ah,0x0e; displaying characters in teletype mode
MOV bx,15; Page bh=0x00, foreground color bl=0x0f
Int 0x10; BIOS Display Service
JMP Putloop
Fin
HLT ; Pause processor
JMP Fin
MSG1:
Db 0x0a, 0x0a; Line break
Db "READ okkkk"
Db 0x0a; Line break
Db 0
Msg
Db 0x0a, 0x0a; Line break
Db "Load Error"
Db 0x0a; Line break
Db 0


Resb 0x7dfe-$; (0x7dfe-current position) are populated with 0x00


Db 0x55, 0xaa


3--compiled to your img file

4--use Ubuntu or other system dd command to copy your img to the USB stick (dd if=xxxx.img of=/dev/sdb) Ps:/dev/sdb This is the name of my USB flash drive on my system, there may be other names, depending on the circumstances

5--put your USB stick on the real machine, turn on the power (My Computer is F12 Select Startup item) Select the USB stick boot

6--can see the effect of running on a real computer.

"30 days to write operating system" How to make USB drive boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.