Question: Consider the following assembly code: .section .rodata.str1.1,aMS,@progbits,1 .section .rodata .LC0: .string result %lx .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp

Consider the following assembly code:

 .section .rodata.str1.1,"aMS",@progbits,1 .section .rodata .LC0: .string "result %lx " .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movl $3735928559, %eax movq %rax, -8(%rbp) movq $0, -24(%rbp) movq $1, -16(%rbp) jmp .L2 .L3: movq -16(%rbp), %rax movq -8(%rbp), %rdx andq %rdx, %rax orq %rax, -24(%rbp) salq $2, -16(%rbp) .L2: cmpq $0, -16(%rbp) jne .L3 movq -24(%rbp), %rax movq %rax, %rsi movl $.LC0, %edi movl $0, %eax call printf leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3" .section .note.GNU-stack,"",@progbits 

This code came from the following skeleton C file, and optimized with O2, so gcc -O2 was the exact command to compile the file.

Step 1 might be to ignore the skeleton file and create a C file from the assembly code, and then rewrite the code to fit the skeleton file.

#include  int main() { long x = 0x________; long result = ______; long mask; for (mask = _________; mask _______; mask = ________) { result |= ________; } printf("result %lx ",result); } 

answer the following questions:

1. Which registers hold x, result, and mask?

2. Describe in your own words what the program is doing.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!