Sean Schouten wrote : > Good evening my friends, > > I was reading the MPASM help file and looking at the > assembler directives; > specifically the RES-Directive. There they have the following > code example: [snipped a bit leaving the rellevant parts...] > UDATA ;This directive allows the > ;following data to be placed only > ;in the data area. > > length res 1 ;One location of memory is > width res 1 ;One location of memory is > > Start CODE 0x0000 ;Following code will be placed in > ;address 0. > > > Looking at the last line of code where the CODE-Directive had > been utilized, > I wondered if they where defining the label START as an ORG > 0x00 type of thing for later use in their code. The CODE directive starts a new "code section". In *this* case they also specifed a specific program memory address, which is optional but not unusual when it comes the "reset-point". But I'd not say "for later use in the code". What do you mean with that ? > The UDATA at the top threw me off > though... I supposed that any UDATA-Directive should be > 'finished' off by a CODE-Directive. Right, and it does. Each section (code or data) will be implicitly ended when starting a new section (code or data) using the UDATA (or one of it's relatives) or CODE directives. > > The thing is that my main program code is at the bottom of > the source, and usually where I put my ORG 0x00. If I where to implement the > above code in my code, would I replace the ORG 0x00 in the main program > code with a simple "Start"-label? You can mix your CODE sections as you like in the source, just don't put any hardcoded address on any other section then your "reset- section". The linker (MPLINK) will sort it out... > I also presumed that the UDATA-Directive that comes before the > RES-directives is a must? I don't think so, if you have s subroutine a bit down in your source code, you can use an UDATA directive right before it to allocate any RAM variables you need. Note that if you have more then one UDATA (or CODE) directive in one source file (called "module" in MPASM language) they must have unique names (like "Start" in your example) I think that you should make it a habit to always put names on all sections, that makes it much easier to read the MAP file. > Ah, a last-minute addition to this email: MPASM is > complaining that I am using CODE and UDATA in my ASM > and telling me that I can only use them when > generating an object file... You have not added a "linker script" to your MPLAB project. So MPLAB tells MPASM that you're using absolute mode code, which you aren't... > Does that mean that I am not thought of as a > likable person in this absolutely MAD world? He, I doubt MPASM have any idea whatsoever about that ! :-) :-) Jan-Erik. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist