Skip to content

Instantly share code, notes, and snippets.

@flaneur2020
Created January 30, 2011 03:39
Show Gist options
  • Save flaneur2020/802497 to your computer and use it in GitHub Desktop.
Save flaneur2020/802497 to your computer and use it in GitHub Desktop.
read_sector
; from http://www.mouseos.com/arch/processor_mode.html
;----------------------------------------------------------------------
;
; read_sector(int sector, char *buf) - read one floppy sector(LBA mode)
; input: di - sector
; si - buf
;----------------------------------------------------------------------
read_sector:
push cx
push dx
push es
push ds
pop es
mov bx, si ; data buffer
mov ax, di ; disk sector number
; LBA mode --> CHS mode
; cylinder = L / 36
mov cl, 36
div cl
mov ch, al ; ch = cylinder
; head = (L % 36) / 18
mov al, ah
xor ah, ah
mov cl, 18
div cl
mov dh, al ; dh = head
; sector = (L % 36) % 18 + 1
mov cl, ah ; cl = sector
inc cl
xor dl, dl ; dl = drive
; ch - cylinder
; cl - sector ( 1 - 63)
; dh - head
; dl - drive number
; es:bx - data buffer
mov ax, 0x201
int 0x13
pop es
pop dx
pop cx
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment