PDA

View Full Version : code size



jmbanales21485
- 24th October 2007, 03:40
hello again,

I want to find out how get the size of the compiled code of my program. where can i check that with pbp. i know its something simple and ive searched but can't find it. thank you.

Bruce
- 24th October 2007, 14:52
You have a lot of options.

If you're using MCS as the editor the bottom screen shows the compiled file size.

If you use MPASM as the assembler you can open the .LST file and look at the bottom.

Program Memory Words Used: 63
Program Memory Words Free: 8129

With PM as the assembler you can look at the bottom of the .LST file;

+ 003C- 0063 @@0000 sleep
+ 003D- 018A clrf PCLATH
+ 003E- 283C goto @@0000

Or you could use Darrels' GetAddress macro to find & display the size something like this;


@ device pic16F877, xt_osc, wdt_off, lvp_off, protect_off

DEFINE OSC 4
DEFINE LOADER_USED 1

RetAddr VAR WORD

asm
GetAddress macro Label, Wout
CHK?RP Wout
movlw low Label ; get low byte
movwf Wout
movlw High Label ; get high byte
movwf Wout + 1
endm
endasm

loop:
@ GetAddress _Over, _RetAddr
HSEROUT [HEX4 RetAddr,13,10]
High 0 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Low 0 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Goto loop ' Go back to loop and blink LED forever

Over:
Or you could just open & examine the compiled .HEX file with your device programmer.

jmbanales21485
- 24th October 2007, 16:51
i'm using mpasm assembler and i could find the size of the code at the very bottom. thank you again.

mackrackit
- 24th October 2007, 21:13
Goto the directory that you saved your project in. That is where you will find the *.LST file Bruce told you about. If your program is called blinky, you will look for blinky.LST.

jmbanales21485
- 27th October 2007, 17:37
when mpasm compiles my code using PicBasic Pro, does the entire PBPPIC14.lib file get compiled also, or is it only the specific functions that i'm using such as ADCIN, or SEROUT, etc.

Bruce
- 27th October 2007, 17:49
Only sections of the library that are required get compiled.

Charles Linquis
- 27th October 2007, 23:06
I don't know what your needs are, but I have had two instances where I needed to
automatically watch the code size:

1. I use MCLOADER, which occupies some of the chip's upper memory.
I need to make sure my compiled code does not "run into" the bottom of MCLoader.

2. I sometimes want to know if my code is small enough to fit into a smaller, cheaper chip.

The technique I use is to add a few statements at the end of my programs -


ASM
ORG 0x1fcee <=== Put the address you don't want to over-run here.
nop
ENDASM


If the code is too big and over-runs the ORG address, MPASM will flag an error.