Absolute ??

General discussion on mikroBasic for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Fritzables
Posts: 61
Joined: 07 Jun 2008 13:20
Location: Brisbane AUSTRALIA

Absolute ??

#1 Post by Fritzables » 16 Jul 2008 04:19

G'Day All,

I want to get a better understanding on why we need to use the directive absolute and how does one find what addresses should be used for a specific processor.

For example: If I was to use Dim var as Byte Absolute $30
what would most likely happen if I was to use just Dim var as Byte instead?

What part of the processor's datasheet provides address info that can be used to store directives?

Cheers
Fritzables.

Skyline
Posts: 267
Joined: 10 Jan 2006 09:35

#2 Post by Skyline » 16 Jul 2008 09:59

Hi,
What part of the processor's datasheet provides address info that can be used to store directives?
Go to chapter 3 of the device datasheet called Memory Organization, and look within this memory chapter for a section called Data Address Space. This section will tell you that data space from 0x0000 to 0x07FF is reserved for SFRs, and available RAM is from 0x0800 to 0xXXXX, ie, total of 2kB, 16kB, whatever. 0xXXXX is specific for your particular processor. Typically, you would want to put your absolutes from 0x0800 to 0xXXXX.
what would most likely happen if I was to use just Dim var as Byte
You should just use the Dim statement as it is, without the absolute keyword. The compiler will then look for a apropriate location to put the variable, and will try to optimise byte/word locations and boundaries and taking care of stack frame requirements.
If I was to use Dim var as Byte Absolute $30
then :twisted: will break loose, as location $30 is for the CPU program counter PC, and if you put something into the PC through *var* then the CPU will go bonkers.
why we need to use the directive absolute
some reasons - to optimise by yourself the placement of variables to prevent fragmentation or to speed memory copies, to equivalence different variables to use the same memory space for memory re-use, for speed of remapping/conversion of byte variables to word/dword and vice versa, to create common SFR names for SFRs for different chips, eg renaming ADPCFG1 to ADPCFG so that your same program works for different chip types, and so on.

It depends :D.

Fritzables
Posts: 61
Joined: 07 Jun 2008 13:20
Location: Brisbane AUSTRALIA

#3 Post by Fritzables » 16 Jul 2008 11:27

G'Day Skyline,

Thanks for the guidance - that was a good read and fully explains what I am after.

Much appreciated.

Fritzables :D

Post Reply

Return to “mikroBasic for dsPIC30/33 and PIC24 General”