I am trying to encapsulate the code into a header and trailer. Therefore, I used the following technique:
In vectors.s, I have
_DEF_SW_VERSION .set 5407 .global VECTOR_TABLE .global _VECTOR_TABLE .global start .extern _asm_startmeup .extern ___SP_INIT .extern _asm_exception_handler .extern _asm_isr_handler .extern _dbug_sc_handler .def _header .def _header_end .def _trailer .def _trailer_end .text "header"/* * Exception Vector Table */VECTOR_TABLE:_VECTOR_TABLE:INITSP: .long ___SP_INIT /* Initial SP */INITPC: .long 0x400 /* Initial PC */vector02: .long _asm_exception_handler /* Access Error */vector03: .long _asm_exception_handler /* Address Error */vector04: .long _asm_exception_handler /* Illegal Instruction */vector05: .long _asm_exception_handler /* Divide by Zero */vector06: .long _asm_exception_handler /* Reserved */vector07: .long _asm_exception_handler /* Reserved *//* … etc … */vectorFF: .long _asm_isr_handlerstart: .long 12351236h ; 2 word header signature .long _DEF_SW_VERSION ; 2 words for version identification .word 0 ; 1 word for n_words .word 0 ; 1 word for checksum .word 0, 0, 0, 0 ; 4 words for future expansion move.w #0x2700,SR jmp _asm_startmeup_header_end:/* -------- Trailer ------*/.text "trailer"_trailer: .long 0ABCEABCFh ; 2 word trailer signature .word 0, 0, 0, 0, 0, 0 ; 6 words for future expansion _trailer_end:/* End of vector.s */ .end
In the memory, I can see header’s signature (12351236h) followed by (after some data) the trailer’s signature.
How can I make the trailer part go at the end of the code in memory?
Thanks,
Simon
The sequence of the relocatable modules in the target memory is defined in the linker command line.
In your case, you need to place the object file of the trailer module to the end of the linker's object file list.
_DEF_SW_VERSION .set 0x7777 .global VECTOR_TABLE .global _VECTOR_TABLE .global start .global _start .global _header .global _header_end .global _trailer .global _trailer_end .extern _startup .extern ___SP_AFTER_RESET .extern _asm_exception_handler .extern _asm_isr_handler .text /* * Exception Vector Table */ VECTOR_TABLE:_VECTOR_TABLE:INITSP: .long ___SP_AFTER_RESET INITPC: .long _start vector02: .long _asm_exception_handler /*..... ........ .....*/vectorFF: .long _asm_isr_handler/* ------------------------------- */ .text "header"_header: .long 12351236h ; signature .long _DEF_SW_VERSION ; version .long 0 ; Number of words .long 0 ; Checksum_header_end:/* ------------------------------- */_start:start: move.w #0x2700,SR jmp _startup /* ------------------------------- */ .text "trailer"_trailer: .long 0ABCEABCFh /* signature */ .long 0, 0, 0, /* for future expansion */_trailer_end:/* ------------------------------- */ .end
The alternative (dirty) way is to place label "_trailer:" at constant (big enough) address with .org directive.