A simple way to check how much RAM is used/available is to open the .asm file generated
after compiling.
Example;
Code:
DEFINE OSC 20
X VAR PORTB
Y VAR BYTE
loop:
FOR Y = 0 TO 7
HIGH 0 'Turn on LED connected to RB0
Pause 50 'Delay for .5 seconds
Low 0 'Turn off LED connected to RB0
Pause 50 'Delay for .5 seconds
NEXT Y
GoTo loop 'Go back to loop and blink LED forever
End
File name blink.bas. Open blink.asm after compiling, and you'll see something like this;
Code:
#define OSC 20
RAM_START EQU 00020h
RAM_END EQU 001EFh
RAM_BANKS EQU 00004h
BANK0_START EQU 00020h
BANK0_END EQU 0007Fh
BANK1_START EQU 000A0h
BANK1_END EQU 000EFh
BANK2_START EQU 00110h
BANK2_END EQU 0016Fh
BANK3_START EQU 00190h
BANK3_END EQU 001EFh
EEPROM_START EQU 02100h
EEPROM_END EQU 021FFh
R0 EQU RAM_START + 000h
R1 EQU RAM_START + 002h
R2 EQU RAM_START + 004h
R3 EQU RAM_START + 006h
R4 EQU RAM_START + 008h
R5 EQU RAM_START + 00Ah
R6 EQU RAM_START + 00Ch
R7 EQU RAM_START + 00Eh
R8 EQU RAM_START + 010h
FLAGS EQU RAM_START + 012h
GOP EQU RAM_START + 013h
RM1 EQU RAM_START + 014h
RM2 EQU RAM_START + 015h
RR1 EQU RAM_START + 016h
RR2 EQU RAM_START + 017h
_Y EQU RAM_START + 018h
PBP system variables are from R0 to RR2. Your Y variable is the last one at 018h.
Depending on how complex your BASIC program is, PBP might need to create a few
temporary variables. If it does these will show up in the .asm file like the ones above.
RAM_START and RAM_END will change depending on the PIC you compile for.
Bookmarks