简体   繁体   English

如何从软盘运行简单的操作系统?

[英]How do I run a simple OS from a floppy disk?

I've recently been trying to make an OS in Assembly, however I have been experiencing some problems. 我最近一直试图在组装中制作一个OS,但是我遇到了一些问题。 I can run my OS in VirtualBox however it just tells me to remove media from floppy drive once I try and run it from a floppy drive. 我可以在VirtualBox中运行我的OS,但是一旦我尝试从软盘驱动器中运行它,它只会告诉我从软盘驱动器中删除媒体。 I have tried it on multiple computers but they all say the same. 我已经在多台计算机上尝试过,但是他们都说相同。 I don't know what else to try, I will put my source code below in case it helps you. 我不知道还能尝试什么,如果有帮助,我会将我的源代码放在下面。 Thanks in advance, Jake Zachariah Nixon. 在此先感谢杰克·扎卡里亚·尼克松。

BITS 16

jmp short start             ;jump to start of os, past disk description
nop                         ;pad out before description

OEMLabel        db "FIRSTBOOT"  ; Disk label
BytesPerSector      dw 512      ; Bytes per sector
SectorsPerCluster   db 1        ; Sectors per cluster
ReservedForBoot     dw 1        ; Reserved sectors for boot record
NumberOfFats        db 2        ; Number of copies of the FAT
RootDirEntries      dw 224      ; Number of entries in root dir
LogicalSectors      dw 2880     ; Number of logical sectors
MediumByte      db 0F0h         ; Medium descriptor byte
SectorsPerFat       dw 9        ; Sectors per FAT
SectorsPerTrack     dw 18       ; Sectors per track (36/cylinder)
Sides           dw 2            ; Number of sides/heads
HiddenSectors       dd 0        ; Number of hidden sectors
LargeSectors        dd 0        ; Number of LBA sectors
DriveNo         dw 0            ; Drive No: 0
Signature       db 41           ; Drive signature: 41 for floppy
VolumeID        dd 00000000h    ; Volume ID: any number
VolumeLabel     db "FIRSTOS    "; Volume Label: any 11 chars
FileSystem      db "FAT12   "   ; File system type: don't change!

start:
    mov ax, 07C0h               ;4k stack space after bootloader
    add ax, 288                 ;4096 + 512 devided by 16 bytes per        paragraph
    mov ss, ax
    mov sp, 4096

    mov ax, 07C0h               ;set data segment to where we are loaded
    mov ds, ax

    mov si, text_string         ;put string position in SI
    call print_string           ;calls print string routine

    jmp $                       ;Jumps here to make infinate loop


    text_string db 'This is my awesome OS called FirstOS! I am currently building it from the ground up!', 0

print_string:                   ;routine to outpu string in SI to screen
    mov ah, 0Eh                 ;int 10h 'print char' function

.repeat:
    lodsb                       ;get char from string
    cmp al, 0                   
    je .done                    ;if char = 0 then jump to .done
    int 10h                     ;else print char
    jmp .repeat                 ;then repeat process

.done:
    ret                         ;return to other code


    times 510-($-$$) db 0       ;pad remainder of boot sector with 0s
    dw 0AA55h                   ;The standard pc boot signature

Thanks again :) 再次感谢 :)

It's working! 工作正常! I found out that the problem was just that I hadn't written the image to the diskette properly! 我发现问题仅在于我没有将映像正确写入软盘! Thanks for your help though. 谢谢您的帮助。 If anyone else has the same problem the best software that I found was called rawwrite . 如果其他人遇到同样的问题,我发现的最好的软件称为rawwrite It's really easy to use and really quick. 它非常易于使用且非常快捷。 Thanks again, Jake Zachariah Nixon. 再次感谢杰克·扎卡里亚·尼克松。

It is hard to tell exactly what the problem is, but here are two things you can try. 很难确切说明问题所在,但是您可以尝试以下两种方法。

  1. Is the computer you are using set to try to boot off of the floppy drive? 您使用的计算机是否设置为尝试从软盘驱动器启动? Verify this in the BIOS settings (entered by pressing a special key early in the boot process). 在BIOS设置中进行验证(在启动过程的早期,通过按特殊键输入)。
  2. Is the disk boot-able? 磁盘可以启动吗? Here is an OSDev tutorial that has instructions on creating a floppy boot-able OS; 这是OSDev教程,其中包含有关创建可启动软盘的OS的说明。 at the very bottom it gives instructions on how to create the floppy: http://wiki.osdev.org/Babystep1 它在最底部给出了有关如何创建软盘的说明: http : //wiki.osdev.org/Babystep1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM