BS1 GOSUB Limit
Sapphire
Posts: 496
The Basic Stamp Syntax and Reference Manual says you can have up to 16 GOSUBs in a BS1 program. But when I tried, the program won't tokenize or load. Even though there are only 16 GOSUBs, a pop-up warning says "Limit of 16 GOSUBs was exceeded." So is the manual wrong, or is there a bug in the editor? It appears the maximum is 15. Does anyone know why?
' {$STAMP BS1} ' {$PBASIC 1.0} GOSUB A '1 GOSUB A '2 GOSUB A '3 GOSUB A '4 GOSUB A '5 GOSUB A '6 GOSUB A '7 GOSUB A '8 GOSUB A '9 GOSUB A '10 GOSUB A '11 GOSUB A '12 GOSUB A '13 GOSUB A '14 GOSUB A '15 GOSUB A '16 END A: RETURN
Comments
Oh, I've got those in there too. That's a neat trick. But this program needed exactly 16 GOSUBs (for some I2C routines) and I hit this error. I in-lined one to cut it back to 15, but wonder why that's the limit. The BS1 tokenizes GOSUB with a 4-bit GOSUB number, so it would seem that 16 should work. I wonder if the problem is with the editor, although I tried a very old STAMP.EXE (DOS) program and it too reports the same error.
It appears we intended it to be a limit of 16 but the final limit became 15 in the final implementation. Unfortunately, both the manual and the tokenizer's error message states 16 as the limit, but it definitely limits it to 15 in practice.
I don't have reason to think that there's a bug, but rather a mistake in the error message itself and the documentation also. I will check on this to see if I can determine all that for sure.
So, it's true that on the BS1 programs are limited to a maximum of 15 GOSUBs total, but the error message in the tokenizer, and consequently the documentation, incorrectly states that it's limited to 16.
We're sorry about the mistake and the inconvenience it has caused you.
It's amazing in all these years none has tested these limits before!
Great rapid response from Parallax, thanks Jeff!
Jon,
The program is attached in case you're interested. I had to make some compromises with the Ack/Nak, but otherwise it meets spec. I can read the voltages and temperature and send them back to my monitoring station. Note that I use tabs instead of spaces, so formatting might be off if you don't use them.
The tab stops are set for: 5,9,13,17,21,25,29,33,57,61,65
Jeff,
Thanks for the clarification. I too noticed the 255 limit on a BS2 (never tried to exceed it) and figured it was really 15 on the BS1, but since the documentation said 16 I was going with that. In any case, I have a work-around. I'm really pushing the limit on this one, but for this application it's just right.
It's awesome that you were able to do an I2C implementation on the BS1!