30天自制操作系统吧 关注:1,380贴子:4,755

一定得用软盘么,都什么时代了,买不到软盘这玩意儿啊

只看楼主收藏回复

求用U盘启动的方法


1楼2012-09-21 19:59回复
    去下作者说的那个虚拟机就行了,然后编译成img格式的文件就可以启动了


    3楼2012-09-22 15:41
    回复
      U盘我试过,可以启动的,但是老是加载第一扇区失败。
      “load error...”
      用winhex就可以。


      IP属地:上海4楼2012-09-28 17:21
      回复
        这个小日本都自带了虚拟机还弄什么U盘嘛


        IP属地:重庆5楼2012-09-29 20:14
        回复
          可以用U盘。真机测试。感觉不同啊。我的电脑上,按书上的程序,不能操作机子的 鼠标(虚拟机上的行),能操作键盘


          6楼2012-10-25 14:48
          回复
            可以用各种虚拟机软件哦,比如vmware和virtualbox


            7楼2012-10-28 00:21
            收起回复
              用virtualBox吧,完全免费的。


              8楼2012-12-10 05:58
              回复
                org 0x7c00 ; bios always loads boot sector to 0000:7C00 jmp boot_start %include "load.inc" STACK_BASE equ 0x7C00 ; base address of stack when booting
                TRANS_SECT_NR equ 2
                SECT_BUF_SIZE equ TRANS_SECT_NR * 512 disk_address_packet: db 0x10 ; [ 0] Packet size in bytes.
                db 0 ; [ 1] Reserved, must be 0.
                db TRANS_SECT_NR ; [ 2] Nr of blocks to transfer.
                db 0 ; [ 3] Reserved, must be 0.
                dw 0 ; [ 4] Addr of transfer - Offset
                dw SUPER_BLK_SEG ; [ 6] buffer. - Seg
                dd 0 ; [ 8] LBA. Low 32-bits.
                dd 0 ; [12] LBA. High 32-bits.
                err:
                mov dh, 3 ; "Error 0 "
                call disp_str ; display the string
                jmp $ boot_start:
                mov ax, cs
                mov ds, ax
                mov es, ax
                mov ss, ax
                mov sp, STACK_BASE call clear_screen mov dh, 0 ; "Booting "
                call disp_str ; display the string ;; read the super block to SUPER_BLK_SEG::0
                mov dword [disk_address_packet + 8], ROOT_BASE + 1
                call read_sector
                mov ax, SUPER_BLK_SEG
                mov fs, ax mov dword [disk_address_packet + 4], LOADER_OFF
                mov dword [disk_address_packet + 6], LOADER_SEG ;; get the sector nr of `/' (ROOT_INODE), it'll be stored in eax
                mov eax, [fs:SB_ROOT_INODE]
                call get_inode ;; read `/' into ex:bx
                mov dword [disk_address_packet + 8], eax
                call read_sector ;; let's search `/' for the loader
                mov si, LoaderFileName
                push bx ; <- save
                .str_cmp:
                ;; before comparation:
                ;; es:bx -> dir_entry @ disk
                ;; ds:si -> filename we want
                add bx, [fs:SB_DIR_ENT_FNAME_OFF]
                .1:
                lodsb ; ds:si -> al
                cmp al, byte [es:bx]
                jz .2
                jmp .different ; oops
                .2: ; so far so good
                cmp al, 0 ; both arrive at a '\0', match
                jz .found
                inc bx ; next char @ disk
                jmp .1 ; on and on
                .different:
                pop bx ; -> restore
                add bx, [fs:SB_DIR_ENT_SIZE]
                sub ecx, [fs:SB_DIR_ENT_SIZE]
                jz .not_found mov dx, SECT_BUF_SIZE
                cmp bx, dx
                jge .not_found push bx
                mov si, LoaderFileName
                jmp .str_cmp
                .not_found:
                mov dh, 2
                call disp_str
                jmp $
                .found:
                pop bx
                add bx, [fs:SB_DIR_ENT_INODE_OFF]
                mov eax, [es:bx] ; eax <- inode nr of loader
                call get_inode ; eax <- start sector nr of loader
                mov dword [disk_address_packet + 8], eax
                load_loader:
                call read_sector
                cmp ecx, SECT_BUF_SIZE
                jl .done
                sub ecx, SECT_BUF_SIZE ; bytes_left -= SECT_BUF_SIZE
                add word [disk_address_packet + 4], SECT_BUF_SIZE ; transfer buffer
                jc err
                add dword [disk_address_packet + 8], TRANS_SECT_NR ; LBA
                jmp load_loader
                .done:
                mov dh, 1
                call disp_str
                jmp LOADER_SEG:LOADER_OFF
                jmp $
                ;============================================================================
                ;字符串
                ;----------------------------------------------------------------------------
                LoaderFileName db "hdldr.bin", 0 ; LOADER 之文件名
                ; 为简化代码, 下面每个字符串的长度均为 MessageLength
                MessageLength equ 9
                BootMessage: db "Booting "; 9字节, 不够则用空格补齐. 序号 0


                9楼2013-02-18 10:58
                回复
                  Message1 db "HD Boot "; 9字节, 不够则用空格补齐. 序号 1
                  Message2 db "No LOADER"; 9字节, 不够则用空格补齐. 序号 2
                  Message3 db "Error 0 "; 9字节, 不够则用空格补齐. 序号 3
                  ;============================================================================ clear_screen:
                  mov ax, 0x600 ; AH = 6, AL = 0
                  mov bx, 0x700 ; 黑底白字(BL = 0x7)
                  mov cx, 0 ; 左上角: (0, 0)
                  mov dx, 0x184f ; 右下角: (80, 50)
                  int 0x10 ; int 0x10
                  ret ;----------------------------------------------------------------------------
                  ; 函数名: disp_str
                  ;----------------------------------------------------------------------------
                  ; 作用:
                  ; 显示一个字符串, 函数开始时 dh 中应该是字符串序号(0-based)
                  disp_str:
                  mov ax, MessageLength
                  mul dh
                  add ax, BootMessage
                  mov bp, ax ; `.
                  mov ax, ds ; | ES:BP = 串地址
                  mov es, ax ; /
                  mov cx, MessageLength ; CX = 串长度
                  mov ax, 0x1301 ; AH = 0x13, AL = 0x1
                  mov bx, 0x7 ; 页号为0(BH = 0) 黑底白字(BL = 0x7)
                  mov dl, 0
                  int 0x10 ; int 0x10
                  ret ;----------------------------------------------------------------------------
                  ; read_sector
                  ;----------------------------------------------------------------------------
                  ; Entry:
                  ; - fields disk_address_packet should have been filled
                  ; before invoking the routine
                  ; Exit:
                  ; - es:bx -> data read
                  ; registers changed:
                  ; - eax, ebx, dl, si, es
                  read_sector:
                  xor ebx, ebx mov ah, 0x42
                  mov dl, 0x80
                  mov si, disk_address_packet
                  int 0x13 mov ax, [disk_address_packet + 6]
                  mov es, ax
                  mov bx, [disk_address_packet + 4] ret ;----------------------------------------------------------------------------
                  ; get_inode
                  ;----------------------------------------------------------------------------
                  ; Entry:
                  ; - eax : inode nr.
                  ; Exit:
                  ; - eax : sector nr.
                  ; - ecx : the_inode.i_size
                  ; - es:ebx : inodes sector buffer
                  ; registers changed:
                  ; - eax, ebx, ecx, edx
                  get_inode:
                  dec eax ; eax <- inode_nr -1
                  mov bl, [fs:SB_INODE_SIZE]
                  mul bl ; eax <- (inode_nr - 1) * INODE_SIZE
                  mov edx, SECT_BUF_SIZE
                  sub edx, dword [fs:SB_INODE_SIZE]
                  cmp eax, edx
                  jg err
                  push eax mov ebx, [fs:SB_NR_IMAP_SECTS]
                  mov edx, [fs:SB_NR_SMAP_SECTS]
                  lea eax, [ebx+edx+ROOT_BASE+2]
                  mov dword [disk_address_packet + 8], eax
                  call read_sector pop eax ; [es:ebx+eax] -> the inode mov edx, dword [fs:SB_INODE_ISIZE_OFF]
                  add edx, ebx
                  add edx, eax ; [es:edx] -> the_inode.i_size
                  mov ecx, [es:edx] ; ecx <- the_inode.i_size ; es:[ebx+eax] -> the_inode.i_start_sect
                  add ax, word [fs:SB_INODE_START_OFF] add bx, ax
                  mov eax, [es:bx]
                  add eax, ROOT_BASE ; eax <- the_inode.i_start_sect
                  ret
                  times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节
                  dw 0xaa55 ; 结束标志


                  10楼2013-02-18 10:58
                  回复
                    硬盘启动方法,load.inc在这
                    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                    ;; boot/include/load.inc
                    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; kernel entry point, corresponding with Makefile
                    KRNL_ENT_PT_PHY_ADDR equ 0x1000 ;; paging
                    PAGE_DIR_BASE equ 0x100000
                    PAGE_TBL_BASE equ 0x101000 ;; where loader is loaded
                    LOADER_SEG equ 0x9000
                    LOADER_OFF equ 0x100
                    LOADER_PHY_ADDR equ LOADER_SEG * 0x10 ;; where kernel file is loaded
                    KERNEL_FILE_SEG equ 0x7000
                    KERNEL_FILE_OFF equ 0
                    KERNEL_FILE_PHY_ADDR equ KERNEL_FILE_SEG * 0x10 ; bytes reserved for kernel.bin
                    KERNEL_VALID_SPACE equ LOADER_PHY_ADDR - KERNEL_FILE_PHY_ADDR ;; super block will be stored at: [0x700,0x900)
                    SUPER_BLK_SEG equ 0x70 ;; ATTENTION:
                    ;; Macros below should corresponding with C source.
                    BOOT_PARAM_ADDR equ 0x900
                    BOOT_PARAM_MAGIC equ 0xB007 ;; we don't calculate the base sector nr of the root device while loading
                    ;; but define it as a macro for two reasons:
                    ;; 1. it is a constant for any certain system
                    ;; 2. it simplifies boot sector and loader
                    ROOT_BASE equ 0x4EFF ;; corresponding with include/sys/fs.h
                    SB_MAGIC_V1 equ 0x111
                    SB_MAGIC equ 4 * 0
                    SB_NR_INODES equ 4 * 1
                    SB_NR_SECTS equ 4 * 2
                    SB_NR_IMAP_SECTS equ 4 * 3
                    SB_NR_SMAP_SECTS equ 4 * 4
                    SB_N_1ST_SECT equ 4 * 5
                    SB_NR_INODE_SECTS equ 4 * 6
                    SB_ROOT_INODE equ 4 * 7
                    SB_INODE_SIZE equ 4 * 8
                    SB_INODE_ISIZE_OFF equ 4 * 9
                    SB_INODE_START_OFF equ 4 * 10
                    SB_DIR_ENT_SIZE equ 4 * 11
                    SB_DIR_ENT_INODE_OFF equ 4 * 12
                    SB_DIR_ENT_FNAME_OFF equ 4 * 13


                    11楼2013-02-18 11:00
                    回复
                      在真机上可以用grub4dos加载软盘镜像启动


                      12楼2013-02-18 15:10
                      回复
                        Easy,先用老毛桃制作U盘启动盘,OK之后再U盘盘根下建一个名为LMT的文件夹,把映像复制进去。重启,U盘引导,选“启动ISO/IMG文件(LMT目录)”,
                        进去漆黑的目录,输入映像文件的序号


                        ,回车,搞定


                        IP属地:中国香港13楼2013-03-23 07:46
                        收起回复
                          13 楼的方法不错 但是知道原理吗 老毛桃这玩意开源吗?


                          15楼2013-07-16 11:29
                          回复
                            刚开始看 然后被软驱难倒了。。。。。。。
                            13楼的方法救了我。。。


                            IP属地:湖北16楼2013-07-21 19:15
                            回复
                              我是十三楼,话说,我花50元买了和usb2.0软驱效果还不错


                              IP属地:中国香港来自手机贴吧17楼2013-09-09 20:30
                              收起回复