因此,在尝试编译和运行程序时出现段错误(内核已转储)。该程序使用选择排序对数字数组进行排序,然后显示排序后的数组。我不知道是什么原因造成了细分错误。任何帮助或建议,将不胜感激。
.section .data
format:
.asciz "%d\n"
numbers:
.int 6, 1, 5, 3, 9
smallInt:
.int 0
.section .text
.global main
main:
leaq numbers(, %rdi,4), %rsi
movq $4, %rcx
movq $4, %rbx
movq (%rsi), %rax
movq %rax, smallInt
addq $4, %rsi
decq %rbx
jz output
loop:
movq (%rsi), %rax
cmpq smallInt, %rax
jl minimum
jmp group
minimum:
movq %rax, smallInt
group:
decq %rbx
addq $4, %rsi
jnz loop
decq %rcx
jz output
addq $1, %rdi
leaq numbers(, %rdi,4), %rsi
jmp loop
output:
addq $0, %rdi
loopOutput:
movq numbers(, %rdi, 4), %rax
pushq %rax
pushq $format
call printf
addq $8, %rsp
cmpq $4, %rdi
je end
addq $1, %rdi
loop loopOutput
end:
movq $1, %rax
movq $0, %rbx
int $0x80