Davide Ferrero
Davide Ferrero

Reputation: 185

Differences between org and code in Pic18 Assembly

i always worked with C so these first days with assembly are quite complicated for me, sorry for my stupid question. I've started some small assembly projects with MplabX and i don't understand if there is some big differences between this code:

rst    code    0x00

and this one:

org    0x00

I think that they bot sets the address at 0x00 but I don't understand if i need to start my program with org instead of code.

thank you very much for your patience. bye

Upvotes: 1

Views: 332

Answers (1)

Mike
Mike

Reputation: 2761

I think it's for the linker to use. "code" creates a new code section at the given address and so the linker can either create a block (where available if no address is provided), export it to other modules or move it. Org, on the other hand, just dumps the following content at a particular location without any option to relocate or integrate it.

There are times when you may want to do both (eg DMA to hardware etc) but for your own code, I'd recommend the "code" directive.

Upvotes: 1

Related Questions