Assembly INT 13h - a problem with reading a disk

I need to write a program in the assembly to read the first sector of the disk (MBR) and write it to a floppy disk, or at least show the data. I understand that INT 13h and 25h do not work in windows protected mode, and I even tried my code in Dos, but the dos system freezes when I run the program. This is the code:

  MOV byte ptr es:[bx], offset result
  MOV     AL,1 ;number ofsectors to read
  MOV     Cl,1 
  MOV     ch,0  
  mov     dl,80h  ;the HDD
  mov     dh,1
  mov ah,02h
  INT     13h

result is a buffer variable.

Thanks in advance.

+2
source share
2 answers

Yeb. it finally worked. This is code (only works on DOS, because INT 13h cannot work on Windows.

            mov dx,80h
        mov cx,1
        mov bx,ds
        mov es,bx
        mov bx,offset result
        mov ax,0201h
        int 13h     
+1
source

I think this line is incorrect

MOV byte ptr es:[bx], offset result ' attempts to write memory [bx]

It should be

MOV es, segment_offset ' probably not needed
MOV bx, buffer_offset
...

And maybe you also need to recover ES, example

push es
mov  es, ...
...
pop  es
' done
+1
source

All Articles