CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old January 21st, 2005, 07:10 AM
    GreekS85 GreekS85 is offline
    Junior Member
     
    Join Date: Jan 2005
    Posts: 4
    GreekS85 is an unknown quantity at this point (<10)
    Memory allocation in Virtual Mode

    Hi guys! i'm trying to allocate a modest amount of memory, merely 512 bytes, so i call the DOS interrupt 21h to allocate memory:

    Input:
    AH=48h (The code for memory allocation function)
    BX=20h (paragraphs of 16 bytes, 20hx16=512d)

    after return from the interrupt, i get:

    Output
    AX=0008 (error code, 8 stands for Insufficient memory)
    BX=0007 (available paragraphs, only, what?! 70h bytes?)

    My System runs on Mindows XP. The program is assembled using debug run through cmd.exe. I definately have more memory then that; 256mb.

    My config files for the 16bit subsystem are:
    AUTOEXEC.NT
    @echo off
    lh %SYSTEMROOT%\system32\mscdexnt.exe
    lh %SYSTEMROOT%\system32\redir
    lh %SYSTEMROOT%\system32\dosx
    SET BLASTER=A220 I5 D1 P330 T3

    CONFIG.NT
    dos=high, umb
    device=%SystemRoot%\system32\himem.sys
    files=40

    I wouldn't like to use anything else for that small an amount! XMS is way too complicated. I also need something not depending on HIMEM.sys or 386 processors. Do you suggest any othe memory management system?
    Reply With Quote
      #2    
    Old January 22nd, 2005, 01:36 PM
    japheth japheth is offline
    Junior Member
     
    Join Date: Dec 2002
    Location: Germany
    Posts: 7
    japheth is an unknown quantity at this point (<10)
    Re: Memory allocation in Virtual Mode

    you possibly have to free the memory first. DOS usually loads an app into the largest free conventional memory block and marsk the whole block as being used by the app. Very often this block was the only free block, so any further memory alloc request will fail.
    Reply With Quote
      #3    
    Old January 23rd, 2005, 10:40 AM
    GreekS85 GreekS85 is offline
    Junior Member
     
    Join Date: Jan 2005
    Posts: 4
    GreekS85 is an unknown quantity at this point (<10)
    Re: Memory allocation in Virtual Mode

    Thanks Japheth!
    You gave me a some ideas on how to overcome that problem.

    Is there a way to find out the descriptor i have to feed to the int21 function 4A(Modify memory allocation - Resizes allocated memory block)?

    Is this number located somewhere in the psp? how can i find out the PSP location from the debug program?
    If in virtual mode DOS allocates so much memory for debug, then i guess i have to reduce its memory, right?
    Reply With Quote
      #4    
    Old January 23rd, 2005, 02:50 PM
    japheth japheth is offline
    Junior Member
     
    Join Date: Dec 2002
    Location: Germany
    Posts: 7
    japheth is an unknown quantity at this point (<10)
    Re: Memory allocation in Virtual Mode

    > If in virtual mode DOS allocates so much memory for debug, then i guess i have to > reduce its memory, right?

    > Is there a way to find out the descriptor i have to feed to the int21 function
    > 4A(Modify memory allocation - Resizes allocated memory block)?

    Its the value of the PSP itself (DS or ES register when program starts, or get it with int 21h, ah=62h)
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:53 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009