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

📄 ext_intrinsics.asm

📁 Extended Memory Access Using IAR v3.42A and CCE v2
💻 ASM
字号:
; ******************************************************************************
; File:     Ext_Intrinsics.asm
; Author:   Bhargavi Nisarga, Texas Instruments Inc
; Date:     July 2007
; 
; Routines to access the upper memory above 64-KB data area 
; Accessed out of C as standard extern Calls.
;
; These assembler functions are mainly to used to access the upper memory above 
; 64 KB as a data area or access the 20-bit SFRs in lower 64 KB.
;
;   Note: This assembler file should be included in the project while exceuting
;		 C programs which interface the global functions listed in this
;		 assembler file.  
;   
; ******************************************************************************
			.global __data20_read_char 
			.global __data20_read_short           
			.global __data20_write_char		
			.global __data20_write_short
            .global __data16_write_addr
            .global __data16_read_addr						

;===============================================================================
; "unsigned char __data20_read_char(unsigned long __addr)"
; This function is used to access the upper memory above 64-KB as a data area. 
; An unsigned char present at the upper memory above 64 KB is read.
; Passing parameter : unsigned long __addr - the 20-bit address is stored in long
;					integer as two words; lower word in R12 and upper word in R13
; Return parameter  : unsigned char - the 8-bit char return value is the data   
;                   present at the 20-bit address location is returned in R12.
;===============================================================================					
						.text
__data20_read_char:	
						push.w 	R13			;upper word
						push.w	R12			;lower word
						popx.a	R13			;20-bit address
						;Move 8-bit char value at the 20-bit addr locn to R12
						movx.b	0x0(R13), R12	;R12 contains the return value	 
						reta				; return

;===============================================================================
; "unsigned short __data20_read_short(unsigned long __addr)"
; This function is used to access the upper memory above 64-KB as a data area. 
; An unsigned short interger present at the upper memory above 64 KB is read.
; Passng parameter : unsigned long __addr - the 20-bit address is stored in long
;				   integer as two words; lower word in R12 and upper word in R13
; Return parameter : unsigned short - the 16-bit return value is the data   
;                  present at the 20-bit address location is returned in R12.
;===============================================================================					
						.text
__data20_read_short:	
						push.w 	R13			;upper word
						push.w	R12			;lower word
						popx.a	R13			;20-bit address
						;Move 16-bit short value present at the 20-bit address 
						;(in R13) location to R12
						movx.w	@R13, R12	;R12 contains the return value
						reta				; return

;===============================================================================
; "void __data20_write_char(unsigned long __addr, unsigned char __value)"
; This function is used to access the upper memory above 64-KB as a data area in
; address order to write a 8-bit char value into the extended memory whose 20-bit 
; is passed to the function as a 32-bit long integer.
; Passing parameter : unsigned long __addr - the 20-bit address location to which
;		    a char value is to be written is stored in long integer as 
;		    two words; lower word in R12 and upper word in R13; 
;		    unsigned short __value - the 8-bit char value stored in     
;                   R14, is the data that is to be written into the 20-bit 
;		    address location.
; Return parameter  : Void
;===============================================================================																		
						.text				
__data20_write_char:	
						push.w	R13			;upper word			
						push.w	R12			;lower word			
						popx.a	R13			;20-bit address			
						;Write the 8-bit char value in R14 onto the 20-bit 
						;address (in R13) location
						movx.b	R14,0x0(R13)
						reta				; return					
						
;===============================================================================
; "void __data20_write_short(unsigned long __addr, unsigned short __value)"
; This function is used to access the upper memory above 64-KB as a data area in
; order to write a 16-bit short integer into the extended memory whose 20-bit 
; address is passed to the function as a 32-bit long integer.
; Passing parameter : unsigned long __addr - the 20-bit address location to which
;		    a char value is to be written is stored in long integer as 
;		    two words; lower word in R12 and upper word in R13; 
;		    unsigned char __value - the 16-bit char value stored in R14,    
;                   is the data that is to be written into the 20-bit addr locn.
; Return parameter  : Void
;===============================================================================
						.text
__data20_write_short:	
						push.w	R13			;upper word			
						push.w	R12			;lower word			
						popx.a	R13			;20-bit address			
						;Write the 16-bit short value in R14 onto the 20-bit 
						;address (in R13) location 
						movx.w	R14,0x0(R13)
						reta				; return					
;===============================================================================
; "void __data16_write_addr(unsigned short __addr, unsigned long __value)"
; This function is used to access 20-bit SFRs in lower 64 KB. An unsigned long  
; value having 20-bit data can be written into the lower 64-KB memory location
; that can store a 20-bit value.
; Passing parameter : unsigned short __addr - the 16-bit address location, in  
;                   the lower 64-KB memory space that can store a 20-bit value
;					is stored in register R12;
;					unsigned long __value - the long integer contains the 20-bit
;					value in two words; lower word in R13 and upper word in R14.
; Return parameter  : Void
;===============================================================================						
						.text
__data16_write_addr:	
						push.w 	R14			;upper word
						push.w	R13			;lower word
						popx.a	R14			;20-bit address
						;Move the 20-bit address in R14 to a 16-bit address 
						;(in R12) location, i.e. move a 20-bit value to a  
						;20-bit SFR in the lower 64-KB memory location
						movx.a	R14, 0x0(R12)
						reta				; return
;===============================================================================
; "unsigned long __data16_read_addr(unsigned short __addr)"
; This function is used to access 20-bit SFRs in lower 64 KB. A 16-bit unsigned 
; short address that contains 20-bit address value is read.
; Passing parameter : unsigned short __addr - the 16-bit address location of the  
;                   20-bit SFR , which can stores a 20-bit value, in the lower 
;					64-KB memory space is stored in register R12
; Return parameter  : unsigned long __value - the 20-bit value that was present  
;					at the 16-bit address location in the lower 64 KB memory, is
;					returned an a long integer contained in two words; lower
;					word in R12 and upper word in R13.
;===============================================================================						
						.text
__data16_read_addr:	
						;R12 has the 16-bit address of a 20-bit SFR
						pushx.a @R12			;push 20-bit addr to stack
						;pop as two words
						pop.w R12			;lower word in R12			
						pop.w R13			;upper word in R13
						reta				; return	
														
						.end				; End of assembler code												

⌨️ 快捷键说明

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