OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Write sectors to usb drive from assembly
PostPosted: Mon Dec 28, 2015 4:58 am 
Offline

Joined: Mon Dec 28, 2015 4:53 am
Posts: 2
I'm developing a bare metal software (there is no operating system, my code is started by the grub), and i would like to save some measurements data to an usb drive. I switched to real mode after my tests in order to use BIOS interrupts, but before I saved my data to the memory address 0xEE00 (it is an awailable address in real mode).

I used the following code to write a sector to my usb drive:

Code:
mov  ax, 0
mov  es, ax
mov  ah, 0x03
mov  al, 0x01
mov  cx, 1
mov  dl, 0x80 ; drive
mov  dh, 0 ; head
mov  bx, 0xEE00
clc
int  0x13


After the tests, the "pendrive is reading or writing" led was blinking, i.e. my pendrive showed that this code writes something to the pendrive. CF is zero, i've checked it. However, after I read the first ~5 Mbytes from this pendrive by linux dd, I can't find the modified sector. I tried to write a sector filled by 'A' characters, but there is no such a sector on my pendrive. What is the problem? One more thing: I've removed my hard discs from the test computer.


Top
 Profile  
 
 Post subject: Re: Write sectors to usb drive from assembly
PostPosted: Mon Dec 28, 2015 5:13 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
You don't set DS or SS. At least you haven't shown that you do.

What happens if you follow the write by a read to a different address, using the same parameters otherwise? What if you just try to read a known sector with those values - do you get the right data? 0x80 for the drive number looks like a magic number to me.


Top
 Profile  
 
 Post subject: Re: Write sectors to usb drive from assembly
PostPosted: Mon Dec 28, 2015 5:55 am 
Offline

Joined: Mon Dec 28, 2015 4:53 am
Posts: 2
Thank you very much, I set ds = 0, and my I found my modified sector on the pendrive =D>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: belliash, SemrushBot [Bot] and 100 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group