Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify below C program to get below x86 gcc assembly output C program: - char password[8] = secret; int main() { char input[8]; printf(please enter

Modify below C program to get below x86 gcc assembly output

C program: -

char password[8] = "secret";

int main() {

char input[8];

printf("please enter your password ");

scanf("%s", input);

if(strcmp(input, password)==0) {

return 0;

} else {

return -1;

}

}

X86 gcc 1.27 Assembly: -

password:

.byte 0x73,0x65,0x63,0x72,0x65,0x74,0x0

.LC0:

.byte 0x70,0x6c,0x65,0x61,0x73,0x65,0x20,0x65,0x6e,0x74

.byte 0x65,0x72,0x20,0x79,0x6f,0x75,0x72,0x20,0x70,0x61

.byte 0x73,0x73,0x77,0x6f,0x72,0x64,0xa,0x0

.LC1:

.byte 0x25,0x73,0x0

main:

pushl %ebp

movl %esp,%ebp

subl $12,%esp

pushl %ebx

pushl $.LC0

call printf

leal -8(%ebp),%eax

pushl %eax

pushl $.LC1

call scanf

movl $0,-12(%ebp)

leal 12(%esp),%esp

.L2:

cmpl $7,-12(%ebp)

jg .L3

movl %ebp,%eax

addl -12(%ebp),%eax

leal -8(%eax),%eax

cmpb $64,(%eax)

jle .L5

movl %ebp,%eax

addl -12(%ebp),%eax

leal -8(%eax),%eax

cmpb $90,(%eax)

jg .L5

movl %ebp,%eax

addl -12(%ebp),%eax

leal -8(%eax),%eax

movl %ebp,%edx

addl -12(%ebp),%edx

leal -8(%edx),%edx

movb (%edx),%cl

addb $32,%cl

movb %cl,(%eax)

.L5:

incl -12(%ebp)

jmp .L2

.L3:

pushl $password

leal -8(%ebp),%eax

pushl %eax

call strcmp

movl %eax,%ebx

leal 8(%esp),%esp

cmpl $0,%ebx

jne .L6

xorl %eax,%eax

jmp .L1

jmp .L7

.L6:

movl $-1,%eax

jmp .L1

.L7:

.L1:

leal -16(%ebp),%esp

popl %ebx

leave

ret

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

5. How can we prevent suicide?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

What is meant by planning or define planning?

Answered: 1 week ago