Browse Prior Art Database

Method of calculating free storage space greater then 2GB in 16-bit SM "C" applications

IP.com Disclosure Number: IPCOM000012045D
Original Publication Date: 2003-Apr-03
Included in the Prior Art Database: 2003-Apr-03
Document File: 2 page(s) / 54K

Publishing Venue

IBM

Abstract

Disclosed is a method of calculating free storage space greater then 2GB in 16-bit "C" code linked with SM memory libraries.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 92% of the total text.

Page 1 of 2

  Method of calculating free storage space greater then 2GB in 16-bit SM "C" applications

Legacy applications that are written in 16-bit "C" and build with small model libraries have serious limitation of not been able to calculate storage space greater then 2GB due to the lack of support for 32-bit calculation in small model "C" libraries. As the result, some application can't be installed on new large medias. Using in-line 16-bit assembly block inside the application solves this problem.

Using assembly MUL instruction within "C" application resolves the 16-bit limitation of "C" small memory model. MUL instruction uses a WORD (16-bit) operand in multiplication with value stored in AX register; the result is then stored in the DX:AX register pair (32 bit). Here is a sample:

_asm {

mov dx, { Drive number }

mov ah,36h ; get disk free space

int 21h ;

cmp ax,0fffh ; error???

je err

mov BytePerSec,cx ; Bytes per sector

mov SecPerClus,ax ; Sector per Cluster

mov AvailClus,bx ; Free Clusters

mov TotalClus,dx ; Total Clusters

;; Calculate bytes per cluster of the drive.

;; if the drive is greater then 2GB, dx register is none zero.

mul cx ; ( Bytes per sector * Sector per Cluster )

mov sec_size_off,ax

mov sec_size_sel,dx

;; now you can use the above information to calculate the available

;; or total space of the drive in mega byte or gega byte.

...........................

...........................

..........................

jmp short exit

err:

..............................