Skip to content

Instantly share code, notes, and snippets.

@jonasschneider
Last active January 2, 2016 05:09
Show Gist options
  • Save jonasschneider/8255542 to your computer and use it in GitHub Desktop.
Save jonasschneider/8255542 to your computer and use it in GitHub Desktop.
# http://en.wikipedia.org/wiki/INT_13H#INT_13h_AH.3D42h:_Extended_Read_Sectors_From_Drive
# http://www.ctyme.com/intr/rb-0708.htm
# http://stackoverflow.com/questions/19866549/int-13h-not-reading-sectors-from-virtual-disk
# Load the second boot stage from the first HDD,
# using the BIOS routine "INT 13h/AH=42h: Extended Read Sectors From Drive".
mov $0x42, %ah
mov $0x80, %dl # drive index (0x80 is first drive)
mov $0, %ax
mov %ax, %ds
movw $(dap - _start + 0x7c00), %si
int $0x13
jmp skip
.align 4
dap:
.byte 0x10 # size
.byte 0
# number of sectors to read
.word 1
# target position for read, offset then segment because of little endian
.word 0x7e00
.word 0x0000
.long 0 # first sector to read
.long 0 # high address
$ diff memory_before_int0x13 memory_after_int0x13
123,124c123
< 0006f00: 0000 0008 0706 0008 0307 1900 0241 0000 .............A..
< 0006f10: 0230 0000 0000 0f7c 0000 0202 4fd3 00f0 .0.....|....O...
---
> 0006f10: 0000 0000 0000 1d7c 0000 0202 4fd3 00f0 .......|....O...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment