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

📄 head.asm

📁 上传一个带源代码的嵌入式实时多任务操作系统CMX
💻 ASM
字号:
;***************************************************************************** 
;*
;* MODULE	: head.asm
;*
;* APPLICATION	: run time library C16x/ST10
;*
;* DESCRIPTION  : This header file is included in every runtime library module.
;*
;*  - Set default value of macros (when not defined on the command-line/EDE):
;*    _EXT, _USRSTACK, _SINGLE_FP, MODEL, FIX_BFWD, FIX_MULDIV
;*  - Check macro values and activate the corresponding assembler controls
;*  - Define the _CALL and _RET macros for the User Stack Model
;*
;*
;* COPYRIGHTS	: 1997 TASKING, Inc.
;*
;***************************************************************************** 


@IF( ! @DEFINED( _EXT ) )	; If _EXT has not been defined
	@SET( _EXT, 1 )		; Assume CPU is based on extended architecture
@ENDI

@IF( ! @DEFINED( @_USRSTACK ) )
	@SET( _USRSTACK, 0 )	; 1 for User Stack model
@ENDI

@IF( ! @DEFINED( @_SINGLE_FP ) )
	@SET( _SINGLE_FP, 0 )	; 1 for single precision float (non-ANSI-C)
@ENDI

@IF( ! @DEFINED( @MODEL ) )
	@MATCH( MODEL, "SMALL" )	; Default memory model is SMALL
@ENDI

@IF( ! @DEFINED( @FIX_BFWD ) )
	@SET( FIX_BFWD, 0 )	; 1 for fixing the Byte forwarding problem
@ENDI

;
; Check macros and perform appropriate action
;

@IF( @_EXT )
$EXTEND				; enable all architecture extensions
@ENDI

@IF( @EQS(@MODEL,"SMALL") )
$MODEL(small)
$NONSEGMENTED
@ENDI

@IF( @EQS(@MODEL,"TINY") )
$MODEL(tiny)
$NONSEGMENTED
@ENDI

@IF( @EQS(@MODEL,"MEDIUM") )
$MODEL(medium)
$SEGMENTED
@ENDI

@IF( @EQS(@MODEL,"LARGE") )
$MODEL(large)
$SEGMENTED
@ENDI


; When FIX_MULDIV is defined to "ILVL" the protection is not done by BCLR IEN
; but by BFLDH PSW, #0F0h, #0F0h.  Note that not all modules support this.
; Make sure that this macro is always defined by the following lines.
@IF( ! @DEFINED(FIX_MULDIV) )
	@DEFINE FIX_MULDIV IEN @ENDD
@ENDI


; The macro _BFWDNOP() expands to a NOP instruction when FIX_BFWD 
; is set to 1. This is used for a software bypass for the Erroneous Byte 
; Forwarding problem of older steps of the CPU. 
@IF( @FIX_BFWD )
@DEFINE _BFWDNOP()
	NOP
@ENDD
@ELSE
@DEFINE _BFWDNOP()
@ENDD
@ENDI


; Macro _CALL() creates the code for a direct/indirect function call
; Macro _RET() creates the code for function return.
; These macro's are added to support user stack function call and return.
; User stack code is generated if variable _USRSTACK is set, else a normal
; function call and return (CALL/RET) are generated.
; Rx is a temporary register. Most run-time routines use R2 for it.
; Register R2 is used in the return stub function and in the return macro for
; tiny and medium model, so operands may not be passed via register R2 ! R2 is
; free for use if _USRSTACK option is enabled in the C-compiler.
@if( @_USRSTACK )
@if( @eqs( @MODEL, "SMALL" ) | @eqs( @MODEL, "LARGE" ) )
@if( @_EXT )
@*define _CALL( FUNCTION_NAME, Rx ) @LOCAL( RETURN_LBL )
	mov	@Rx, #SOF @RETURN_LBL
	mov	[-R0], @Rx
	mov	@Rx, #SEG @RETURN_LBL
	mov	[-R0], @Rx
	jmps	SEG @FUNCTION_NAME, SOF @FUNCTION_NAME
@RETURN_LBL:
@endd
@*define _RET()
	mov	R2, [R0+]
	atomic	#4
	push	R2		; push segment number
	mov	R2, [R0+]
	push	R2		; push segment offset
	rets
@endd
@else
extern __iret:far		; public declaration return table stub function
@*define _CALL( FUNCTION_NAME, Rx ) @LOCAL( RETURN_LBL )
	mov	@Rx, #SOF @RETURN_LBL
	mov	[-R0], @Rx
	mov	@Rx, #SEG @RETURN_LBL
	mov	[-R0], @Rx
	jmps	SEG @FUNCTION_NAME, SOF @FUNCTION_NAME
@RETURN_LBL:
	add	R0, #4
@endd
@*define _RET() @LOCAL( __LBL )
	mov	R2, [R0]
	cmp	R2, CSP
	jmp	CC_NE, @__LBL
	mov	R2, [R0+#02H]
	jmpi	CC_UC, [R2]
@__LBL:	jmps	SEG( __iret ), SOF( __iret )
	retv				; virtual return
@endd
@endi
@else
@*define _CALL( FUNCTION_NAME, Rx ) @LOCAL( RETURN_LBL )
	mov	@Rx, #SOF @RETURN_LBL
	mov	[-R0], @Rx
	jmpa	cc_UC, @FUNCTION_NAME
@RETURN_LBL:
@endd
@*define _RET()
	; execute inter-segment jump to return label on the user stack
	mov	R2, [R0+]
	jmpi	cc_UC, [R2]
	retv				; virtual return
@endd
@endi
@else
@*define _CALL( FUNCTION_NAME, Rx )
	call	@FUNCTION_NAME		; return address pushed on system stack (@Rx not used)
@endd
@*define _RET()
	ret				; return address on the system stack
@endd
@endi

⌨️ 快捷键说明

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