Download Assembler/Linker/Librarian User's Guide
Transcript
Assembler/Linker/Librarian User’s Guide 6.3 PROGRAM MEMORY Program memory code must be organized into a logical code section. To do this, the code must be preceded by a code section declaration (See 4.9 “code - Begin an Object File Code Section”) to make it relocatable. Absolute Code Equivalent Relocatable Code Start clrw option code ;Address determined ;by the linker. Start clrw option Prog1 org 0x0100 movlw 0x0A movwf var1 Prog1 code 0x0100 ;Start at 0x0100 movlw 0x0A movwf var1 If more than one code section is defined in a source file, each section must have a unique name. If the name is not specified, it will be given the default name .code. Each program memory section must be contiguous within a single source file. A section may not be broken into pieces within a singe source file. The physical address of the code can be fixed by supplying the optional address parameter of the code directive. Situations where this might be necessary are: • Specifying reset and interrupt vectors • Ensuring that a code segment does not overlap page boundaries EXAMPLE 6-2: RELOCATABLE CODE Reset code 0x0lFF ;Fixed address goto Start Pgm code ;Address determined by the linker clrw option 6.4 LOW, HIGH AND UPPER OPERATORS Low, high and upper operators are used to return one byte of a multi-byte label value. If low is used, only bits 0 through 7 of the expression will be used. If high is used, only bits 8 through 15 of the expression will be used. If upper is used, only bits 16 through 21 of the expression will be used. Operator Definition low Return low byte of operand. high Return high byte of operand. upper Return upper byte of operand. scnsz_low Return low byte of section size. scnsz_high Return high byte of section size. scnsz_upper Return upper byte of section size. scnend_low Return low byte of section end operand. scnend_high Return high byte of section end operand. scnend_upper Return upper byte of section end operand. scnstart_low Return low byte of section start operand. scnstart_high Return high byte of section start operand. scnstart_upper Return upper byte of section start operand. Operator precedence information may be found in 3.5 “Arithmetic Operators and Precedence”. DS33014K-page 142 © 2009 Microchip Technology Inc.