30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

Output:<br />

Illegal instruction executed<br />

Explanation:<br />

This example requires the linker script p30f6014.gld. There are three<br />

parts to this example.<br />

First, an interrupt handler is written for the interrupt vector<br />

_MathErrorto handle a math error by sending an illegal instruction<br />

signal (SIGILL)to the executing program. The last statement in<br />

the interrupt handler clears the exception flag.<br />

Second, the function illegalinsnwill print an error message and<br />

call exit.<br />

Third, in main, signal (SIGILL, illegalinsn)sets the handler<br />

for SIGILLto the function illegalinsn.<br />

When a math error occurs, due to a divide by zero, the _MathError<br />

interrupt vector is called, which in turn will raise a signal that will call the<br />

handler function for SIGILL, which is the function illegalinsn.<br />

Thus error messages are printed and the program is terminated.<br />

dsPIC<br />

®<br />

Language Tools Libraries<br />

DS51456B-page 220 2004 Microchip Technology Inc.<br />

signal<br />

Description: Controls interrupt signal handling.<br />

Include: <br />

Prototype: void (*signal(int sig, void(*func)(int)))(int);<br />

Arguments: sig signal name<br />

func function to be executed<br />

Return Value: Returns the previous value of func.<br />

Example: #include /* for signal, raise, */<br />

/* SIGINT, SIGILL, */<br />

/* SIG_IGN, and SIGFPE */<br />

#include /* for printf */<br />

/* Signal handler function */<br />

void mysigint(int id)<br />

{<br />

printf("SIGINT received\n");<br />

}<br />

int main(void)<br />

printf (" là một chuỗi \ n", s);<br />

}<br />

khác<br />

{<br />

printf ("%%% c là một định dạng không rõ \ n",<br />

* Fmt);<br />

}<br />

fmt ++;<br />

phá vỡ;<br />

mặc định:<br />

printf ("% c là không rõ \ n", * fmt);<br />

fmt ++;<br />

phá vỡ;<br />

}<br />

}<br />

va_end (ap);<br />

}<br />

int main (void)<br />

{<br />

tprint (".% d% s% c", 83, "Đây là văn bản.", 'a');<br />

}<br />

Đầu ra:<br />

là một số nguyên<br />

là một chuỗi<br />

. không biết<br />

% C là một định dạng chưa biết<br />

va_arg (Tiếp theo)<br />

Thư viện chuẩn C với hàm toán học<br />

2004 Microchip Technology Inc DS51456B trang 223<br />

4.12 ĐỊNH NGHĨA CHUNG<br />

Các stddef.hconsists tập tin tiêu đề của một số loại và macro có công dụng<br />

chung<br />

trong các chương trình.<br />

va_end<br />

Mô tả: Kết thúc việc sử dụng ap.<br />

Bao gồm:<br />

Prototype: va_end # define (va_list ap)<br />

Đối số: ap con trỏ đến danh sách các đối số<br />

Ghi chú: Sau khi một cuộc gọi đến va_end, các apis con trỏ danh sách đối số<br />

được coi là<br />

không hợp lệ. Cuộc gọi hơn nữa để va_argshould không được thực hiện cho đến

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

Saved successfully!

Ooh no, something went wrong!