MPLAB assembly error

Thread Starter

zortharg

Joined Apr 16, 2013
4
I'm trying to compile a program for the PIC16C57 in assembly language. I am trying to make use of all 4 pages, and my program uses the majority of the 2048 instructions. But when I try to build it, there's a problem. For all the "GOTO" points that are not in the first page, the first 512 instructions, at compile it says Error[126] Argument out of range. It doesn't acknowledge that maybe, just MAYBE I already have the page bits set right and I actually DO want to "goto" a marked instruction that is not on page 00. I can stand this being a "warning" but it refuses to let me have it do that by any way I can figure out. MPLAB v6.20.
 

Markd77

Joined Sep 7, 2009
2,806
I've never used that PIC, but it may be possible to do a workaround.
If you have a label in page 1 (512-1023) try goto label - d'512'
I could be completely wrong....
 

takao21203

Joined Apr 28, 2012
3,702
Eventually you need to mask out the high bits, in assembler something like:

Rich (BB code):
movlw HIGH(l_dest)
...set status bits

goto LOW(l_dest)
It is OK for a few such GOTO's, otherwise use C also for the 16F5x.
 

ErnieM

Joined Apr 24, 2011
8,377
Perhaps, maybe, just maybe, an address not on page zero requires a number greater then 9 bits so maybe, just maybe,THE COMPILER IS EMITTING A QUITE PROPER ERROR TO YOUR INCORRECT CODE.

Moral: don't give the goto instruction a number greater then 511 as a destination.

Your next step is to figure out a way to truncate a symbolic address to never exceed this limit.
 

takao21203

Joined Apr 28, 2012
3,702
Perhaps, maybe, just maybe, an address not on page zero requires a number greater then 9 bits so maybe, just maybe,THE COMPILER IS EMITTING A QUITE PROPER ERROR TO YOUR INCORRECT CODE.

Moral: don't give the goto instruction a number greater then 511 as a destination.

Your next step is to figure out a way to truncate a symbolic address to never exceed this limit.
This is all obvious from the datasheet. I have done it some times.
Yes what else than using HIGH and LOW assembler operators would be appreciate?

This is mentioned in the MPASM help file, even if this information is not made for beginners.

Neither are 16f5x without a waterproof instruction manual.

People using assembler really must read the datasheet, there is no way around it.

When the program memory paging bits are in the status word, no assembler will modify the goto instruction to satisfy this need + emit additional code for the STATUS register.

Perhaps maybe eventually, with a macro.
 

Thread Starter

zortharg

Joined Apr 16, 2013
4
No, I found the problem. I set the device to PIC16C57 but it changed it back to PIC16C54, the chip from my last project, when I created the new project, the stupid thing. I changed it to PIC16C57 again and closed the project and opened it again and the frigging thing was back to PIC16C54! I want MPLAB 5.7 again. Unfortunately stupid winsux 7 doesn't let me use it because it's a 32 bit application, or a 16 bit application or something. But when I repeatedly change the device back to PIC16C57 it acknowledge that yes indeed it is a device which has more pages of ROM and over 512 instructions. Don't tell me my code is bad ErnieM, you haven't even SEEN my code and obviously nor do you understand that on a 2048 instruction device, the compiler should be able to handle instructions with labels on the last 1536 of them. Have no doubt, if you did see my code, your eyes would melt from its sheer awesomeness.
 

takao21203

Joined Apr 28, 2012
3,702
No, I found the problem. I set the device to PIC16C57 but it changed it back to PIC16C54, the chip from my last project, when I created the new project, the stupid thing. I changed it to PIC16C57 again and closed the project and opened it again and the frigging thing was back to PIC16C54! I want MPLAB 5.7 again. Unfortunately stupid winsux 7 doesn't let me use it because it's a 32 bit application, or a 16 bit application or something. But when I repeatedly change the device back to PIC16C57 it acknowledge that yes indeed it is a device which has more pages of ROM and over 512 instructions. Don't tell me my code is bad ErnieM, you haven't even SEEN my code and obviously nor do you understand that on a 2048 instruction device, the compiler should be able to handle instructions with labels on the last 1536 of them. Have no doubt, if you did see my code, your eyes would melt from its sheer awesomeness.
It should've been a compiler in the first place MAYBE.
DEFINITIVELY I have done 16F57.

obviously nor do you understand that on a 2048 instruction device, the compiler should be able to handle instructions with labels on the last 1536 of them

If OP maintains such a writing style, I see problems arising. People can feel offended by talk like that.

1. OP is not properly understanding COMPILER and ASSEMBLER. And no need to put the benefit of doubt on others capability to understand posts.

Possiblity 2. Troll.

Sorry for assuming such a possibility, but obviously nor do you understand that on a 2048 instruction device, the compiler should be able to handle instructions with labels on the last 1536 of them gives some proximity for that. Or minor age college student.

3. I'd welcome to see regular capitalization being used.

Don't tell me my code is bad ErnieM, you haven't even SEEN my code

Shouting is appreciate when the code is shown, but has been ignored due to stupidity.
 

ErnieM

Joined Apr 24, 2011
8,377
No, I found the problem. I set the device to PIC16C57 but it changed it back to PIC16C54, the chip from my last project, when I created the new project, the stupid thing. I changed it to PIC16C57 again and closed the project and opened it again and the frigging thing was back to PIC16C54! I want MPLAB 5.7 again. Unfortunately stupid winsux 7 doesn't let me use it because it's a 32 bit application, or a 16 bit application or something. But when I repeatedly change the device back to PIC16C57 it acknowledge that yes indeed it is a device which has more pages of ROM and over 512 instructions. Don't tell me my code is bad ErnieM, you haven't even SEEN my code and obviously nor do you understand that on a 2048 instruction device, the compiler should be able to handle instructions with labels on the last 1536 of them. Have no doubt, if you did see my code, your eyes would melt from its sheer awesomeness.
As a very minimum, proper code should compile cleanly. That means no warnings, it means CLEAN.

Incorrect code generates compiler errors. Period, end of story. Code that generates errors isn't code at all, it's just some ASCII text in search of a champion to repair it. There is no object generated, no sequence of pure machine instruction ready to be executed.

However, I would not expect someone who is not observant enough to remember to save his project to grasp the subtly of this concept.

And it is a poor craftsman indeed who blames his tools.

Here endeth the lesson.
 

DerStrom8

Joined Feb 20, 2011
2,390
Despite the rudeness of the OP, who really needs to get his act together and RESPECT the people trying to help him, I will respond.

#1: You are not entitled to our help. Do not think that we are required to answer your questions. Think about it--if you want help from us, do you really think it's a good idea to act like a rude, snobby, stuck-up little brat towards them?

#2: Just making sure--you know the PIC16C series is a one-time-programmable device, right? I never understood why anyone would use one-shot uCs for anything but professional circuit board design. Unless it's the type you can clear with UV light....

Anyway, to the OP, you'd better shape up before you find yourself shunned, if not banned. We enjoy helping kids, but only if they're respectful and honestly want to learn.

Matt
 

takao21203

Joined Apr 28, 2012
3,702
It is a fact no assembler will solve the problem.

Pecularities will increase exponentially. Sometimes the compiler really actually does not work right and you need a trick.

Nothing wrong with asking on a forum, but my recommendation really is to strip off unneccessary communications.

Keep code listings as short as possible.

Learn how to ask.

Not knowing what is a compiler and an assembler- and using an old 16C PIC.

Hope this work improves.

Dealing with all sort of PICs, 16F and 16F all through, there have been maybe 500 problems where I could have said STUPID ME.

It is interesting as such, but not worth illustrating all this experience with forum posts.

Would be interesting to see how OP is moving on- or maybe post wasn't genuine.

What is the next problem, how will OP ask, and how will it become solved. Be assured there will be 100s such problems on daily basis.
 

atferrari

Joined Jan 6, 2004
4,764
Not an extremely spectacular debut zortharg, but shocking anyway. Congratulations!

After all, ErnieM said: Perhaps, maybe, just maybe,
 
Last edited:

joeyd999

Joined Jun 6, 2011
5,237
Personally, I would have liked to have seen the code. I'd never before seen code, the awesomeness of which would melt my eyes, not written by me.

Much of the code I've seen, though, has made me cry...
 

ErnieM

Joined Apr 24, 2011
8,377
One thine before we leave this oh so useful thread... the assembler will correctly load in the 9 bit portion of the destination address when such is called for, but you have to pick a PIC that has such an address space. I know, I just tested it. You still need to set the page and there is a PAGESEL macro for that too.

BTW, the HIGH macro will only load in 8. <grin>
 
Top