Find the answer to your Linux question:
Results 1 to 2 of 2
Hi buddies, OS: Windows XP Virtual Machine: Bochs-2.4.5 I want to learn some details about linux booting, so I begin writing a small boot program myself. Yesterday, I was writing ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    4

    Unhappy How to write a boot program into a floppy image?


    Hi buddies,
    OS: Windows XP
    Virtual Machine: Bochs-2.4.5

    I want to learn some details about linux booting, so I begin writing a small boot program myself.

    Yesterday, I was writing a small boot program and planned to use it boot a Bochs virtual machine. The boot program is written in assembly language and compiled with nasm. The src: 
    Code:
    org 07c00h    ; 告诉编译器程序加载到 7c00处
    mov ax, cs
    mov ds, ax
    mov es, ax
    call DispStr    ; 调用显示字符串例程
    jmp $        ; 无限循环
    
    DispStr:
    mov ax, BootMessage
    mov bp, ax           ; es:bp = 串地址
    mov cx, 16           ; cx = 串长度
    mov ax, 01301h       ; ah = 13, al = 01h
    mov bx, 000ch        ; 页号为 0(bh = 0) 黑底红字(bl = 0Ch,高亮)
    mov dl, 0
    int 10h              ; 10h 号中断
    ret
    
    BootMessage: db "Hello, OS world!"
    times 510-($-$$) db 0      ; 填充剩下的空间,使生成的二进制代码恰好为 512字节
    dw 0xaa55               ; 结束标志
    sorry for the chinese comments. Just ignore them. This boot.asm just print a message 'Hello, OS world!' and loop forever. It is compiled with command:
    "nasm boot.asm -o boot.bin "

    I use bxiamge.exe in Bochs and create an floppy image called boot.img and configure the Bochs virtual host to boot from this floppy image.

    My question is how to write the compiled boot.bin program into the floppy image(boot.img)?

    Thanks in advance!!

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,184
    You do it with the dd command. I think the correct syntax is dd bs=512 if=boot.img of=/dev/fd0 but you'd better check the man page to make sure.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •