inc command on 28X1

nick12ab

Senior Member
I don't think this has been covered before as a search in the forum for 'inc' failed to get any results, but I've just noticed that using the inc command:
Code:
inc b0
takes up more program memory than adding one to a variable:
Code:
b0 = b0 + 1
using inc uses six bytes of program memory but using b0 = b0 + 1 uses just three bytes. Is this meant to be a punishment for being lazy and not typing the variable name twice?

Also, it only seems to apply to the 28X1 as it doesn't apply to the 28X or the 28X2, on which both commands are only two bytes each.
 

MartinM57

Moderator
Number of bytes consumed by PICAXE basic commands as a general topic has been discussed many times.

It depends on:
- the command
- the PICAXE variant
- where it appears in the code

As far as I know there are no definitive answers.

See it as a punishment or the opportunity to squeeze that extra byte of space for code that doesn't quite fit in a PICAXE....
 

nick12ab

Senior Member
This should also be mentioned in the various code optimisation pdfs that are dotted around the forum.

I also remember that the compiler whilst saying that it has a capacity of 4096 but it complains at about anything above 4087. In confirming this value, I copy-and-pasted 4000 lines of 'b0 = 0' and it said 'Memory used: 0 bytes of 4096'. In testing this, it turned out that they had either fixed the flaw or the flaw only occurs in complicated code. I also tried it for 'b0 = b0 + 1' to confirm that the bytes used by that command aren't miscounted. That also allows it to get up to the full 4096.

ADDED: I wonder what would happen if I had an extra-long program and added loads of 'b0 = 0' commands after the end to make the compiler say that it only takes up 0 bytes and downloaded it... The possibilities are:
• The download dialog doesn't appear (and maybe Programming Editor crashes)
• Nothing gets downloaded onto the chip
• The extra bytes are lost
• Part of the interpreter is overwritten and therefore this is a way to destroy a PICAXE non-electrically
 
Last edited:

Technical

Technical Support
Staff member
The compiler can currently cope with about double the program memory capacity before crashing, so if you have a 'realistic' program it will accurately report the over use of memory (e.g. 28 bytes over). The reason it keeps compiling is for exactly that reason, to give you a realistic idea of how much your program is over the maximum capacity. However we will look into stopping the memory crash at very large over memory usage.

. The possibilities are:
• The download dialog doesn't appear (and maybe Programming Editor crashes)
• Nothing gets downloaded onto the chip
• The extra bytes are lost
• Part of the interpreter is overwritten and therefore this is a way to destroy a PICAXE non-electrically
It is never possible to overwrite the interpreter, it is 'write protected' within the PIC. So simply not possible, whatever you try to do via a download. In this scenario a bunch of 0s will be downloaded, which isn't a realistic BASIC program but also won't do any harm.
 

nick12ab

Senior Member
Technical just said that it wouldn't work on anything.

@Jamster.

Seriously, don't waste time with the Support / surport site.

Use Gadwin or Win7 screengrab
to post a quick .jpg.

e
How about copying the URL of the image itself and using the tags so that the image is embedded in the page? Like this:
[IMG]http://surportpages.webs.com/however.bmp
But make sure it's NOT a bitmap as it's a massive file size if it is. And as you have it open in Paint, you could save it as a JPG as Paint supports that.

What's JAMtech?
technical said:
It is never possible to overwrite the interpreter, it is 'write protected' within the PIC. So simply not possible, whatever you try to do via a download. In this scenario a bunch of 0s will be downloaded, which isn't a realistic BASIC program but also won't do any harm.
So does that mean that if I were to purchase a conventional PIC programmer, I'd be restricted on what memory could be used or would the programmer be able to remove the protection. Obviously, the code read out protect bits can be cleared only when the entire PIC is erased or else they'd be useless but are they the same thing as the write protect bits?
 

Technical

Technical Support
Staff member
Block write protect and code protect are completely different things, see the Microchip datasheets for more details. If you erase any code protected PIC in a PIC programmer you will erase all memory and fuses, so will get back to a factory fresh blank condition.
 

westaust55

Moderator
I don't think this has been covered before as a search in the forum for 'inc' failed to get any results, but I've just noticed that using the inc command:
Code:
inc b0
takes up more program memory than adding one to a variable:
Code:
b0 = b0 + 1
using inc uses six bytes of program memory but using b0 = b0 + 1 uses just three bytes. Is this meant to be a punishment for being lazy and not typing the variable name twice?

Also, it only seems to apply to the 28X1 as it doesn't apply to the 28X or the 28X2, on which both commands are only two bytes each.
Not sure what you are using to get your figures. :confused:

1. With PE V5.3.6 I see 6 bytes for both INC b0 and b0 = b0+1
2. From my study of the PE and how programs are tokenised, INC b0 is internally just converted to b0 = b0 + 1 when the program is tokenised and downloaded.

For some further information (not all is disclosed), have a read here:
http://www.picaxeforum.co.uk/showthread.php?t=17782
 
Last edited:

nick12ab

Senior Member
nick12ab.

Because
1. That pic reports 2,359, 350 bytes.

2. It is BIG and intrusive.

e
Ok. Attachments unfortunately have the limitation of only being able to upload two images. It would probably be better for a small image and it is still better than making everybody go to that seemingly infamous 'surport' site. Doesn't the forum technology support a feature that hides a section of a post which can be shown by pressing a 'show' button or something like that? But as it is pretty much impossible to buy a mouse without a wheel these days, getting past the images is much easier than clicking a link.

My example is on my serial glcd driver thread where I put a table of results for a test because the forum removes extra spaces so doesn't allow tables:


or seeing how much Jamster likes links, I'll provide one for him: here

But it's all a matter of opinion really - and screen resolution.
 

eclectic

Moderator
Just my opinion, but,
be subtle.

No screaming billboards.

Allow the viewer to see the basic info,
then to choose to view, if required.

It also saves on webspace.

e
 

Attachments

hippy

Technical Support
Staff member
But it's all a matter of opinion really - and screen resolution.
And download bandwidth for some, especially as more people are using mobile devices and 3G connections these days. Not everywhere has access to affordable high-speed broadband yet.

The biggest problem with inline links to images on other sites is that, some time in the future, the images or hosting site may disappear which can take something quite important away from a posting.
 

nick12ab

Senior Member
No screaming billboards.

Allow the viewer to see the basic info,
then to choose to view, if required.
Your opinion is a good opinion but as the post it was in didn't have much else relating to the test in it and the rest as responding to other posts, the test results ARE the basic info. I don't see how a table of results is a 'screaming billboard'. And in total, signatures probably take up more screen space than small images like that.

Just out of interest, as I'm coming up to 100 posts, are 'New Member', 'Member' and 'Senior Member' the only three ranks for non-moderators and how many posts are required to become a senior member - because if it's only 100 then it's quite underrated.
 

eclectic

Moderator
Your opinion is a good opinion but as the post it was in didn't have much else relating to the test in it and the rest as responding to other posts, the test results ARE the basic info. I don't see how a table of results is a 'screaming billboard'. And in total, signatures probably take up more screen space than small images like that.

Just out of interest, as I'm coming up to 100 posts, are 'New Member', 'Member' and 'Senior Member' the only three ranks for non-moderators and how many posts are required to become a senior member - because if it's only 100 then it's quite underrated.
See posts 7, 9 and 13.

And, as Zebedee said.....

e
 

nick12ab

Senior Member
Sorry, I didn't notice hippy's post as it was posted before I started writing the post afterwards so I never saw that. The mobile devices and 3G internet bandwidth are good points. I'll attach images from now on. I probably would have never switched from doing that if the attachment limit was more lenient.
 

lbenson

Senior Member
>the forum removes extra spaces so doesn't allow tables

Put the tables within [code]...[/code] tags.

Code:
   1   2   3
 

nick12ab

Senior Member
Not sure what you are using to get your figures. :confused:

1. With PE V5.3.6 I see 6 bytes for both INC b0 and b0 = b0+1
I'm using that version too. Are you sure it's in 28X1 mode and not any other because for me the others report the same amount for each but the 28X1 doesn't.

Speaking of which, there hasn't been a definite answer for thae difference yet.

>the forum removes extra spaces so doesn't allow tables

Put the tables within
Code:
...
tags.

Code:
   1   2   3
Excellent idea. Thanks for that.
 

Technical

Technical Support
Staff member
'inc b0' and 'let b0 =b0 + 1' parse as exactly the same thing, so give a same length program.

Have you enabled AQA/OCR assembler under the advanced button on the mode selection page? If so you will get different readings due to the fact 'inc' is then processed as one of the special assembler commands instead.
 

nick12ab

Senior Member
'inc b0' and 'let b0 =b0 + 1' parse as exactly the same thing, so give a same length program.

Have you enabled AQA/OCR assembler under the advanced button on the mode selection page? If so you will get different readings due to the fact 'inc' is then processed as one of the special assembler commands instead.
Yes, those were enabled. After disabling them, 'inc b0' took up the same amount of space as 'let b0 = b0 + 1'. Thank you.


Hang on a minute... isn't allowing assembler commands on a PICAXE opening up the interpreter to be read off using assembler commands?
 

Technical

Technical Support
Staff member
Hang on a minute... isn't allowing assembler commands on a PICAXE opening up the interpreter to be read off using assembler commands?
AQA and OCR assembler is not real PIC assembler, it's a faked 'made up assembler' language which is specified by the exam boards for UK 'A' level exams. So no.
 

westaust55

Moderator
Fromt he Rev Ed website:

OCR/AQA A Level Assembler Code Compiler.
The OCR/AQA grade A2 Electronics courses (UK) uses a special 'assembler code' language. This special compiler allows PICAXE users to write PICAXE programs using the A level assembler code set.


In line with Technical's comments about being a pseudo assembler, further details are available here.
 
Top