Microsoft KB Archive/40719

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

COBOL Can Call Assembly Subroutine to Get Available Memory

PSS ID Number: Q40719 Article last modified on 02-02-1989

3.00 3.00A | 3.00 3.00A MS-DOS | OS/2

Summary: The Microsoft COBOL Version 3.00 or 3.00A program shown below can be used to call the assembly language subroutine listed to determine the amount of memory available. This can be used to determine the space available for a called program and will help determine if the cause of a load failure error is due to insufficient memory.

Example Code: This program should be compiled and LINKed with no COBOL.DIR, accepting the defaults: $SET ANS85 LITLINK RTNCODE-SIZE “4” OSVS ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 TEMP-VAR PIC XX. PROCEDURE DIVISION. MAIN. DISPLAY “Checking available memory” AT 0310 WITH BLANK SCREEN. CALL “FREE” USING RETURN-CODE. DISPLAY RETURN-CODE. STOP RUN. The following assembly code should be compiled with the Microsoft Macro Assembler Version 5.00 or later: .MODEL large .CODE public free ;make routine visible to COBOL free proc far ;declare it as a far call mov ah,48h ;function to allocate mem block mov bx,0ffffh ;ask for all of it int 21h ;do interrupt mov ax,bx ;NUM of block is returned in BX mov cx,16 ;Multiply by 16 to get number mul cx ;of bytes lo in AX/ hi in DX mov bx,dx ;move high bytes to bx reg ret free endp end

Copyright Microsoft Corporation 1989.