【发布时间】:2012-02-11 14:14:45
【问题描述】:
我正在使用 gcc 编译汇编代码,我想在编译过程中打印文件中包含的自定义消息。我希望能够做这样的事情:
custommessage:
.incbin "custommessage.txt"
.print custommessage
这可能吗?
【问题讨论】:
标签: gcc assembly compilation directive
我正在使用 gcc 编译汇编代码,我想在编译过程中打印文件中包含的自定义消息。我希望能够做这样的事情:
custommessage:
.incbin "custommessage.txt"
.print custommessage
这可能吗?
【问题讨论】:
标签: gcc assembly compilation directive
不,您不能直接执行此操作,因为 .print 指令只需要打印字符串。
但是,如果您愿意先对您的消息文件执行一个小的转换,您可以得到您想要的:
sed -e 's/^/.print \"/' -e 's/$/\"/' custommessage.txt > msg.txt
这会将.print " 前置,并将" 附加到每一行。
然后在你的汇编文件中
.include "msg.txt"
将打印您的所有消息。
【讨论】: