How to load a kernel from disk with BIOS int 13h in NASM assembly?

前端 未结 5 2081
醉话见心
醉话见心 2021-02-02 01:21

I\'ve been stuck with this for weeks now and have no idea where I\'m going wrong because NASM hasn\'t given me any errors. The code is pretty self explanatory because of the com

5条回答
  •  無奈伤痛
    2021-02-02 02:10

    I don't know if you're using a floppy to boot your OS, but if you are using, i suggest you to declare some things after the ORG and Bits declaration, take a look(they are very important):

    JMP short main   ; Jump past disk description section
    NOP              ; Pad out before disk description
    
    ; ------------------------------------------------------------------
    ; Disk description table, to make it a valid floppy
    ; Note: some of these values are hard-coded in the source!
    ; Values are those used by IBM for 1.44 MB, 3.5 diskette
    
    OEMLabel            db "BERL OS"    ; Disk label - 8 chars
    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 "BERL OS"    ; Volume Label: any 11 chars
    FileSystem          db "FAT12"      ; File system type: don't change!
    
    ; End of the disk description table
    ; ------------------------------------------------------------------
    

    It's a good idea to put this.

    Regards.

提交回复
热议问题