Modular Code

Status
Not open for further replies.

be80be

Well-Known Member
In mplab 8.15 you can't use variable definitions like this
Code:
;***** VARIABLE DEFINITIONS
        UDATA_SHR
sGPIO   res 1                   ; shadow copy of GPIO
dc1     res 1                   ; delay loop counters
dc2     res 1
;*********************************************
RESET   CODE    0x0000          ; processor reset vector
you get this errors

What I want to know is this not the same thing . And that was just a old way of doing it
Code:
;***** VARIABLE DEFINITIONS
      cblock  0x20
		
	sGPIO                    ; shadow copy of GPIO
	dc1                        ; delay loop counters
	dc2     

	endc
;**************************************************
	org    0x0000          ; processor reset vector
 
Last edited:
You have to decide if you are writing a relocatable file or not. To use the second version of your code just remove the linker file from your project.

<edit> or to use the first version, add a linker script.</edit>

Mike.
 
Last edited:
Ok i get it now. I added the 12f629.lkr to the first code and now it builds fine. I never used a linker file on the second code It also builds fine. I was trying to learn about timers
and interrupts and was reading Gooligum tutorials. I didn't start a 1 didn't read the part about adding a linker. I have all ways did it like the last part. but i like the way he code's
and wanted try it that way
 
Thanks all What i'm asking is the code I put up not the same it sure works the same the only thing is that the second one doesn't use a lkr and the first one does. Or am I wrong.
and the first one works better if you have a lot of code
 
Thanks all What i'm asking is the code I put up not the same it sure works the same the only thing is that the second one doesn't use a lkr and the first one does. Or am I wrong.
and the first one works better if you have a lot of code

The difference is that if you use a linker file, you are in charge of where to locate the code within the controller, where if you use the second one, you don't have to worry about it.

Yes, they will do the same thing, so for now, don't worry about using relocatable code. If you want to learn how to do that later, then check the elmer160 site.

Does that answer your question?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…