Assembly 查找最大数字的地址
我希望assemby中的程序能够找到最大数量,但希望以地址结束。我是汇编新手,使用at&T语法Assembly 查找最大数字的地址,assembly,x86,Assembly,X86,我希望assemby中的程序能够找到最大数量,但希望以地址结束。我是汇编新手,使用at&T语法 .section .data data_items: #These are the data items .long 3,67,34,222,45,75,54,34,44,33,22,11,66,0 .section .text .globl _start _start: movl $0, %edi # move 0
.section .data
data_items: #These are the data items
.long 3,67,34,222,45,75,54,34,44,33,22,11,66,0
.section .text
.globl _start
_start:
movl $0, %edi # move 0 into the index register
movl data_items(,%edi,4), %eax # load the first byte of data
movl %eax, %ebx # since this is the first item, %eax is
# the biggest
start_loop: # start loop
cmpl $0, %eax # check to see if we’ve hit the end
je loop_exit
incl %edi # load next value
movl data_items(,%edi,4), %eax
cmpl %ebx, %eax # compare values
jle start_loop # jump to loop beginning if the one isn’t bigger
movl %eax, %ebx # move the value as the largest
jmp start_loop # jump to loop beginning
loop_exit:
# %ebx is the return value, and it already has the number
movl $1, %eax #1 is the exit() syscall
int $0x80
只需在ebx中输入地址,而不是与ebx进行比较,而是与(%ebx)进行比较。我猜您说的是x86程序集,并添加了该标记。如果不正确,请使用适当的体系结构重新标记。世界上有不止一种类型的处理器,它们使用不同的汇编语言。