1

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

  • I don't know about this assembler, but some assemblers allow you to specify the intended starting address of the code without affecting the actual location of the code within the produced program (there's no padding at the start of the program image). For example, the first byte of a MSDOS .COM file is loaded into offset 0x100 in memory. Another example is that the BIOS of a PC will load code into location 0x0000:0x7c00. For a .COM program org 00100h is used, for a boot sector, org 07c00h is used. – rcgldr Feb 27 '15 at 23:04

1 Answers1

1

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.

Mike
  • 2,721
  • 1
  • 15
  • 20
  • this is an interesting information, i've never realized that it could be different for linker and not only writing code, thank you – Davide Ferrero Feb 28 '15 at 12:54