📄 asm_func.s43
字号:
; ******************************************************************************
; File: ASM_func.s43
; Author: Bhargavi Nisarga, Texas Instruments Inc
; Date: June 2007
;
; Routines to get address of a data table, read and write a 20-bit value
; to locked register R4.
; Accessed out of C as standard extern Calls.
;
; Note 1: The linker command file for this project has to be modified to
; create a new memory segment (CONST_HIGH - in this example). The
; linker command -Z(CONST)CONST_HIGH=10000-1FFFF is used to create a
; new memory segment in the extended memory (0x10000 - 0x1FFFF).
;
; ******************************************************************************
#include "msp430xG46x.h"
RTMODEL "__rt_version", "2" ; Ensure correct runtime model
PUBLIC __Get_Address20
PUBLIC __Write_R4
PUBLIC __Read_at_R4_plus
; Data Table in extended memory
NAME Sin_tab
RSEG CONST_HIGH
EVEN
Sin_tab DW 2048, 2447, 2831, 3185, 3495, 3750, 3939, 4056
DW 4095, 4056, 3939, 3750, 3495, 3185, 2831, 2447
DW 2048, 1648, 1264, 910, 600, 345, 156, 39
DW 0, 39, 156, 345, 600, 910, 1264, 1648
;===============================================================================
; "unsigned long __Get_Address20(void)"
; This function is used to get the 20-bit address of the data table (Sin_tab),
; initialized in the extended memory.
; Passing parameter : void
; Return parameter : unsigned long - the 32-bit return value is returned in two
; words; lower word in R12 and upper word in R13
;===============================================================================
RSEG CODE
__Get_Address20
mov.w #LWRD Sin_tab, R12 ; Lower word - R12
mov.w #HWRD Sin_tab, R13 ; Upper word - R13
reta ; Return
;===============================================================================
;" void __Write_R4(unsigned long value)"
; This function is used to write a 20-bit address in register R4
; Passing parameter: unsigned long - 32-bit value that is passed to the function
; in two words; lower word in R12 and upper word in R13
; Return parameter: void
;===============================================================================
__Write_R4
push.w R13 ; Push two words into stack
push.w R12 ; and pop a 20-bit address
popx.a R4 ; R4 has the 20-bit address
reta
;===============================================================================
;" unsigned int __Read_at_R4_plus(void)"
; This function is used to read the data located at the 20-bit address stored in
; register R4 and word increment the contents of R4
; Passing parameter: void
; Return parameter: unsigned int - 16-bit data word is stored in R12
;===============================================================================
RSEG CODE
__Read_at_R4_plus
; Read the data located at the 20-bit address stored in register R4
; and word increment R4
mov.w @R4+, R12 ; R4 acts as address variable
reta
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -