This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

address space overflow with getchar

I just added a getchar to a program compiling as an Xsmall memory model with Large Code size.

As soon as I add the getchar, I get an address space overflow in the BIT SPACE. I am not sure what this means and how to approach it's solution.

Can someone shed light on this?

  • If you try to fit a quart into a pint pot [1], it won't fit - it will overflow

    The same principle applies to processor memory:
    Any processor has only a finite memory capacity; if you try to put in more data than the available capacity, it will overflow

    Possible solutions are:
    1. Increase the capacity;
    2. Reduce the data.

    In the case of the BIT space, the capacity is fixed by the processor architecture, so 1 is not an option;
    You will therefore have to reduce your usage of BIT space.

    The Linker listing (or "map") file shows your memory usage.

    [1] 1 Quart = 2 Pints - about a litre.

  • Gee, I'm not sure if your reply was meant to be humorous or pedantic and condecending. The price of asking for help, I guess. I appreciate the time and effort to respond.

    I realize I should have provided more detail.

    1. The code before inclusion of getchar runs fine.

    2. The inclusion of getchar results in a BIT ADDRESS SPACE OVERFLOW.

    3. Looking at the map, only one BIT out of the 251's 00:0020H to 00:007FH BIT space is used.

    This is what I don't understand. I have RAM defined in that area.

    If I use _getkey(), the problem goes away and, I guess, I could ignore it. It would be nice to have an insight into why a single BIT usage generated a OVERFLOW.

  • Hmmmm,

    Is it possible that you told the compiler/linker to use the BIT space for something else AND now that you are trying to use a BIT, there is no space for it?

    Take a look at the MAP file and see what's occupying the BIT space.

    Jon

  • It seems my answer didn't get posted...here it is again

    Only a single BIT of the BIT space is used by getchar. I don't understand why an overflow is being generated.

    I have gotten around the problem by using _geykey() but will have to write my own gets() (since it uses getcgar()) unless I can solve this.

    Does someone have the source for the Keil getchar()?