⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callconv.t

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 T
字号:
@c@c  COPYRIGHT (c) 1988-2002.@c  On-Line Applications Research Corporation (OAR).@c  All rights reserved.@c@c  $Id: callconv.t,v 1.3 2002/01/17 21:47:46 joel Exp $@c@chapter Calling Conventions@section IntroductionEach high-level language compiler generatessubroutine entry and exit code based upon a set of rules knownas the compiler's calling convention.   These rules address thefollowing issues:@itemize @bullet@item register preservation and usage@item parameter passing@item call and return mechanism@end itemizeA compiler's calling convention is of importance wheninterfacing to subroutines written in another language eitherassembly or high-level.  Even when the high-level language andtarget processor are the same, different compilers may usedifferent calling conventions.  As a result, calling conventionsare both processor and compiler dependent.The Hitachi SH architecture supports a simple yeteffective call and return mechanism.  A subroutine is invokedvia the branch to subroutine (XXX) or the jump to subroutine(XXX) instructions.  These instructions push the return addresson the current stack.  The return from subroutine (rts)instruction pops the return address off the current stack andtransfers control to that instruction.  It is is important tonote that the MC68xxx call and return mechanism does notautomatically save or restore any registers.  It is theresponsibility of the high-level language compiler to define theregister preservation and usage convention.@section Calling MechanismAll RTEMS directives are invoked using either a bsror jsr instruction and return to the user application via therts instruction.@section Register UsageAs discussed above, the bsr and jsr instructions donot automatically save any registers.  RTEMS uses the registersD0, D1, A0, and A1 as scratch registers.  These registers arenot preserved by RTEMS directives therefore, the contents ofthese registers should not be assumed upon return from any RTEMSdirective.> > The SH1 has 16 general registers (r0..r15)> > r0..r3 used as general volatile registers> > r4..r7 used to pass up to 4 arguments to functions, arguments above 4 are> > passed via the stack)> > r8..13 caller saved registers (i.e. push them to the stack if you need them> > inside of a function)> > r14 frame pointer> > r15 stack pointer>@section Parameter PassingRTEMS assumes that arguments are placed on thecurrent stack before the directive is invoked via the bsr or jsrinstruction.  The first argument is assumed to be closest to thereturn address on the stack.  This means that the first argumentof the C calling sequence is pushed last.  The followingpseudo-code illustrates the typical sequence used to call aRTEMS directive with three (3) arguments:@example@grouppush third argumentpush second argumentpush first argumentinvoke directiveremove arguments from the stack@end group@end exampleThe arguments to RTEMS are typically pushed onto thestack using a move instruction with a pre-decremented stackpointer as the destination.  These arguments must be removedfrom the stack after control is returned to the caller.  Thisremoval is typically accomplished by adding the size of theargument list in bytes to the current stack pointer.@section User-Provided RoutinesAll user-provided routines invoked by RTEMS, such asuser extensions, device drivers, and MPCI routines, must alsoadhere to these calling conventions.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -