HJR-DSP: Comprehension of assembly operations and segments

Source: Internet
Author: User

DSP programming languages are assembly and C

Let's start with the compilation basics, which are several common operations

MOVE Transfer, ADD addition, sub subtraction, Mpym multiplication, MACM multiply (MACM a,b,c = "C=a*b+c")

Shift: Shift-out bit discard, vacancy 0, left n is equal to n times 2, right shift n is equal to 2 of the n-th square


For the program, mainly consists of data and code, the data is divided into initialized data and uninitialized data, such as you int A; this is uninitialized, int a = 1; this is initialization.

assembly language to segment the program space, storage data and code, note that only the variables may not be initialized, the code must be initialized

Why fragmentation, for management convenience, such as uninitialized variables will be assigned a uniform value 0

Segment not initialized:

. BSS: Holds uninitialized global variables reserved by the system, such as Int,long, where the number of bits is determined by the system

. Usect: Store user-defined, uninitialized global variables, such as defining an ABC type set to 100-bit length

Initialize segment:

. Data: A global variable that holds the initialization of the system reservation

. Sect: A global variable that holds user-defined initialization

. Text: Store Your program code

Like. BSS h,3

is to assemble a variable called H-bit length 3 into a. BSS segment

Let's look at a piece of code

	. Mmregs
	def start
	. Text
start:   MOV #0X000A, AC0
	 Amov #0X018001, XAR2
	 Amov #0X018002, XAR3
	 MOV #0X0005, *ar2
	 MOV #0X0002, *ar3
	 MACM *ar2,*ar3,ac0 here
:    B here;
	. End
The. Text above is the code snippet that tells the assembler to assemble the following code into the program space
Note Several rules for registers

The description with X is the secondary register

MACM is a multiplicative, the above code is compiled after the AC0 value is

A+2*5=20

20 in 16 notation, full 10 in 1 is 14

Then AC0 is a 40-bit register, so 0x0000000014,1 that is high, 4 is low, low is full of high-level into 1, converted into a value is 1*16+4=20

If you encounter decimal multiplication, see whether it is fixed-point DSP or floating-point DSP, Low-point, not allowed, fast, power consumption, floating point opposite

Fixed-point calculation formula, Xq = x*2 Q Power Q is the calibration number

Like Q=8, writing 0.3*5 programs.

When writing a program, the 0.3 needs to be converted to 0.3*2 8 power, or 0.3*256, and then with the converted value of the operation




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.