正在加载图片...
pushl ebp mov112(8ebp),暑ecx movl $l, movl 8(gebp), edx cmpl ecx, edx imu11edx,暑eax addl $2, edx cmpl &ecx, edx popl ebp Based on the assembly code, fill in the blanks below in its corresponding C source code. (Note: you may only use symbolic variablesx, y, i, and result, from the source code in your expre ssions belo -do not use register names.) int dog(int x, int y) int i, result esu⊥t= for (i result return resulti Problem 6:(2*4=8pts) This problem tests your understanding of how while loops in C relate to IA32 machine code Consider the following IA32 assembly code for a procedure cat( pushl ebp ovl esp, ebp ovl 8(sebp), ecx pushl ebx xorl ebx, ebx movl 12(ebp), eax decl secx cmp1-1,暑ecx je. L6 mov1暑ecx,8edx imu11eax,各ed 1 p2align 4,, 15 decl secx ddl sedx, sex add18eax,暑edx Page 4 of 7-Page 4 of 7 dog: pushl %ebp movl %esp, %ebp movl 12(%ebp), %ecx movl $1, %eax movl 8(%ebp), %edx cmpl %ecx, %edx jge .L7 .L5: imull %edx, %eax addl $2, %edx cmpl %ecx, %edx jl .L5 .L7: popl %ebp ret Based on the assembly code, fill in the blanks below in its corresponding C source code. (Note: you may only use symbolic variables x, y, i, and result, from the source code in your expressions below — do not use register names.) int dog(int x, int y) { int i, result; result = ________; for (i = ________; _____________; ________) result = _________________; return result; } Problem 6: (2*4 = 8pts) This problem tests your understanding of how while loops in C relate to IA32 machine code. Consider the following IA32 assembly code for a procedure cat(): cat: pushl %ebp movl %esp, %ebp movl 8(%ebp), %ecx pushl %ebx xorl %ebx, %ebx movl 12(%ebp), %eax decl %ecx cmpl $-1, %ecx je .L6 movl %ecx, %edx imull %eax, %edx negl %eax .p2align 4,,15 .L4: decl %ecx addl %edx, %ebx addl %eax, %edx cmpl $-1, %ecx
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有