先说没学会汇编语言,但是任务要求完成,根据自己的理解写了一些注解,但是按照我的理解就出不了循环,所以该如何理解,特别是循环体里面,到底是让怎么处理数据
08049645 <phase_2>:
8049645: f3 0f 1e fb endbr32
8049649: 55 push %ebp
804964a: 89 e5 mov %esp,%ebp
804964c: 83 ec 48 sub $0x48,%esp
804964f: 8b 45 08 mov 0x8(%ebp),%eax
8049652: 89 45 c4 mov %eax,-0x3c(%ebp)
8049655: 65 a1 14 00 00 00 mov %gs:0x14,%eax
804965b: 89 45 f4 mov %eax,-0xc(%ebp)
804965e: 31 c0 xor %eax,%eax
8049660: 83 ec 04 sub $0x4,%esp
8049663: 6a 08 push $0x8
8049665: 8d 45 d4 lea -0x2c(%ebp),%eax
8049668: 50 push %eax
8049669: ff 75 c4 pushl -0x3c(%ebp)
804966c: e8 3c 06 00 00 call 8049cad <read_n_numbers>
//调用函数,类似与数组Array[i]
8049671: 83 c4 10 add $0x10,%esp
8049674: 85 c0 test %eax,%eax
8049676: 75 07 jne 804967f <phase_2+0x3a> //eax不是0就继续
8049678: b8 00 00 00 00 mov $0x0,%eax
804967d: eb 65 jmp 80496e4 <phase_2+0x9f>
//第一个答案
804967f: 8b 45 d4 mov -0x2c(%ebp),%eax //ebp-0x2c存的值给eax
8049682: 83 f8 12 cmp $0x12,%eax //比较eax和0x12
8049685: 75 08 jne 804968f <phase_2+0x4a> //跳转就会爆炸,所以第一个数为0x12即18 二进制是10010
8049687: 8b 45 d8 mov -0x28(%ebp),%eax
804968a: 83 f8 25 cmp $0x25,%eax //eax和0x25即37比较
804968d: 74 0c je 804969b <phase_2+0x56> //相等进入循环 所以第一个数为37 二进制是100101
804968f: e8 5b 09 00 00 call 8049fef <explode_bomb>
8049694: b8 00 00 00 00 mov $0x0,%eax
8049699: eb 49 jmp 80496e4 <phase_2+0x9f>
//进入循环
804969b: c7 45 d0 02 00 00 00 movl $0x2,-0x30(%ebp) //ebp-0x30是一个计数器,初值为2 i=2
80496a2: eb 35 jmp 80496d9 <phase_2+0x94>
80496a4: 8b 45 d0 mov -0x30(%ebp),%eax
80496a7: 8b 44 85 d4 mov -0x2c(%ebp,%eax,4),%eax //eax = Array[i]
80496ab: 8b 55 d0 mov -0x30(%ebp),%edx //edx = 计数器
80496ae: 83 ea 02 sub $0x2,%edx //edx = edx - 2
80496b1: 8b 54 95 d4 mov -0x2c(%ebp,%edx,4),%edx //edx = Array[i-1]
80496b5: 89 d1 mov %edx,%ecx //ecx = edx = Array[i-1]
80496b7: d1 f9 sar %ecx //ecx右移
80496b9: 8b 55 d0 mov -0x30(%ebp), %edx //edx = 计数器
80496bc: 83 ea 01 sub $0x1,%edx //edx = edx - 1
80496bf: 8b 54 95 d4 mov -0x2c(%ebp,%edx,4),%edx //edx = Array[i-1]
80496c3: 01 ca add %ecx,%edx //edx = edx + ecx
80496c5: 39 d0 cmp %edx,%eax //比较eax与edx
80496c7: 74 0c je 80496d5 <phase_2+0x90>
80496c9: e8 21 09 00 00 call 8049fef <explode_bomb> //
80496ce: b8 00 00 00 00 mov $0x0,%eax
80496d3: eb 0f jmp 80496e4 <phase_2+0x9f>
80496d5: 83 45 d0 01 addl $0x1,-0x30(%ebp) //计数器 + 1
80496d9: 83 7d d0 07 cmpl $0x7,-0x30(%ebp) //ebp-0x30与0x7即7比较
80496dd: 7e c5 jle 80496a4 <phase_2+0x5f> //计数器只要<=7就往下走,退出循环
80496df: b8 01 00 00 00 mov $0x1,%eax
80496e4: 8b 4d f4 mov -0xc(%ebp),%ecx
80496e7: 65 33 0d 14 00 00 00 xor %gs:0x14,%ecx
80496ee: 74 05 je 80496f5 <phase_2+0xb0>
80496f0: e8 9b fa ff ff call 8049190 <__stack_chk_fail@plt>
80496f5: c9 leave
80496f6: c3 ret