30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

There are a number of reasons why providing built-in functions is preferable to<br />

requiring programmers to use inline assembly. They include the following:<br />

1. Providing built-in functions for specific purposes simplifies coding.<br />

2. Certain opitmizations are disabled when inline assembly is used. This is not<br />

the<br />

case for built-in functions.<br />

3. For machine instructions that use dedicated registers, coding inline assembly<br />

while avoiding register allocation errors can require considerable care. The<br />

built-in functions make this process simpler as you do not need to be concerned<br />

with the particular register requirements for each individual machine<br />

instruction.<br />

This chapter is organized as follows:<br />

• Built-In Function List<br />

• Built-In Function Error Messages<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 376<br />

5.2 BUILT-IN FUNCTION LIST<br />

2004 Microchip Technology Inc.<br />

This section describes the programmer interface to the MPLAB C30 C compiler<br />

built-in<br />

functions. Since the functions are “built in”, there are no header files associated<br />

with<br />

them. Similarly, there are no command-line switches associated with the built-in<br />

functions – they are always available. The built-in function names are chosen<br />

such that<br />

they belong to the compiler's namespace (they all have the prefix __builtin_), so<br />

they will not conflict with function or variable names in the programmer's<br />

namespace.<br />

__builtin_divsd<br />

Description: The function computes the quotient num/ den. A math error<br />

exception<br />

occurs if denis zero. Function arguments are signed, as is the function<br />

result. The command-line option -Wconversionscan be used to<br />

detect unexpected sign conversions.<br />

Prototype: int __builtin_divsd(const long num, const int den);<br />

Argument: num numerator<br />

den denominator<br />

Return Value: Returns the signed integer value of the quotient num/ den.<br />

Assembler<br />

Operator / Machine<br />

Instruction:<br />

Các thông báo lỗi sau đây được tạo ra khi các chức năng tích hợp được sử dụng<br />

không chính xác.<br />

Tham số để __builtin_function () không phải là địa chỉ của một đối tượng trong<br />

mã, PSV, hoặc phần EEDATA<br />

Đối số cho các chức năng tích hợp sau đây phải là một địa chỉ đối tượng rõ<br />

ràng:<br />

• __builtin_tblpage<br />

• __builtin_tbloffset<br />

• __builtin_psvpage<br />

• __builtin_psvoffset<br />

Ví dụ, nếu objis đối tượng trong một phần thực thi hoặc chỉ đọc, cú pháp sau<br />

có giá trị:<br />

unsigned trang = __builtin_function (& obj);<br />

__builtin_psvoffset<br />

Mô tả: Chức năng trả về trang PSV bù đắp của các đối tượng có địa chỉ là<br />

được coi là một tham số. Đối số pmust là địa chỉ của một<br />

đối tượng trong một dữ liệu EE, PSV hay không gian bộ nhớ thực thi; nếu<br />

không một<br />

thông báo lỗi được sản xuất và biên soạn không. Xem không gian<br />

thuộc tính trong MPLAB®<br />

Hướng dẫn C30 C Compiler của người dùng.<br />

Nguyên mẫu: int __builtin_psvoffset (const void * p);<br />

Đối số: p địa chỉ đối tượng<br />

Quay trở lại giá trị: Trả về số trang PSV offsetof đối tượng có địa chỉ là<br />

được coi là một tham số.<br />

Assembler<br />

Điều hành / Máy<br />

Hướng dẫn:<br />

psvoffset<br />

__builtin_return_address<br />

Mô tả: Chức năng này trả về địa chỉ trả về của hàm hiện tại, hoặc của<br />

một trong những người gọi của nó. Đối với levelargument một giá trị từ 0 sản<br />

lượng<br />

địa chỉ trả về của hàm hiện nay, giá trị sản lượng 1 sự trở lại<br />

địa chỉ của người gọi của chức năng hiện tại, và vv. Khi mức độ<br />

vượt quá chiều sâu ngăn xếp hiện tại, 0 sẽ được trả lại. Chức năng này<br />

chỉ nên được sử dụng với một đối số khác không cho mục đích gỡ lỗi.<br />

Nguyên mẫu: int __builtin_return_address (const mức int);<br />

Đối số: mức Số khung để quét lên gọi chồng.<br />

Quay trở lại giá trị: Trả về địa chỉ trả về của hàm hiện tại, hoặc của một trong<br />

của nó

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!