How do you read the object info screen? (how to proactively calculate PASM code size)
turbosupra
Posts: 1,088
I started having my PASM fit command tell me that I had exceeded 492 longs, so now I'm trying to trim out the waste in my code.
I'm wondering how I read this object info window and if I can reconcile it to just the PASM code? Is there a way to move the output of the fit command so that I can print it to the PST?
Thanks for reading.
I'm wondering how I read this object info window and if I can reconcile it to just the PASM code? Is there a way to move the output of the fit command so that I can print it to the PST?
Thanks for reading.
Comments
I usually comment out a couple of lines until it compiles again - then I now how much longs I need and start optimizing the code then.
Another pretty unknown feature of the prop-tool is that after compiling and before you change any code again you can click on any PUB/PRI/DAT section and constants./ labels and get the size or value displayed on the status-line on the bottom of the screen.
Enjoy!
Mike
I clicked on my PASM section and it said 1836 bytes, strange that it is listed in bytes for cog ram if this is indeed a representation of cog ram. If it is, it does give me a way to monitor my cog size before I exceed my limit. I have fit 492, so that would mean I exceed the limit at 1968 bytes if my assumptions about this are correct.
So fit 492 means 1968 bytes and if I click on the DAT section as you've both shown me, I can compare that number (in bytes strangely enough) to 492 longs/1968 bytes?
You can use smaller numbers after "fit" to see how much room you have left when the code is loaded to the cog.
Try "fit 250", which will cause an error if your code is longer that 250 longs since the last "org" statement. By adjusting the number up or down, you can figure out the size of your PASM code.
Any variables defined using "res" wont take up hub RAM but these do count against you as longs between "org" and "fit".
This is one reason it's hard to figure out your PASM code size using the Prop Tools "F8" feature (at least as far as I know).
no better way. But without using res and using a simple label with a long you can use F8 and you are right it is in bytes.
Enjoy!
Mike
you can put your PASM in a separate OBJ and provide a Method to give you the Adress of that block. So you still can start your cognew in the main programm.
instead COGNEW(@entry,Parameter) use COGNEW(obj.MyPasm,Parameter)
ooh shoot.
needed to correct that:
instead COGNEW(@entry,Parameter) use COGNEW(obj.MyPasm,Parameter)
is not fully correct
you need to use a variable, I guess or you confuse the compiler
somthing like
myAdr:=obj.MyPasm
COGNEW(myAdr,Parameter)
Then you can see that also on the Info-Screen for that OBJ. (you mentally neede to subtract some constant amount for the PUB method... 3 longs? or so.)
I think that RES then might show up as variable space ... unverified ... I need to try that out.
Example:
Enjoy!
Mike
Add the following before your PASM code.
And the following after the PASM code.
Characters 189 and 190 make up the horizontal resistor symbol in the Prop Tool. Now I just need to find where these reistors are in the hex display.
Looking in the far right column for the reistor symbols, I see my PASM starts at $58 and ends at $CB making it ($CB - $57) / 4 = $1D or 29 longs in size. This doesn't include any variables declared using "res" since "res" variables don't take up hub RAM space.
You could of course choose any character you think would be easy to spot in the far right colum.
Did I mention this was an awkward way of finding PASM code size?
needed to correct that:
instead COGNEW(@entry,Parameter) use COGNEW(obj.MyPasm,Parameter)
is not fully correct
you need to use a variable, I guess or you confuse the compiler
somthing like
myAdr:=obj.MyPasm
COGNEW(myAdr,Parameter)
Enjoy!
Mike
The parentheses turn it into an expression.
-Phil
this is nice ... i did not know ... thanks
Enjoy!
Mike
I copied the code to an empty window and then added pub main as F8 doesn't work without a pub. Here were the results, which I guess are pretty accurate? I'm still trying to understand msrobot's way of doing this with pub mypasm ? I tried it as the following but it didn't work, maybe it only works for entire object sizes?
no. you got me wrong. the pub does not give you the PASMSIZE but the PASMADRESS. So you can have the pasm in a seperate obj but still use it in the main object by its adress.
kind of an answer to another question you have asked lately but yet not have solved...
Enjoy!
Mike
I noticed that if I use entry (or whatever it is named in your cog new command) and then after the fit command I put exit I can then call the two pub commands and did some math I would get a difference of 1856 bytes, which was the exact same value if I clicked on the dat section like Mike and Jon said to do after compiling.
So to get the long size, I just divided by 4 and got 464, so I started adding variables to see where the limit was, as expected each long I added would add 1 to the getPasmSize value.
I was able to get to 481, when I tried for the 482nd long, I would fail the "fit 492" command that I have at the bottom of my PASM code so there is apparently the fit command accounts for 11 longs that are not between PASM entry and PASM exit, which I then transferred over to my getPasmSize as well.
Now I can programmatically and proactively keep track of my PASM code size Thanks to everyone who helped, I don't know if I'm the only one who stresses over this, but if not maybe this can help others.
pub getPasmEntry
result := @entry
pub getPasmExit
result := @exit
pub getPasmSize
result := (((@exit - @camsim)/4)+11)
-Phil
-Phil
Since no one else offered this solution though, it would be nice to have a second set of eyes, let me know what you find.
"(@exit - @entry) / 4" does not include any variables declared with "res".
Are you using the F8 info as your code size? If so, the "PUB" method you had to add has some overhead as well has initialization overhead that isn't part of your PASM code.
The "462 LONGS" value includes this extra overhead but your PASM code doesn't take up 462 longs.
-Phil
... Yup you guessed it, 11! The mystery has been solved and I did not know that, so thank you. Is there a way to programmatically count the res variables?
So I guess I have two choices, keep a manual count of the res variables or get rid of the res variables altogether. The res variables I am using are for a math function that I took from the spin compiler, but there is no reason they couldn't be initialized variables. I really can't see the advantage, or maybe I should say I haven't found the advantage to using a cog ram reserved variable over an initialized variable. Maybe it takes up less hub ram space to use res variables instead of an initialized long that has to then be copied over from hub ram to cog ram? Maybe it is purely stylistic?
-Phil
Yes. In the following example, end is a variable that's initialized with the long size of the PASM code, including the res space:
-Phil
For example, for the code posted by Phil above BST produces this listing output:
Where it plainly tells you what space is left in the cog. No need for that end - begin business unless you need it at run time of course.