如何在 Xcode 6.1.1 上重复 GNU 汇编程序中的指令?
How to repeat an instruction in GNU assembler on Xcode 6.1.1?
我正在尝试使用 Xcode6.1.1(我猜是使用 GNU 汇编程序)编译代码,目标是 iPad air2(aarch64)
.macro saving_callee_prsv_regi used_regi_index
.if \used_regi_index >= 19
i = 19
.rept \used_regi_index - 19
str x\i,[sp,#-8*(\i-18)] // fail here: x\i
i = i + 1
.endr
.endif
.endm
但是上面的代码编译失败。我意识到 "i" 是符号而不是值,我找到“.irp symbol,values”并写了一个新版本。
.macro saving_callee_prsv_regi_2 used_regi_index
.if \used_regi_index >= 19
i = 19
.rept \used_regi_index - 19
.irp idx, i // fail here, "i" is expression not value?!
str x\idx,[sp,#-8*(\idx-18)]
i = i + 1
.endr
.endif
.endm
虽然新代码仍然无法通过编译,但我的预期结果是:
当 saving_callee_prsv_regi 19 -->
str x19,[sp,#-8]
当 saving_callee_prsv_regi 22 -->
str x19,[sp,#-8]
str x20,[sp,#-16]
str x21,[sp,#-24]
str x22,[sp,#-32]
有什么建议吗?谢谢!
GNU 汇编程序主要是作为 C 编译器的后端开发的,因此它缺乏适合人类的功能。我能想到的最好的是:
.macro saving_callee_prsv_regi used_regi_index
.irp i, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
.if \i <= \used_regi_index
str x\i,[sp,#-8*(\i-18)]
.endif
.endr
.endm
(根据需要调整列表。)
我正在尝试使用 Xcode6.1.1(我猜是使用 GNU 汇编程序)编译代码,目标是 iPad air2(aarch64)
.macro saving_callee_prsv_regi used_regi_index
.if \used_regi_index >= 19
i = 19
.rept \used_regi_index - 19
str x\i,[sp,#-8*(\i-18)] // fail here: x\i
i = i + 1
.endr
.endif
.endm
但是上面的代码编译失败。我意识到 "i" 是符号而不是值,我找到“.irp symbol,values”并写了一个新版本。
.macro saving_callee_prsv_regi_2 used_regi_index
.if \used_regi_index >= 19
i = 19
.rept \used_regi_index - 19
.irp idx, i // fail here, "i" is expression not value?!
str x\idx,[sp,#-8*(\idx-18)]
i = i + 1
.endr
.endif
.endm
虽然新代码仍然无法通过编译,但我的预期结果是:
当 saving_callee_prsv_regi 19 -->
str x19,[sp,#-8]
当 saving_callee_prsv_regi 22 -->
str x19,[sp,#-8]
str x20,[sp,#-16]
str x21,[sp,#-24]
str x22,[sp,#-32]
有什么建议吗?谢谢!
GNU 汇编程序主要是作为 C 编译器的后端开发的,因此它缺乏适合人类的功能。我能想到的最好的是:
.macro saving_callee_prsv_regi used_regi_index
.irp i, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
.if \i <= \used_regi_index
str x\i,[sp,#-8*(\i-18)]
.endif
.endr
.endm
(根据需要调整列表。)