10.07.2015 Views

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

MPLAB® C30 C 编译器用户指南

SHOW MORE
SHOW LESS

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

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

MPLAB C18 与 MPLAB <strong>C30</strong> C 编 译 器 比 较例 C-6:指 定 将 一 个 变 量 存 放 到 程 序 存 储 器 中C18: #pragma romdata const_tableconst rom char my_const_array[10] ={0,1,2,3,4,5,6,7,8,9};<strong>C30</strong>: const __attribute__((space(const)))char my_const_array[10] = {0,1,2,3,4,5,6,7,8,9};注 :MPLAB <strong>C30</strong> 不 直 接 支 持 对 程 序 空 间 中 变 量 的 访 问 。 这 样 分 配 的 变 量 必 须 由编 程 人 员 显 式 访 问 , 通 常 通 过 使 用 表 访 问 行 内 汇 编 指 令 , 或 使 用 程 序 空 间可 见 性 窗 口 来 访 问 。 关 于 PSV 窗 口 的 更 多 信 息 , 参 见 第 4.15 节 “ 程 序 空间 可 视 性 (PSV) 的 使 用 ”。例 C-7:将 函 数 PRINTSTRING 分 配 到 程 序 存 储 器 中 的 地 址 0X8000C18: #pragma code myTextSection=0x8000;int PrintString(const char *s){...};<strong>C30</strong>: int __attribute__((address(0x8000))) PrintString(const char *s) {...};例 C-8:编 译 器 自 动 保 护 和 恢 复 变 量 VAR1 和 VAR2C18: #pragma interrupt isr0 save=var1, var2void isr0(void){/* perform interrupt function here */}<strong>C30</strong>: void __attribute__((__interrupt__(__save__(var1,var2))))isr0(void){/* perform interrupt function here */}C.14 存 储 模 型MPLAB C18 使 用 非 ANSI 的 小 存 储 模 型 和 大 存 储 模 型 。 小 存 储 模 型 使 用 16 位 指 针 并 将程 序 存 储 器 限 制 为 小 于 64 KB (32K 字 )。MPLAB <strong>C30</strong> 使 用 非 ANSI 的 小 代 码 模 型 和 大 代 码 模 型 。 小 代 码 模 型 将 程 序 存 储 器 限 制 为小 于 96 KB (32K 字 )。 在 大 代 码 模 型 中 , 指 针 可 能 使 用 跳 转 表 。C.15 调 用 约 定MPLAB C18 和 MPLAB <strong>C30</strong> 的 调 用 约 定 有 许 多 差 别 。 关 于 MPLAB <strong>C30</strong> 调 用 约 定 的 论述 , 请 参 阅 第 4.12 节 “ 函 数 调 用 约 定 ” 。© 2005 Microchip Technology Inc. DS51284C_CN 第 157 页

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

Saved successfully!

Ooh no, something went wrong!