斧王FUWANG 发表于 2022-5-31 17:17

Microchip C语言编译器论坛

xc16问题
dspic器件,在xc16编译器下的.S源文件里怎么定义一个结构体变量??谁试过这是官网上扣的一个例程,感觉和普通的汇编编程风格很不同额,比方说一些伪指令前面都加个“.”还有就是程序中的ExampleHPFFilter是个结构体变量么,如何定义的?

斧王FUWANG 发表于 2022-5-31 17:18

/*******************************************************************************

High Pass Filter coefficients file

//高通滤波系数文件

Company:

Microchip Technology Inc.

File Name:

examplehpf.s

Summary:

Consists of coefficients used by the filter function

//包含了滤波函数的系数

Description:

This file composes of the high pass filter coefficients that are used

by the IIRTransposed filter function to filter the incoming analog

signal. These coefficients reside in the x-memory area.

//这些系数存在于X-memory存储区域

*******************************************************************************/

/*******************************************************************************

Copyright (c) 2012 released Microchip Technology Inc.All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute

Software only when embedded on a Microchip microcontroller or digital signal

controller that is integrated into your product or third party product

(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for

additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF

MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.

IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER

CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR

OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES

INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR

CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF

SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES

(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

*******************************************************************************/

; *****************************************************************************

; *****************************************************************************

; Section: Constants

; *****************************************************************************

; *****************************************************************************

.equ ExampleHPFNumSections, 5

; ..............................................................................

;

; Allocate and initialize filter coefficients

;

; These coefficients have been designed for use in the Transpose filter only

.section .xdata, xmemory, data;THIS line was modified

;to be compatible with C30 v1.3x

ExampleHPFCoefs:

.hword0x2392; b( 1,0)/2

.hword0xB8FF; b( 1,1)/2

.hword0x3D5F; a( 1,1)/2

.hword0x2392; b( 1,2)/2

.hword0xEF39; a( 1,2)/2

.hword0x2FBB; b( 2,0)/2

.hword0xA1F2; b( 2,1)/2

.hword0x579D; a( 2,1)/2

.hword0x2FBB; b( 2,2)/2

.hword0xDA17; a( 2,2)/2

.hword0x3818; b( 3,0)/2

.hword0x9344; b( 3,1)/2

.hword0x68F9; a( 3,1)/2

.hword0x3818; b( 3,2)/2

.hword0xCC0D; a( 3,2)/2

.hword0x3C51; b( 4,0)/2

.hword0x8C80; b( 4,1)/2

.hword0x7150; a( 4,1)/2

.hword0x3C51; b( 4,2)/2

.hword0xC52E; a( 4,2)/2

.hword0x3E73; b( 5,0)/2

.hword0x8920; b( 5,1)/2

.hword0x7583; a( 5,1)/2

.hword0x3E73; b( 5,2)/2

.hword0xC175; a( 5,2)/2

; ..............................................................................

; Allocate states buffers in (uninitialized) Y data space

.section .yconst

ExampleHPFStates1:

.space ExampleHPFNumSections*2

ExampleHPFStates2:

.space ExampleHPFNumSections*2

; ..............................................................................

; Allocate and intialize filter structure

;配置和初始化,滤波器结构体

.section .data

.global _ExampleHPFFilter

;这个是对ExampleHPFFilter定义么????否则该变量是在哪里定义的??

_ExampleHPFFilter:

.hword ExampleHPFNumSections-1

.hword ExampleHPFCoefs

.hword 0xFF00

.hword ExampleHPFStates1

.hword ExampleHPFStates2

.hword 0x0000

; ..............................................................................

; Sample assembly language calling program

;The following declarations can be cut and pasted as needed into a program

;               .extern _IIRTransposeFilterInit

;               .extern _BlockIIRTransposeFilter

;               .extern _ExampleHPFFilter

;

;               .section      .bss

;

;      The input and output buffers can be made any desired size

;          the value 40 is just an example - however, one must ensure

;          that the output buffer is at least as long as the number of samples

;          to be filtered (parameter 4)

;input:         .space40

;output:      .space40

;               .text

;

;

;This code can be copied and pasted as needed into a program

;

;

; Set up pointers to access input samples, filter taps, delay line and

; output samples.

;               mov   #_ExampleHPFFilter, W0; Initalize W0 to filter structure

;               call    _IIRTransposeFilterInit ; call this function once

;

; The next 4 instructions are required prior to each subroutine call

; to _BlockIIRTransposeFilter

;               mov   #_ExampleHPFFilter, W0; Initalize W0 to filter structure

;               mov   #input, W1      ; Initalize W1 to input buffer

;               mov   #output, W2   ; Initalize W2 to output buffer

;               mov   #20, W3 ; Initialize W3 with number of required output samples

;               call    _BlockIIRTransposeFilter      ; call as many times as needed

sadicy 发表于 2022-6-3 09:08

很少看s文件

橘子阿小 发表于 2022-6-7 08:04

它是一个子函数

chenqianqian 发表于 2022-6-7 08:09

楼主还用汇编写代码?

豌豆爹 发表于 2022-6-7 10:13

为什么你贴的代码底纹是黑色的,

lcczg 发表于 2022-6-8 17:01

具体格式解释,汇编器的用户手册应该会讲。

活跃的老崔 发表于 2022-6-27 08:58

mark
页: [1]
查看完整版本: Microchip C语言编译器论坛