更新时间:2023-11-14 14:10:46
您似乎在尝试通过将 data_items
与一个数字进行比较来确定是否已到达末尾.你可以做的是使用循环来帮助解决这个问题.这是我想出的:
It seems like you're trying to determine whether you've reached the end of data_items
by comparing it to a number. What you can do is use a loop to help with that. Here's what I came up with:
.section .data
data_items:
.long 4,73,121,133,236,251,252
data_items_size:
.byte 7
.section .text
.globl _start
_start:
movl $0, %edi
movl data_items(,%edi,4), %eax
movl %eax, %ebx
movl $1, %ecx
loop:
cmpl data_items_size, %ecx
je exit
incl %ecx
incl %edi
movl data_items(,%edi,4), %eax
cmpl %eax, %ebx
jge loop
movl %eax, %ebx
jmp loop
loop_exit:
movl $1, %eax
int $0x80
data_items_size
标签包含 data_items
的大小.在这个例子中,我使用了 %ecx
寄存器作为循环的计数器.我试了一下,退出状态码是252,最后加253的时候还是252,看来是可以的了.希望我能帮到你:)
The data_items_size
label contains the size of data_items
. In this example, I used the %ecx
register as a counter for the loop.
I tried it and I got 252 as the exit status code, and when I added 253 at the end, I still got 252. So it seems to be working. Hope I helped you out :).