The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: byte1918 on December 04, 2010, 03:57:45 PM

Title: Display Used Disk Space
Post by: byte1918 on December 04, 2010, 03:57:45 PM
Hello,

This is my first post here, so please bear with me.

I have this homework assignment that requires me to display the used disk space on the screen.

I know I can get all the info I need by using the 36h function of 21h interruption.
Quote       Returns:     
                      AX         Sectors per cluster
                                   FFFFh if invalid drive specified
                      BX         Number of available clusters
                      CX         Bytes per sector
                      DX         Total number of clusters per drive

Ok so AX*BX*CX should be the free space. and AX*CX*DX should be the total disk space.
I have written a simple procedure to multiply a double word with a word, the result being a double word. (assuming the result doesn't overflow)
Ok, so after I get the total disk space and the free space, I should subtract free space from total disk space, but the problem is I'm not really sure how to do that, since both numbers are on two double words, and as far as I can see subtracting word by word won't work.

Any tips are appreciated. Also if you know a better way to get the used disk space, feel free to tell me.

thanks

PS. I'm using TASM
Title: Re: Display Used Disk Space
Post by: clive on December 04, 2010, 04:28:20 PM
You can use SUB, followed by SBB, to extend the math beyond 16-bit, this uses the "borrow" flag. This is similar to ADD, followed by ADC, using the carry.
Title: Re: Display Used Disk Space
Post by: byte1918 on December 04, 2010, 04:54:26 PM
Can't believe this, I tried it on paper but failed somehow (damn this cold and headache), anyway it works. thanks