我找到最大值的代码:
# %edi - Holds the current index
# %ebx - Largest element so far
# %eax - Current element
.section .data
data_items:
.int 3,67,34,222,45,75,65,55,45,35,100,300,0
.section .text
.global _start
_start:
movl $0, %edi
movl data_items (,%edi,4), %eax
movl %eax, %ebx
start_loop:
cmpl $0, %eax
je loop_exit
incl %edi
movl data_items(,%edi,4), %eax
cmpl %ebx, %eax
jle start_loop
movl %eax, %ebx
jmp start_loop
loop_exit:
movl $1,%eax
int $0x80
此代码的输出:echo $?
将打印为44
。
但是当我使用gdbtui
调试它时,我在300
中获得了值%ebx
。
那么为什么在调用程序退出中断时会破坏%ebx
的值?