The following tasks, in onder Allocate a global array (Le., space in the data se
ID: 3861110 • Letter: T
Question
The following tasks, in onder Allocate a global array (Le., space in the data segment) enough for storing 4 inegers and initialize the array (from Ist to 4th element) with 8, 1,3 and 2 ot the somse time(ie DONT write sode to put in these values instead). Display a labeled output about the array's initial contents (from Ist to 4th clement) IMPORTANT You are to load the values of the array elements froem memory and use those values to generate dhe labeled output (You are not to simply display a hard-coded, preset string.) Re-order the values in the array so that the contents of the arraymemory (from 1 t to 4th elemen becomes 2 3 , and g using the following operations (in order Swap the coetents in memory of the Ist and 4th elements of the aray Swap the contents in memory of the 2nd and 3ed elements of the array IMPORTANT each of the two swap operations above, you can re-ase (where expedient) the aray's base address in registcr (loaded whom performing the display of the array's initial contents) but you MUST re-load rom mrmory (ie , assuming no km alea ge that certain values might have alreaby exited in some fegistersdee to proe operat ons). she associated arra y elements esh he va we5 Display a labeled output about the arrays contents (from 4t toit element) afer be 2 swapping operatin. abot NOTE: It is from 4th to 1st element and not from 1st to 4th element IMPORTANT Similar to when performing the two swap operations above, you can re-use (where expedient) the array's base address in register (oaded when perfoerming the prior operations) but you MUSI re-lovad the vaes of the array elements fresh from Mmory (.e, assuming no knowledge that certain values might have already existod in some registers due to prior operationsExplanation / Answer
.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .rdata .align 2 $LC0: .ascii "Initial Values of the array " .align 2 $LC1: .ascii "%d " .align 2 $LC2: .ascii "The values of the array after swapping " .text .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $fp,56,$31 # vars= 24, regs= 2/0, args= 16, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-56 sw $31,52($sp) sw $fp,48($sp) move $fp,$sp .cprestore 16 movz $31,$31,$0 li $2,8 # 0x8 sw $2,32($fp) li $2,1 # 0x1 sw $2,36($fp) li $2,2 # 0x2 sw $2,40($fp) li $2,3 # 0x3 sw $2,44($fp) lw $2,%got($LC0)($28) nop addiu $4,$2,%lo($LC0) lw $2,%call16(puts)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 nop lw $28,16($fp) sw $0,24($fp) b $L2 nop $L3: lw $2,24($fp) nop sll $2,$2,2 addiu $3,$fp,24 addu $2,$3,$2 lw $2,8($2) nop move $5,$2 lw $2,%got($LC1)($28) nop addiu $4,$2,%lo($LC1) lw $2,%call16(printf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,printf 1: jalr $25 nop lw $28,16($fp) lw $2,24($fp) nop addiu $2,$2,1 sw $2,24($fp) $L2: lw $2,24($fp) nop slt $2,$2,4 bne $2,$0,$L3 nop li $4,10 # 0xa lw $2,%call16(putchar)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,putchar 1: jalr $25 nop lw $28,16($fp) lw $2,32($fp) nop sw $2,28($fp) lw $2,44($fp) nop sw $2,32($fp) lw $2,28($fp) nop sw $2,44($fp) lw $2,36($fp) nop sw $2,28($fp) lw $2,40($fp) nop sw $2,36($fp) lw $2,28($fp) nop sw $2,40($fp) lw $2,%got($LC2)($28) nop addiu $4,$2,%lo($LC2) lw $2,%call16(puts)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 nop lw $28,16($fp) sw $0,24($fp) b $L4 nop $L5: lw $2,24($fp) nop sll $2,$2,2 addiu $3,$fp,24 addu $2,$3,$2 lw $2,8($2) nop move $5,$2 lw $2,%got($LC1)($28) nop addiu $4,$2,%lo($LC1) lw $2,%call16(printf)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,printf 1: jalr $25 nop lw $28,16($fp) lw $2,24($fp) nop addiu $2,$2,1 sw $2,24($fp) $L4: lw $2,24($fp) nop slt $2,$2,4 bne $2,$0,$L5 nop move $2,$0 move $sp,$fp lw $31,52($sp) lw $fp,48($sp) addiu $sp,$sp,56 j $31 nop .set macro .set reorder .end main .size main, .-main .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.