jwen
jwen

Reputation: 79

Is NASM incompatible with certain hardware?

Is NASM incompatible with certain hardware configurations?

the following code runs on Qemu and an Intel Pentium system, however, when it's run on a Intel Celeron based computer, the HP Compaq dc7600 in particular, the system claims that the volume is not valid, stating Non-System disk or disk error. is this a system configuration error, if it is, what would I need to change? (8.4 in datasheet).

[BITS 16]

main:
    cli
    hlt  

times 510 - ($-$$) db 0
dw 0xAA55

the system is booting from a binary file created with nasm -fbin mbr.asm -o mbr.bin and is written to a usb drive with dd if=mbr.bin of=/dev/sdb

Upvotes: 0

Views: 102

Answers (1)

jwen
jwen

Reputation: 79

Some BIOS's require a partition to be set in order to reconize a device as bootable. the following is the absolute minimal code required to get the system to boot:

[ORG 0x7c00]
[BITS 16]

main:
    cli
    hlt


times 494 - ($ - $$) db 0x00 ; Padding to 512 bytes

; Partitions table for a MBR

partition_table_1:
    db 0x80 ; Status, 0x80 means active
    db 0x00 ; First Absolute Sector CHS
    db 0x00 ; 
    db 0x00 ;  
    db 0x00 ; Partition Type
    db 0x00 ; Last Absolute Sector CHS
    db 0x00 ; 
    db 0x00 ; 
    dd 0x00000001 ; First Absolute Sector LBA
    dd 0x00000200 ; Number of Sectors

dw 0xAA55 ; Boot signature required to boot

thanks to the comment posted by Michael Petch, take a look at his comment for a more complete example.

Upvotes: 3

Related Questions