Download MicroMonitor User`s Manual
Transcript
9.4 Establishing a Stack Frame for Various CPU Architectures Since we eluded to the establishment of a stack frame in the previous section, we’ll very briefly show how to set up an application-owned stack for ARM, MIPS, PowerPC and Coldfire. Note that it is beyond the scope of this document to go into a lot of target-specific detail; however, the basic setup of a non-monitor-owned stack is essential. Each of these examples are included in the demo application code under the uMon source code distribution, they are shown here simply for completeness of the discussion. Each of these startup points uses the “start” tag and assumes that the first ‘C’ function is Cstart(). They simply establish the stack pointer to be the end of the AppStack[] array, then jump to Cstart(). This sort of pre-C code is generally part of a compiler package called crt0.s; however, it is provide here to provide independence from that linkage. 9.4.1 ARM-Based Stack Setup .extern AppStack .extern Cstart .global start .text start: ldr sp, =(AppStack + 4096 - 16) jump_to_c: bl Cstart 9.4.2 MIPS-Based Stack Setup #define sp #define k0 $29 $26 .extern AppStack .extern Cstart .global start .text .set noreorder start: la addiu addiu sp, AppStack sp, 4096 sp, -16 la j nop k0,Cstart k0 goToC: 9.4.3 Coldfire-Based Stack Setup .extern .extern .global AppStack Cstart start .text start: move.l #AppStack+(4096-16),%sp jsr Cstart 9.4.4 PowerPC-Based Stack Setup #define #define #define sp r0 r7 1 0 7 95