Microsoft KB Archive/40719

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:22, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q40719 to Microsoft KB Archive/40719 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.