@ 符号在 C 语言中是什么意思?
Global Variable Address Modifier (@address)
You can assign global variables to specific addresses with the global variable address modifier. These variables are called 'absolute variables'. They are useful for accessing memory mapped I/O ports and have the following syntax:
Declaration = <TypeSpec> <Declarator>[@<Address>|@"<Section>"]
[= <Initializer>];
<TypeSpec> is the type specifier, e.g., int, char
<Declarator> is the identifier of the global object, e.g., i, glob
<Address> is the absolute address of the object, e.g., 0xff04, 0x00+8
<Initializer> is the value to which the global variable is initialized.
A segment is created for each global object specified with an absolute address. This address must not be inside any address range in the SECTIONS entries of the link parameter file. Otherwise, there would be a linker error (overlapping segments). If the specified address has a size greater than that used for addressing the default data page, pointers pointing to this global variable must be "__far". An alternate way to assign global variables to specific addresses is (Listing 8.8).
Listing 8.8 Assigning global variables to specific addresses
#pragma DATA_SEG [__SHORT_SEG] <segment_name>
setting the PLACEMENT section in the linker parameter file. An older method of accomplishing this is shown in Listing 8.9.
Listing 8.9 Another means of assigning global variables to specific addresses
<segment_name> INTO READ_ONLY <Address> ;
Listing 8.10 is a correct and incorrect example of using the global variable address modifier and Listing 8.11 is a possible PRM file that corresponds with example Listing.
Listing 8.10 Using the global variable address modifier
//看这意思,就是把int型变量glob地址从0x0500开始,并把值10初始化时放在0x0500
int glob @0x0500 = 10; // OK, global variable "glob" is
// at 0x0500, initialized with 10
void g() @0x40c0; // error (the object is a function)
void f() {
int i @0x40cc; // error (the object is a local variable)
}
全局变量地址修饰符(@address)
您可以使用全局变量地址修饰符将全局变量分配给特定地址。这些变量称为“绝对变量”。它们对于访问内存映射的I / O端口很有用,并具有以下语法:
声明= <TypeSpec> <声明符> [@ <地址> | @“ <部分>”]
[= <Initializer>];
<TypeSpec>是类型说明符,例如int,char
<Declarator>是全局对象的标识符,例如i,glob
<Address>是对象的绝对地址,例如0xff04、0x00 + 8
<Initializer>是全局变量初始化到的值。
将为每个用绝对地址指定的全局对象创建一个段。该地址不得在链接参数文件的SECTIONS条目中的任何地址范围内。否则,将出现链接器错误(重叠段)。如果指定的地址的大小大于用于寻址默认数据页的大小,则指向此全局变量的指针必须为“ __far”。将全局变量分配给特定地址的另一种方法是(清单8.8)。
清单8.8将全局变量分配给特定地址
#pragma DATA_SEG [__SHORT_SEG] <段名称>
在链接器参数文件中设置PLACEMENT部分。清单8.9显示了完成此操作的较旧方法。
清单8.9将全局变量分配给特定地址的另一种方法
<段名称> INTO READ_ONLY <地址>;
清单8.10是使用全局变量地址修饰符的正确和不正确的示例,清单8.11是与示例清单相对应的可能的PRM文件。
清单8.10使用全局变量地址修饰符
//看这意味着,就是把int型变量glob地址从0x0500开始,并把值10初始化时放在0x0500
int glob @ 0x0500 = 10; //确定,全局变量“ glob”为
//在0x0500处,以10初始化
无效g()@ 0x40c0; //错误(对象是一个函数)
无效f(){
int我@ 0x40cc; //错误(对象是局部变量)
}
主要在嵌入式内应用多,将某一变量名称指向寄存器的地址处,之后对此地址处寄存器的操作(赋值)只需要对此变量名操作即可
以pic16F877A中pic16F877.h头文件对寄存器地址的命名举例
static volatile unsigned char INDF @0x00;
static volatile unsigned char TMR0 @0x01;
这里将0x00地址处赋予INDF,而INDF对应多少位呢,unsigned char限定INDF表示8位,这样就对0x00物理地址下的8位寄存器命名了一个变量,之后操作此地址下寄存器只需要操作此变量即可,不需要在记忆寄存器的地址是什么,只需要记住它对应的变量名即可,毕竟记名字要比一系列数字要好的多;
还可以使用指针符号来对某一地址下寄存器进行命名举例说明
以上面情况举例
#define INDF (static volatile unsigned char *)0x00;
将0x00强制类型转换为unsigned char 的指针类型 并对它赋予另外一个名字INDF
上一篇: C 语言 memset 函数说明
下一篇: C 语言中的复数 - C 语言基础
推荐阅读
-
C 语言中的 double 是什么意思
-
@ 符号在 C 语言中是什么意思?
-
在 C 语言中,->(指针运算符)是什么意思 -/* 由于 p 此时指向 A,因此 p->a == A.a,即 1 */ ** 由于 p 此时指向 A,因此 p->a == A.a。
-
aps是什么意思_不同的富士APS-C画幅微单区别在哪里,档次是怎么划分的?-X-A系列原本指的是富士的入门级微单,最大的特点是没有使用富士X-Trans™CMOS 传感器,目前在售的有两款,分别是XA5和XA7。 富士(FUJIFILM)X-A5/XA5 15-45套机 富士(FUJIFILM)X-A7/XA7 15-45套机 目前这两款相机都处于历史最低价附近,XA5套机2699元,XA7套机3999元。XA5就是一个标准的入门级相机,定位就是时尚小巧自拍,在2699这个价位不要对它的性能有太多的奢求。 XA7价格来到了3999元,这就很有意思了,富士把入门型的相机价格推到了4000元,并且提供了自拍翻转屏和4K30P视频录制,这样一款相机就很有性价比了。 XE3是老款的中端相机,价格和入门级的XA7是一样的,都是3999元,这两款相机如何做选择呢?XE3有着更多的按键意味着更好的操控,但屏幕不是自拍翻转屏所以这点不如XA7好用。 要注意的是XE3用的是富士独有的X-Trans™CMOS III传感器,XA7是普通的2400万像素传感器,你可以理解为X-Trans才是富士的精髓。 富士(FUJIFILM)X-E3 15-45套机 当然,买新不买旧,XA7的新功能和自拍翻转屏可能会更适合你。 XT200是富士专门针对vlog市场推出的相机,其实之前的XA7也可以拍摄vlog,但XT200是富士官方宣传中的第一款vlog相机。数码防抖+3.5mm 麦克风口+自拍翻转屏+无裁切4K30P,这些都是XT200的优势,但这款相机也是普通的2400万像素传感器,没有用富士独有的X-Trans,可能是从价格角度考虑做了阉割吧。 富士(FUJIFILM)X-T200/XT200 微单相机 Vlog相机 富士XT30是我认为富士性价比最高的微单照相机,注意我说的是照相机。理由很简单,因为从拍照角度来看XT30和XTXT3几乎没有明显差距,主要是操控差了一些、视频性能大幅削弱,但好歹也是个有着双波轮+曝光补偿波轮+快门速度波轮的相机,操控方面不会太差的。视频方面也有着超采4K 30P的规格,支持F-log输出。 可以这么说,如果你只拍照,那么XT30是富士微单中性价比最高的,视频方面XT30也不差,只不过没有专业的10bit和4K60P而已。 富士(FUJIFILM)X-T30/XT30 15-45套机 XT3和XT4得放在一起说,这两款相机其实都挺好,420 10bit 4K60P的专业视频模式基本代表了APS-C画幅的上限水平。XT4还提升了电池续航增加了五轴防抖,配上富士独特的胶片滤镜,不管是拍照还是拍视频都非常优秀。 不要觉得这两款相机贵,同价位里能做到4K60P的微单也就是M43画幅的GGHGH5S,最便宜的G9机身也要7000多,这APS-C画幅的XT3机身接近8000也算合理价格范围内。除此之外的4K60P机身只有13998的松下S5和15999的佳能R6了。 富士(FUJIFILM)X-T3/XT3 1855套机 富士(FUJIFILM)X-T4/XT4 微单相机 套机(18-55mm) B站更新4K视频投稿后有很多人想拍摄4K升格,在很长一段时间里富士XT3和XT4是最优选,毕竟兼顾视频和拍照,对焦也还算能用。 X-Pro3和X-Pro2这两款微单可以算是旁轴相机,是富士官方意义上的旗舰级相机。从用料做工操控按键角度来说的确是旗舰级别,但视频性能方面只有4K30P,价格却比XT3还贵,可能这就是旁轴情怀带来的溢价吧。 富士(FUJIFILM)X-Pro3 微单相机 机身 黑色 我在之前的文章里提过很多次,有一些相机属于如果你想买你压根不会看测评,如果你犹豫那么这款相机不适合你,为什么这么说,因为有一些比较小众的相机可能在性能上并不好,但独特的外形、操控、体积、传承赋予了它独特的定位。譬如富士X-Pro系列微单就是旁轴的电子化,理光GR传承大师的扫街理念,尼康DF的外形源自胶片时代的相机,这些相机就不是针对大多数消费者的,定位就是小众。所以我说喜欢就买,不要考虑什么性能规格。 X100系列相机是一款不可换镜头的等效35mm旁轴数码相机,从外形看就是经典的复古造型。这两款相机和X-Pro3一样,如果你喜欢那就买,别犹豫, 你在市场上找不到同类型的其他数码相机,徕卡Q是28mm,索尼RX1R系列是35mm但外形不够复古,X100系列就是独特的你没有其他选择。 那么X100F和X100V该如何选择呢?X100F的镜头很一般甚至算不上好,如果我没记错的话和初代的X100是同款镜头,X100V的镜头是全新制作的很棒,X100V的机身性能也和XTX-Pro3差不多。 富士(FUJIFILM)X100F 数码相机 旁轴 2430万像素 富士(FUJIFILM)X100V 数码相机 旁轴 2610万像素 还是那句话,这两款相机也是那种如果你喜欢那就毫不犹豫下单的类型,而且这两款相机也没有竞品。 以前不推荐富士的原因是原厂镜头太贵,现在唯卓仕给富士出了四款可以自动对焦的大光圈镜头,覆盖35到130mm的焦段,可以基本满足人像摄影爱好者的需求。拍风景的话国产很多镜头厂商都有富士卡口的手动镜头可以选择,从这个角度来说富士微单就非常值得入手了。 和友商竞品相比:
-
在 Python 中,pass 在 C 语言中的等价物是什么?