flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > How do I write to a disk using Int 13h? |
Author |
|
revolution 13 Mar 2008, 04:07
You need to set es:bx to point to the data that you want to write to the disk.
|
|||
13 Mar 2008, 04:07 |
|
ralc 27 Mar 2008, 20:47
Thank you. I think that I have it mostly worked out.
This is what I have now: ;============================================= ; 'write to sector 72 write_command: call clear_screen mov CX, 3 reset_disk: MOV AH,00h ; Reset disk system 3 times, as recommended INT 13h loope reset_disk: lea di, write_buffer call get_string mov BX, DI mov ES:[BX], BX mov AL, 1 ; AL = number of sectors to read/write (must be nonzero) MOv CH, 2 ; CH = cylinder number (0..79). MOV CL, 1 ; CL = sector number (1..18). mov DH, 0 ; DH = head number (0..1). MOV DL, 0 ; DL = drive number Mov AH, 03h INT 13h putc 0Dh putc 10 ; next line. jmp processed ;============================================= It writes to sector 72. It works fine, except it does not write the first two characters. It looks as tho I need to shift something. That is not my primary concern at the moment. What I am working on now is reading from the disk. I have tried (what I thought) reserving the code from the write proceedure and came up with this: ;==================================================== ; this is suppose to read from sector 72 read_command: call clear_screen mov CX, 3 reset_read_disk: MOV AH,00h ; Reset disk system 3 times, as recommended INT 13h loope reset_read_disk mov BX, DI mov es, bx mov AL, 1 ; AL = number of sectors to read/write (must be nonzero) MOv CH, 2 ; CH = cylinder number (0..79). MOV CL, 1 ; CL = sector number (1..18). mov DH, 0 ; DH = head number (0..1). MOV DL, 0 ; DL = drive number Mov AH, 02h ; Read INT 13h putc 0Dh putc 10 ; next line. gotoxy 0, 1 mov SI, SI; Tried also: mov SI,BX;mov SI,es;mov SI,DI call print_string ;wait for any key... mov ax, 0 int 16h jmp processed ; END Read ;==================================================== This does not seem to read from anything, at least it does not read anything to the dispaly. Where did I make the wrong turn? Thank you. |
|||
27 Mar 2008, 20:47 |
|
revolution 27 Mar 2008, 21:51
ralc wrote: mov es, bx |
|||
27 Mar 2008, 21:51 |
|
edfed 27 Mar 2008, 22:09
note that on some machines, the offset in bx shall be 0, otherwise, it don't work.
and be carefull to don't cross a 64k boundary during the read/write/verify. it may cause a dma overrun. then, the best is to write your own floppy driver. i prefer to read sectors one by one, and if error, retry at least 3 times. it is slow, but it's better. something fun: you post a question about floppy the day i buy new ones. and i think i have the same problems as you. if i try to write over 16K on the floppy, it don't works, the same for reads. |
|||
27 Mar 2008, 22:09 |
|
Mac2004 28 Mar 2008, 04:57
ralc: My boot sector example may help you. It loads a secondary binary file to memory and jumps to it. The example also shows how to handle es:bx.
http://board.flatassembler.net/topic.php?t=6529 regards, Mac2004 |
|||
28 Mar 2008, 04:57 |
|
roboman 28 Mar 2008, 14:57
I've also got an example on my page that might help. A little program that formats a dish using the bios, then writes the boot sector with the bios int 13. 'ForDex' at http://home.comcast.net/~dexos/
|
|||
28 Mar 2008, 14:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.