Shop OBEX P1 Docs P2 Docs Learn Events
Object exceeds runtime meory limit by 1 long, dat and assembly — Parallax Forums

Object exceeds runtime meory limit by 1 long, dat and assembly

TransistorToasterTransistorToaster Posts: 149
edited 2007-03-23 21:15 in Propeller 1
Hello,
I'd like some advice on how to solve this problem. I've been programming in assembly for a couple cogs under this pattern:
DAT
ORG 0
asmprog1
...
RES VAR1 1
ORG 0
asmprog2
...
RES VAR2 1
ORG 0
asmprog3
...
RES VAR3 1




I am getting the compiler error of "object exceeds runtime memory limit by 1 long" but I am not overpopulating. Each cog has 512 longs and I take up about 75 longs in data and nowhere close to 400 lines of instructions in the assembly code. Since I use the ORG 0 statement at the beginning of each block, I would expect the compiler to properly think that each block is meant as an assembly program plus ram space and restart the counting to check that I don't exceed 9bits=512 longs when referencing registers in the instruction s and d fields; although I could be mistaken.

The overall profile (F8) says I still have a lot of room:
Prog 1693 longs
Var 317 longs
Stack/Free 6178 longs

What is wrong?

Frank

Post Edited (transistortoaster) : 3/23/2007 3:52:09 PM GMT

Comments

  • bambinobambino Posts: 789
    edited 2007-03-23 15:53
    I had similiar problems with and SPI routine I wrote.

    Placing one org per Dat section cured it. Also it may be just a typo but the assembly var declarations are :

    var1 res 1
    var2 res 1
    var3 res 1
    
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 15:59
    >Also it may be just a typo but the assembly var declarations are :
    Yes, I just typed up erroneously the same var identifiers here. That is not legal to do.

    >Placing one org per Dat section cured it.
    i tried that right now, without improvement.
  • bambinobambino Posts: 789
    edited 2007-03-23 16:15
    >I would expect the compiler to properly think that each block is meant as an assembly program plus ram space .
    Just to clarify, the 512 longs is the combined total of space not just ram or program. So it may be that your routine is taking up the space.
    Other than that I guess I would be scratching my head too!
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 16:20
    >the 512 longs is the combined total of space not just ram or program.
    The combined plus a couple of cog specific special function registers, so I should say a tad less than 512

    Right now, I don't see the logic of an ORG 0 directive before the variables. They can't be starting at zero address because they are following the assembly instructions in the 512 longs block.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-23 16:22
    There must be something else in the portions you're not showing that's causing the problem. Your scheme should work fine. The error message comes when the program counter controlled by the ORG exceeds the 496 longs limit. The only "odd" thing that might be a problem is the use of RES, then ORG in the same DAT section. It should work. Since you tried putting DATs in front of each ORG, that couldn't be it.
  • bambinobambino Posts: 789
    edited 2007-03-23 16:25
    I don't have any files here at work with me, and I do not remember exactly how my assembly section looks. I will have a look at it tonight. I am pretty sure I used an org for each dat section but I've not looked at it since I got it finished.
    I just call it from my Top Object File and forget it.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 16:28
    Mike,
    >might be a problem is the use of RES, then ORG in the same DAT section.
    Could you explain with more words please? I have more than one program in the dat section.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 16:38
    It's probably not the ASM code what causes the error, I think that "Runtime Memory Limit" refers to something that has to do with SPIN. Also, ASM error of code that tries to access over 512 longs is "Address out of range".

    EDIT: I replicated the error, it appears when the total amount of VAR+PUB+DAT memory used exceeds 32KB. I'm also interested in how you could view the 'Overall Profile' if you get a compile error - did you comment something out? something huge?

    Post Edited (Jasper_M) : 3/23/2007 4:49:46 PM GMT
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 16:58
    I did a search on "runtime" in the propeller manual and I got only one result. Could this have anything to do with my problem?

    On p107 it's written
    [noparse][[/noparse]quote]
    To run Spin code, the new cog needs some run-time workspace, called “stack space,” where it can store temporary things like return addresses, return values, intermediate expression values, etc.


    Each time I start up a new assembly program, I do cognew(@asmStart, @var), where var is a single long that I use to pass information between the spin program that requested the assembly program to start on a new cog. In the propeller manual on p 189, it talks about passing a pointer to stack space. On p107 it says that 9 longs were enough for a led blinker program. Now, I don't see the concept of stack in the assembly, but I wonder could that have anything to do with a runtime memory error flagged by the compiler?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-23 17:11
    Assembly code does not use a stack. Your quote from the manual doesn't apply here.

    My comment was based on the fact that RES causes the cog address counter in the assembler to increment, but not the DAT address counter. That's why a RES can only appear at the end of a cog's code. It shouldn't affect anything if you follow the RESs with an ORG.

    Again, I suspect the problem is in the stuff you didn't show in your posting.
  • potatoheadpotatohead Posts: 10,260
    edited 2007-03-23 17:55
    I thought just using an org was sufficient for this.

    Could the org 0 be the problem?
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 18:03
    potatohead said...
    I thought just using an org was sufficient for this.

    Could the org 0 be the problem?

    "org" is just a shorter way to write "org 0" , so it shouldn't be.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 18:29
    My code is built from the graphics_demo.spin. I cut out a bunch of DAT constants which were unused drawing information at the end of the big block of DAT. This allowed the compiler to accepted more lines of code in the assembly section above the latter. So far, I suspect that the compiler thinks the whole block of DAT is meant to take up 512 longs.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 18:32
    Jasper,

    Jasper_M said...

    EDIT: I replicated the error, it appears when the total amount of VAR+PUB+DAT memory used exceeds 32KB. I'm also interested in how you could view the 'Overall Profile' if you get a compile error - did you comment something out? something huge?
    I commented out the drops that made the vase overflow.

    TransistorToaster said...

    The overall profile (F8) says I still have a lot of room:
    Prog 1693 longs
    Var 317 longs
    Stack/Free 6178 longs
    Post Edited (TransistorToaster) : 3/23/2007 6:38:33 PM GMT
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 18:35
    Yes, I was wondering HOW did you manage to do that - you can't get to that window if the code doesn't compile. So you did comment something out, right? Something that caused the problem?

    EDIT: Sorry, I didn't notice the first one of those two posts.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 18:37
    This edit feature is a mixed blessing...
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 18:39
    Ah, the Graphics demo uses VERY MUCH stack:

    _stack = ($3000 + $3000 + 100) >> 2 'accomodate display memory and stack

    This is like 3/4 of whole RAM. So you have VERY LITTLE space left actually - remember that the free space is Stack/free - and the stack takes 24KB.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-23 18:45
    Strictly speaking, the display memory is not allocated in the stack. The _stack statement just tests for that amount of space between the start of the stack and the end of memory. The large blocks for the bitmap and display buffer are allocated at fixed locations at the end of memory and the _stack statement just takes that into account.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 18:47
    Yes, but they are within the space declared as the object stack, right?

    EDIT: No, wait, I understand now - it just prevents the stack from expanding on the buffers.

    And this is the source of the problem - I created the error by adding stuff, then removed it by subtracting the number of longs from _stack. So it really means it's an out-of-memory case.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 18:50
    Somebody said...

    Ah, the Graphics demo uses VERY MUCH stack:

    _stack = ($3000 + $3000 + 100) >> 2 'accomodate display memory and stack

    This is like 3/4 of whole RAM. So you have VERY LITTLE space left actually - remember that the free space is Stack/free - and the stack takes 24KB.

    I was meaning to ask at point point where all the RAM is allocated for the video memory. I could use the video mode that has no buffer (i.e. direct drawing to the screen) and recover a lot of RAM.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 18:54
    TransistorToaster said...

    I was meaning to ask at point point where all the RAM is allocated for the video memory. I could use the video mode that has no buffer (i.e. direct drawing to the screen) and recover a lot of RAM.

    You mean tile-based mode? Graphics can't be done using Parallax drivers without a bitmap buffer. TV_text doesn't have a bitmap buffer AFAIK.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-23 19:09
    There is no "video memory" on the Propeller.

    All video on the Propeller requires a driver program written in assembly language that runs in one or more cogs. These drivers always (for speed) have a small buffer in the cog memory, but this is usually enough only for one or two scan lines. Some of the hires VGA text drivers have a byte-wide text buffer in main RAM, but most of them and the TV driver use a word-wide buffer for each character. This word contains a pointer into the ROM font table entry for the character and some color information as well. The bitmapped graphics drivers (VGA and TV) use the same pointer, but it points to a bitmap for a 16 x 32 or 16 x 16 pixel "tile" in main memory. The graphics.spin driver knows about this tile layout for the screen's bitmap.

    The Hydra "sprite" graphics are done differently. There's still a "tile" layout to the video display since that's how the video hardware works, but the Hydra graphics drivers generate the tile information "on the fly" from the sprite information. You'll have to read the Hydra manual for details.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 19:20
    Mike Green said...
    There is no "video memory" on the Propeller.
    The Hydra "sprite" graphics are done differently. There's still a "tile" layout to the video display since that's how the video hardware works, but the Hydra graphics drivers generate the tile information "on the fly" from the sprite information. You'll have to read the Hydra manual for details.

    Umm, what tile layout? I don't quite get it... The display is not mapped into tiles - the video drivers usually handle the output as a pixel stream, not tiles. Are you referring to that a fixed number of pixels are outputted with each waitvid with "that's how the video hardware works"? But it's not really a tile layout since the division to blocks is only horizontal. And by shifting, smooth scrolling etc. are still achieved. Or do you refer to their way of using tilemaps as backgrounds?
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 19:30
    >Graphics can't be done using Parallax drivers without a bitmap buffer.
    How come?

    From graphics_demo.spin:

    _stack ($3000 + $3000 +100) >>2
    bitmap_base=$2000
    display_base=$5000

    gr.setup(16,12,73, display_base) ' or put bitmap_base

    gr.copy() 'it contains the code to copy from one memory region to the other with nothing more. I thought that according to what is put in the gr.setup the graphics routines either wrote to the memory actively scanned by the video dedicated cog or the off screen memory region that is copied.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 19:35
    Ah, you're just going to ditch the back buffer. I never thought of that. Yeah, that should work and should free 12KB of mem.

    EDIT: Of course, it will cause flickering.
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 19:39
    I just cut the stack by $3000, changed the pointers and it's working. I just need to play around so to minimize the appearance of the drawing.
  • Jasper_MJasper_M Posts: 222
    edited 2007-03-23 19:55
    By the way, I tried that myself, and the whole demo crashed after some time if I didn't remove the gr.Copy. It seems that longmove doesn't like it if destination and source are the same (maybe... or then it hangs for some other weird reason..)
  • TransistorToasterTransistorToaster Posts: 149
    edited 2007-03-23 21:15
    I took out the gr.copy. There is nothing to copy when you use only one RAM region for the display.
Sign In or Register to comment.