How to write on hard disk with bios interrupt 13h

前端 未结 2 1877
栀梦
栀梦 2021-02-11 08:41

I want to copy my boot loader to first sector(512) of hard disk within itself (I should use bios interrupt 13h) and I found this code:

mov bx, buffer1       ; se         


        
2条回答
  •  忘掉有多难
    2021-02-11 08:50

    BIOS functions have input parameters. If you don't get all of the input parameters right, the BIOS function isn't able to guess what you meant. For the BIOS function you're using have a look at: http://www.ctyme.com/intr/rb-0608.htm

    As far as I can tell, you're missing sane values for both CH and ES, so the BIOS can write data from a completely different address to a completely different sector. Also note that CL is the lowest half of the CX register - there's no point loading a value into CL and then overwriting it by loading something into CX.

    BIOS functions return values too. In your case the BIOS may be returning a status code that tells you what went wrong, and because you don't check you don't know if anything went wrong or what it was if it did.

提交回复
热议问题