Help
Advanced Member level 2
hi,
Why when reach this instruction disk_reg->command = READ; the others (disk_reg->track, and disk_reg->sector) result would become ZERO?
I get this sample from this link:
https://www.cs.cf.ac.uk/Dave/C/node13.html#SECTION001321000000000000000
Thank You.
Code:
struct DISK_REGISTER {
unsigned ready:1;
unsigned error_occured:1;
unsigned disk_spinning:1;
unsigned write_protect:1;
unsigned head_loaded:1;
unsigned error_code:8;
unsigned track:9;
unsigned sector:5; // 27 bits
unsigned command:5;
};
struct DISK_REGISTER *disk_reg;
void main(void)
{
char new_sector=2, new_track=3, READ=4, readOut=0;
while(1)
{
/* Define sector and track to start read */
disk_reg->sector = new_sector;
disk_reg->track = new_track;
disk_reg->command = READ; // !!!!?
/* wait until operation done, ready will be true */
while ( ! disk_reg->ready ) ;
/* check for errors */
if (disk_reg->error_occured)
{ /* interrogate disk_reg->error_code for error type */
//switch (disk_reg->error_code)
//......
}
}
}
Why when reach this instruction disk_reg->command = READ; the others (disk_reg->track, and disk_reg->sector) result would become ZERO?
I get this sample from this link:
https://www.cs.cf.ac.uk/Dave/C/node13.html#SECTION001321000000000000000
Thank You.