assembly - 汇编代码的预处理不起作用(#if #else #endif)
问题描述
这是汇编代码bootcode.S
.section boot, "ax", %progbits
get_intid:
#if INTGRP==NSG1
#warning taking NSG1
mrs x0, s3_0_c12_c12_0
#else
#warning taking G0
mrs x0, s3_0_c12_c8_0
#endif
ret
.end
现在我想做预处理,以便根据变量INTGRP(NSG1或G0),在“.S”文件中选择相应的行,并将结果写入“.s”文件。
当我尝试gcc -E -DINTGRP=G0
时,它总是选择第二行。实际上它与 -D 选项无关。那么我应该如何给出命令以使#if 部分变为真呢?
ADD:
从评论中,我意识到出了什么问题。所以正确的方法是:
.section boot, "ax", %progbits
#define G0 0
#define NSG1 1
get_intid:
#if INTGRP==NSG1
#warning taking NSG1
mrs x0, s3_0_c12_c12_0
#else
#warning taking G0
mrs x0, s3_0_c12_c8_0
#endif
ret
.end
并使用命令
cc -E -DINTGRP=0 bootcode.S -o bootcode.s
或者
cc -E -DINTGRP=1 bootcode.S -o bootcode.s
谢谢您的帮助!
解决方案
推荐阅读
- javascript - 如何在反应中扩展渲染 DOM
- docker - 如何配置 Jenkins 作业以使用 Docker 构建?
- python - SQLAlchemy ORM 对不同的表使用相同的模型并传递变量来运行查询
- python - Tkinter mainloop坏了,消息框不断弹出
- android - 搜索 android Gradle 的依赖项
- excel - 在visual studio中动态创建tablix
- java - 是否可以使用 javapreparedstatement SQL 搜索 MySQL 工作台数据库中的所有表以更改值?
- python - for循环的高级使用
- amazon-web-services - 如何通过入口控制器在 Kuberenetes 中公开内部服务
- javascript - NestJS 在服务类中丢失了这个内部函数方法的上下文