小编das*_*20s的帖子

如何使用静态数组的结束指针作为循环条件来比较 x86 中的地址?

从头开始编程的挑战之一是“修改程序以使用结束地址而不是数字 0 来知道何时停止。”

\n

我发现很难做到这一点,因为到目前为止,这本书只介绍了movl,,cmplincl以及寻址模式)和jmp指令。基本上,下面的代码片段中的所有内容都是到目前为止所介绍的。我发现的所有解决方案都涉及本书中尚未介绍的说明。下面的代码查找集合中的最大值。

\n
.section .data\ndata_items:             #These are the data items\n.long 3,67,34,222,45,75,54,34,44,33,22,11,66,0\n\n.section .text\n.globl _start\n_start:\n    movl $0, %edi                   # move 0 into the index register\n    movl data_items(,%edi,4), %eax  # load the first byte of data\n    movl %eax, %ebx                 # since this is the first item, %eax is\n                                    # the biggest\nstart_loop:                     # start loop\n    cmpl $0, %eax                   # check to see if we\xe2\x80\x99ve hit the end\n    je loop_exit\n    incl %edi                       # …
Run Code Online (Sandbox Code Playgroud)

linux x86 assembly pointers att

2
推荐指数
1
解决办法
278
查看次数

标签 统计

assembly ×1

att ×1

linux ×1

pointers ×1

x86 ×1