#option org and memory space issues

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

#option org and memory space issues

Post by Jerry Messina » Sat Sep 08, 2012 2:15 pm

I usually use a low-memory bootloader for most of my projects and use '#option org_reset' to reserve space for the bootloader. When I'm debugging my application in MPLAB, I use '#option org_program' instead so that my code ends up in the same locations as it would when running under the bootloader.

I've never noticed until now, but when I do this (use '#option org_program', that is), it seems I can produce an output hex file that has code past the end of the flash space and neither the compiler or assembler complain or give any warnings that I've exceeded the memory space.

For example, I'm using a 14K50 with 16K of flash ($4000) and I've reserved 4K for a usb bootloader. So, my app gets located at $1000, and that gives me 12K to work with ($1000-$3FFF). I have a few hundred bytes too much code at the moment, and I'm getting instructions in the asm .lst and .hex file out past $41C0, which isn't going to work out very well. The .cof file just ends at $3FFF, so when I go to debug it goes out to lunch since it's (properly) missing code. But, no errors anywhere.

When I compile with '#option org_reset', I do get an asm error at the 'goto MAIN' instruction, but that seems to be only because MAIN ends up being past $4000 and it doesn't like the initial jump. If I play around a bit with the asm file and get rid of the GOTO, MPASM seems quite happy to assemble code out past $4300, well past the end of the chip.

This seems to be an MPASM issue more so than a SF one, but any ideas as to what I can do to consistently get an error/message when I have too much code?

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sat Sep 08, 2012 3:36 pm

As you point out, it should be MPASM that reports an error but it doesn't. I've not got a fix for this I'm afraid, although I have not looked into it in too much detail. I've also encountered the same problem with C30...

Post Reply