问题描述
:96: 错误:`(%rax,%edx,4)' 不是有效的基/索引表达式
line97:错误:`-4(%rax,%edx,4)' 不是有效的基/索引表达式
line97: Error: `-4(%rax,%edx,4)' is not a valid base/index expression
line101:错误:`(%rax,%edx,4)' 不是有效的基/索引表达式
line101: Error: `(%rax,%edx,4)' is not a valid base/index expression
line102:错误:`-4(%rax,%edx,4)' 不是有效的基/索引表达式
line102: Error: `-4(%rax,%edx,4)' is not a valid base/index expression
我收到这些错误消息,但不知道如何解决.
I get these error messages and am not sure how to fix it.
这是我的代码:
__asm__ (
"loop:
"
"movl $1,%3
"
"movl $0, %6
"
"start:
"
"movl (%1,%3,4),%4
"
"movl -4(%1, %3, 4), %5
"
"cmpl %4, %5
"
"jle next
"
"xchgl %4, %5
"
"movl %4, (%1, %3, 4)
"
"movl %5, -4(%1, %3, 4)
"
"movl $1, %6
"
"next:
"
"incl %3
"
"cmpl %3, %2
"
"jge start
"
"cmpl $0, %6
"
"je end
"
"jmp loop
"
"end:
"
请帮助解释如何修复这些错误消息.我正在尝试在 ASM 中进行冒泡排序.
Some help explaining how to fix these error message, please. I am trying to make a bubble sort in ASM.
推荐答案
您没有说明您的目标处理器是什么,但它似乎是 x64.在 x64 上, (%rax, %edx, 4)
不是合法的组合.有关有效寻址模式的列表,请参阅处理器手册.我的猜测是你的意思是 (%rax, %rdx, 4)
.
You didn't say what processor you are targeting, but it appears to be x64. On x64, (%rax, %edx, 4)
is not a legal combination. Consult the processor manual for a list of valid addressing modes. My guess is that you meant (%rax, %rdx, 4)
.
这篇关于asm 错误消息:`(%rax,%edx,4)' 不是有效的基/索引表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!