minor notice, const and org...

Beta Testing discussion on mikroBasic.
Post Reply
Author
Message
dejan_mrtt
Posts: 101
Joined: 24 Jan 2007 18:43
Location: Skopje, Macedonia
Contact:

minor notice, const and org...

#1 Post by dejan_mrtt » 23 Oct 2008 08:41

I have noticed the following:

When declaring a constant in code, and setting its ORG address after the declaration, the Code Explorer goes blank, same as if you typed something wrong (not in place).

Example:

Code: Select all

Program Code_Explorer_Behaviour

Const MyConst as byte[3] = (10,20,30) org $E000

Sub Procedure Proc_01()
End Sub

Sub Procedure Proc_02()
End Sub

Sub Procedure Proc_03()
End Sub

Sub Procedure Proc_04()
End Sub

Sub Procedure Proc_05()
End Sub

Sub Procedure Proc_06()
End Sub

main:
While (MyConst[2] = 30)
nop
Wend
End.
If you compile a program like this, the constant will in fact be written on address declared by ORG instruction, so everything is fine....
only...
The code explorer will miss all procedures as well as all the code under the "org $E000" declaration.

In other words code explorer does not recognize the "org" when placed after const declaration.

In the above example : If you comment out the "org $E000" procedures written bellow will show up, otherwise they will be missing.

Now...I am not sure that ORG can be placed after const declaration, but I have try it 100 times and = it WORKS FINE. Yet its not in the help file, ( or I need glasses ) :shock:

However its will be nice if this can be fixed in the next version, cause working with large codes without code explorer is painful.

Regards

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#2 Post by yo2lio » 23 Oct 2008 09:31

Of course, because you don't use this procedures ....

try this :

Code: Select all

Program Code_Explorer_Not_Behaviour

Const MyConst as byte[3] = (10,20,30) org $E000

Sub Procedure Proc_01()
End Sub

Sub Procedure Proc_02()
End Sub

Sub Procedure Proc_03()
End Sub

Sub Procedure Proc_04()
End Sub

Sub Procedure Proc_05()
End Sub

Sub Procedure Proc_06()
End Sub

main:

Proc_01()
Proc_02()
Proc_03()
Proc_04()
Proc_05()
Proc_06()

While (MyConst[2] = 30)
nop
Wend
End.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

dejan_mrtt
Posts: 101
Joined: 24 Jan 2007 18:43
Location: Skopje, Macedonia
Contact:

#3 Post by dejan_mrtt » 23 Oct 2008 11:48

Sorry yo2lio, I guess you didn't read the problem in details.

Here is when CODE EXPLORER goes blank cause of the "ORG"...


Image
Image

and here is without "ORG"

Image
Image

I doubt its just on my machine...
Hope this shows what I mean, and hope it helps.

Regards.

dejan_mrtt
Posts: 101
Joined: 24 Jan 2007 18:43
Location: Skopje, Macedonia
Contact:

#4 Post by dejan_mrtt » 23 Oct 2008 12:00

....by the way , PROCEDURE or FUNCTION will appear in code explorer
even if its not called by main or elsewhere.

As I said both programs will compile fine,
and will produce HEX with the constant written on address $E000.

The only problem is of visual functionality of the CODE EXPLORER.

regards

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#5 Post by yo2lio » 23 Oct 2008 12:05

Sorry, you are right !
dejan_mrtt wrote:....by the way , PROCEDURE or FUNCTION will appear in code explorer
even if its not called by main or elsewhere.
Yes, but not in the hex file.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

FreeMan
Posts: 38
Joined: 25 Jul 2006 04:32

What PIC are you using?

#6 Post by FreeMan » 12 Nov 2008 00:42

Peace be on to you

i had read your question and i think you are using the new version of MB... well that is not really important for moment, first of all notice this:

$E000 Hex = 57344 Decimal

So the immediate question is: what PIC are you using?

Because if you are using some of the commonly used ones like PIC16F87x or PIC18F245 or similar... then this constant you are declaring will NEVE be inside the memory FLASH of that PIC ( They got just 8k to 16k or maybe little more)

My suggestion :
i think what you meant to write is this :

Code: Select all

Const MyConst as byte[3] = (10,20,30) org $000E ' and NOT $E000
this should solve everything, just one last note: If you are using interruption in your program, so then mind the space reserved to the interruption in the FLASH memory zone ( you can see those information from the >Statistic view >> Procedure detail )

be very careful using those keywords (Org and Absolute) they may bring strange behavior to your program or completly block it. and then the to find the solution to that problem may take you months to detect it.

PS: Please let us knew if this helped you or gave you any push

All the best regards,
Freeman

Peace be on to you

dejan_mrtt
Posts: 101
Joined: 24 Jan 2007 18:43
Location: Skopje, Macedonia
Contact:

#7 Post by dejan_mrtt » 20 Nov 2008 14:28

i had read your question and i think you are using the new version of MB... well that is not really important for moment, first of all notice this:

$E000 Hex = 57344 Decimal

So the immediate question is: what PIC are you using?
Immediate answer is: PIC18F66J10 (with 64K Flash)

i think what you meant to write is this :
Code:

Code: Select all

Const MyConst as byte[3] = (10,20,30) org $000E ' and NOT $E000 
Wrong. I meant exactly $E000 Hex = 57344 Decimal.

this should solve everything,
this will solve Nothing, cause we are speaking of CODE EXPLORER BEHAVIOUR ( nothing further ).

Everything you said is true, but you missed the point. Sorry. :?

ONCE AGAIN - PROBLEM IS IN CODE EXPLORER BEHAVIOR, AND THE ABOVE EXAMPLES ARE JUST WRITTEN TO SHOW THE EXACT BEHAVIOR, DON'T ANALYZE THE STRUCTURE OF THE CODE, CAUSE ITS MEANINGLESS. THANKS.

...I am sure MikroE team has understand what I am trying to say, so lets give them space to answer, a simple question.

Will it be solved in the next version?

Regards to all, and thanks for your time.

FreeMan
Posts: 38
Joined: 25 Jul 2006 04:32

There is always an alternative

#8 Post by FreeMan » 01 Dec 2008 15:19

Peace be with you,

i think there is a solution since you can use a Flash functions:

Flash_Read (x as byte)
Flash_write ( x as byte)

for more detailed information, please see: Flash Memory Library

and, you can use a pointer pointing to that memory space to read it ( i never did something similar). in worst case, you can always read and write to that specific memory address.

Note: my only perpuse is to share some info, so there is always a place for the MB members to give thier ideas.

PS: i am not an expert, but i do hope that this may stop your pain ;), good luck

Best reguards,
FreeMan

Peace be with you

dejan_mrtt
Posts: 101
Joined: 24 Jan 2007 18:43
Location: Skopje, Macedonia
Contact:

#9 Post by dejan_mrtt » 04 Dec 2008 18:49

The difference between what is required and what you suggest is:

in above problem: The Constant is written directly in the HEX, and it is programmed by the programmer when you burn the hex into the PIC.

What you suggest is for constant to be written in flash by the PIC it self (in RUN TIME).

There are also other minor issues which in the end are making those concepts very different. So when you want very long array of constants, and if you know what you are doing, you would not declare a constant like that, and then afterwards rewrite it in flash (just because you need it to be on specific address) This will result in one constant written twice in your PIC.

You don't want this, neither do I.

Peace be with you too :wink:

Post Reply

Return to “mikroBasic Beta Testing”