# Question & Answer: please write the following Y86 assembley instructions for the following C code. Please write in text so I can copy and paste……

please write the following Y86 assembley instructions for the following C code. Please write in text so I can copy and paste.

``` * C Program to Solve the Magic Squares Puzzle without using
```
``` * Recursion
```
``` */
```
```#include <stdio.h>
```
```
```
```void magicsq(int, int [][10]);
```
```
```
```int main( )
```
```{
```
```    int size;
```
```    int a[10][10];
```
```
```
```    printf("Enter the size: ");
```
```    scanf("%d", &size);
```
```    if (size % 2 == 0)
```
```    {
```
```        printf("Magic square works for an odd numbered sizen");
```
```    }
```
```    else
```
```    {
```
```        magicsq(size, a);
```
```    }
```
```    return 0;
```
```}
```
```
```
```void magicsq(int size, int a[][10])
```
```{
```
```    int sqr = size * size;
```
```    int i = 0, j = size / 2, k;
```
```
```
```    for (k = 1; k <= sqr; ++k)
```
```    {
```
```        a[i][j] = k;
```
```        i--;
```
```        j++;
```
```
```
```        if (k % size == 0)
```
```        {
```
```            i += 2;
```
```            --j;
```
```        }
```
```        else
```
```        {
```
```            if (j == size)
```
```            {
```
```                j -= size;
```
```            }
```
```            else if (i < 0)
```
```            {
```
```                i += size;
```
```            }
```
```        }
```
```    }
```
```    for (i = 0; i < size; i++)
```
```    {
```
```        for (j = 0; j < size; j++)
```
```        {
```
```            printf("%d  ", a[i][j]);
```
```        }
```
```        printf("n");
```
```    }
```
```    printf("n");
```
```}
```

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: please write the following Y86 assembley instructions for the following C code. Please write in text so I can copy and paste……
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

The assembly instruction from the above given c code is given below:

```        .file   1 ""
.section .mdebug.abi32
.previous
.nan    legacy
.module fp=32
.module nooddspreg
.abicalls
.section        .rodata.str1.4,"aMS",@progbits,1
.align  2
\$LC0:
.ascii  "%d  00"
.text
.align  2
.globl  magicsq
.set    nomips16
.set    nomicromips
.ent    magicsq
.type   magicsq, @function
magicsq:
.frame  \$sp,56,\$31              # vars= 0, regs= 7/0, args= 16, gp= 8
.set    noreorder
.set    nomacro
mult    \$4,\$4
srl     \$3,\$4,31
sra     \$3,\$3,1
movz    \$31,\$31,\$0
sw      \$16,28(\$sp)
.cprestore      16
sw      \$31,52(\$sp)
sw      \$21,48(\$sp)
sw      \$20,44(\$sp)
sw      \$19,40(\$sp)
sw      \$18,36(\$sp)
sw      \$17,32(\$sp)
move    \$16,\$4
mflo    \$7
li      \$6,1                    # 0x1
move    \$2,\$0
\$L2:
slt     \$4,\$7,\$6
bne     \$4,\$0,\$L13
sll     \$8,\$2,5

bne     \$16,\$0,1f
div     \$0,\$6,\$16
break   7
1:
sll     \$4,\$2,3
sll     \$8,\$3,2
sw      \$6,0(\$4)
mfhi    \$4
bne     \$4,\$0,\$L3
nop

b       \$L4

\$L3:
beq     \$16,\$3,\$L9

bgez    \$2,\$L4
nop

b       \$L4

\$L9:
move    \$3,\$0
\$L4:
b       \$L2

\$L13:
lw      \$19,%got(\$LC0)(\$28)
move    \$17,\$5
move    \$18,\$0
\$L6:
slt     \$2,\$18,\$16
beq     \$2,\$0,\$L14
move    \$21,\$17

move    \$20,\$0
\$L8:
slt     \$2,\$20,\$16
beq     \$2,\$0,\$L15
move    \$5,\$19

lw      \$25,%call16(__printf_chk)(\$28)
lw      \$6,0(\$21)
.reloc  1f,R_MIPS_JALR,__printf_chk
1:      jalr    \$25
li      \$4,1                    # 0x1

lw      \$28,16(\$sp)
b       \$L8

\$L15:
lw      \$25,%call16(putchar)(\$28)
nop
.reloc  1f,R_MIPS_JALR,putchar
1:      jalr    \$25
li      \$4,10                   # 0xa

lw      \$28,16(\$sp)
b       \$L6

\$L14:
lw      \$31,52(\$sp)
lw      \$21,48(\$sp)
lw      \$20,44(\$sp)
lw      \$19,40(\$sp)
lw      \$18,36(\$sp)
lw      \$17,32(\$sp)
lw      \$16,28(\$sp)
lw      \$25,%call16(putchar)(\$28)
li      \$4,10                   # 0xa
.reloc  1f,R_MIPS_JALR,putchar
1:      jr      \$25

.set    macro
.set    reorder
.end    magicsq
.size   magicsq, .-magicsq
.section        .rodata.str1.4
.align  2
\$LC1:
.ascii  "Enter the size: 00"
.align  2
\$LC2:
.ascii  "%d00"
.align  2
\$LC3:
.ascii  "Magic square works for an odd numbered size00"
.section        .text.startup,"ax",@progbits
.align  2
.globl  main
.set    nomips16
.set    nomicromips
.ent    main
.type   main, @function
main:
.frame  \$sp,440,\$31             # vars= 408, regs= 1/0, args= 16, gp= 8
.set    noreorder
.set    nomacro
lw      \$5,%got(\$LC1)(\$28)
lw      \$25,%call16(__printf_chk)(\$28)
.cprestore      16
movz    \$31,\$31,\$0
sw      \$31,436(\$sp)
.reloc  1f,R_MIPS_JALR,__printf_chk
1:      jalr    \$25
li      \$4,1                    # 0x1

lw      \$28,16(\$sp)
lw      \$4,%got(\$LC2)(\$28)
lw      \$25,%call16(__isoc99_scanf)(\$28)
nop
.reloc  1f,R_MIPS_JALR,__isoc99_scanf
1:      jalr    \$25

lw      \$4,424(\$sp)
lw      \$28,16(\$sp)
andi    \$2,\$4,0x1
bne     \$2,\$0,\$L17
nop

lw      \$4,%got(\$LC3)(\$28)
lw      \$25,%call16(puts)(\$28)
nop
.reloc  1f,R_MIPS_JALR,puts
1:      jalr    \$25

b       \$L20
nop

\$L17:
lw      \$25,%got(magicsq)(\$28)
nop
.reloc  1f,R_MIPS_JALR,magicsq
1:      jalr    \$25