Question: Hey there! I have an assembly program called mergesort.s and I just need help writing a c program that read's a possible 100 random integers

 Hey there! I have an assembly program called mergesort.s and I

Hey there! I have an assembly program called mergesort.s and I just need help writing a c program that read's a possible 100 random integers and then calls the assembly program!

Here is the assembly program if it helps

merge(int*, int, int, int, int):

pushq %rbp

movq %rsp, %rbp

addq $-128, %rsp

movq %rdi, -232(%rbp)

movl %esi, -236(%rbp)

movl %edx, -240(%rbp)

movl %ecx, -244(%rbp)

movl %r8d, -248(%rbp)

movl -236(%rbp), %eax

movl %eax, -4(%rbp)

movl -244(%rbp), %eax

movl %eax, -8(%rbp)

movl -236(%rbp), %eax

movl %eax, -12(%rbp)

.L5:

movl -4(%rbp), %eax

cmpl -240(%rbp), %eax

jg .L7

movl -8(%rbp), %eax

cmpl -248(%rbp), %eax

jg .L7

movl -4(%rbp), %eax

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

addq %rdx, %rax

movl (%rax), %edx

movl -8(%rbp), %eax

cltq

leaq 0(,%rax,4), %rcx

movq -232(%rbp), %rax

addq %rcx, %rax

movl (%rax), %eax

cmpl %eax, %edx

jge .L3

movl -4(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -4(%rbp)

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

leaq (%rdx,%rax), %rcx

movl -12(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -12(%rbp)

movl (%rcx), %edx

cltq

movl %edx, -224(%rbp,%rax,4)

jmp .L5

.L3:

movl -8(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -8(%rbp)

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

leaq (%rdx,%rax), %rcx

movl -12(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -12(%rbp)

movl (%rcx), %edx

cltq

movl %edx, -224(%rbp,%rax,4)

jmp .L5

.L7:

movl -4(%rbp), %eax

cmpl -240(%rbp), %eax

jg .L6

movl -4(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -4(%rbp)

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

leaq (%rdx,%rax), %rcx

movl -12(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -12(%rbp)

movl (%rcx), %edx

cltq

movl %edx, -224(%rbp,%rax,4)

jmp .L7

.L6:

movl -8(%rbp), %eax

cmpl -248(%rbp), %eax

jg .L8

movl -8(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -8(%rbp)

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

leaq (%rdx,%rax), %rcx

movl -12(%rbp), %eax

leal 1(%rax), %edx

movl %edx, -12(%rbp)

movl (%rcx), %edx

cltq

movl %edx, -224(%rbp,%rax,4)

jmp .L6

.L8:

movl -236(%rbp), %eax

movl %eax, -4(%rbp)

.L10:

movl -4(%rbp), %eax

cmpl -248(%rbp), %eax

jg .L11

movl -4(%rbp), %eax

cltq

leaq 0(,%rax,4), %rdx

movq -232(%rbp), %rax

addq %rax, %rdx

movl -4(%rbp), %eax

cltq

movl -224(%rbp,%rax,4), %eax

movl %eax, (%rdx)

addl $1, -4(%rbp)

jmp .L10

.L11:

nop

leave

ret

integers. The C code will be responsible for I/O and calling an assembler function to perform the sort. A file contains no more than 100 random integers between 1 and 250. You must process all integers in the file, i.e. process until EOF

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!