Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project, you are asked to write MIPS code to sort a set of input floatin

ID: 3691853 • Letter: I

Question

In this project, you are asked to write MIPS code to sort a set of input floating-point numbers in an ascending order. You can implement any sorting algorithm you select (or invent) only if it produces correct results. You may refer to Project 4 for reading and printing floating-point numbers. However, for this project, you need to write all the code from the beginning to the end, including the .data and .text segments. In particular, you need to allocate data space to store the input sequence of floating-point numbers and sort them.

Same as in Project 4, input number 0.0 indicates the end of the input numbers and it is not counted as an input number.

A sample result:
--------------------------------------------
Input a Float-Point #:(0 indicates the end)
1.0
Input a Float-Point #:(0 indicates the end)
-1.0
Input a Float-Point #:(0 indicates the end)
2.0
Input a Float-Point #:(0 indicates the end)
-2.0
Input a Float-Point #:(0 indicates the end)
3.0
Input a Float-Point #:(0 indicates the end)
-3.0
Input a Float-Point #:(0 indicates the end)
0
Sorting Result
-3.0, -2.0, -1.0, 1.0, 2.0, 3.0

-- program is finished running --
---------------------------------------------

Explanation / Answer

.Ltext0: .section .rodata.str1.8,"aMS",@progbits,1 .align 8 .LC0: 0000 0A496E70 .string " Input a Float-Point#:(0 indicates the end): " 75742061 20466C6F 61742D50 6F696E74 .section .rodata.str1.1,"aMS",@progbits,1 .LC1: 0000 256C6600 .string "%lf" .LC3: 0004 0A536F72 .string " Sorting Result " 74696E67 20526573 756C7420 0A00 .LC4: 0016 252E316C .string "%.1lf " 662000 .section .text.unlikely,"ax",@progbits .LCOLDB5: .section .text.startup,"ax",@progbits .LHOTB5: .p2align 4,,15 .section .text.unlikely .Ltext_cold0: .section .text.startup .globl main main: .LFB13: .cfi_startproc 0000 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0001 53 pushq %rbx .cfi_def_cfa_offset 24 .cfi_offset 3, -24 0004 4881ECC8 subq $200, %rsp 000000 .cfi_def_cfa_offset 224 000b 64488B04 movq %fs:40, %rax 25280000 00 0014 48898424 movq %rax, 184(%rsp) B8000000 001c 31C0 xorl %eax, %eax 0002 31ED xorl %ebp, %ebp .LVL0: 001e 488D5C24 leaq 16(%rsp), %rbx 10 0023 EB06 jmp .L4 .LVL1: .p2align 4,,10 0025 0F1F00 .p2align 3 .L17: 0028 83C501 addl $1, %ebp .LVL2: .L4: .LBB8: .LBB9: 002b BE000000 movl $.LC0, %esi 00 0030 BF010000 movl $1, %edi 00 0035 31C0 xorl %eax, %eax 0037 E8000000 call __printf_chk 00 .LVL3: .LBE9: .LBE8: 003c 4889DE movq %rbx, %rsi 003f 31C0 xorl %eax, %eax 0041 BF000000 movl $.LC1, %edi 00 0046 E8000000 call __isoc99_scanf 00 .LVL4: 004b 660FEFD2 pxor %xmm2, %xmm2 004f 4883C308 addq $8, %rbx 0053 660F2E53 ucomisd -8(%rbx), %xmm2 F8 0058 7ACE jp .L17 005a 75CC jne .L17 005c 8D5DFF leal -1(%rbp), %ebx .LVL5: 005f 85DB testl %ebx, %ebx 0061 0F8ED200 jle .L5 0000 0067 31F6 xorl %esi, %esi 0069 BF010000 movl $1, %edi 00 .LVL6: 006e 6690 .p2align 4,,10 .p2align 3 .L10: 0070 F20F104C movsd 24(%rsp,%rsi,8), %xmm1 F418 .LVL7: 0076 4863C6 movslq %esi, %rax .LVL8: 0079 F20F1044 movsd 16(%rsp,%rsi,8), %xmm0 F410 007f 660F2EC1 ucomisd %xmm1, %xmm0 0083 7717 ja .L21 0085 E9AA0000 jmp .L26 00 .LVL9: 008a 660F1F44 .p2align 4,,10 0000 .p2align 3 .L34: 0090 4863C2 movslq %edx, %rax 0093 83F8FF cmpl $-1, %eax 0096 0F849400 je .L33 0000 .LVL10: .L21: 009c 8D5001 leal 1(%rax), %edx 009f 4863D2 movslq %edx, %rdx 00a2 F20F1144 movsd %xmm0, 16(%rsp,%rdx,8) D410 00a8 8D50FF leal -1(%rax), %edx .LVL11: 00ab 4863CA movslq %edx, %rcx 00ae F20F1044 movsd 16(%rsp,%rcx,8), %xmm0 CC10 00b4 660F2EC1 ucomisd %xmm1, %xmm0 00b8 77D6 ja .L34 .LVL12: .L6: 00ba 83C701 addl $1, %edi .LVL13: 00bd 4883C601 addq $1, %rsi 00c7 39FD cmpl %edi, %ebp 00c9 75A5 jne .L10 00c1 F20F114C movsd %xmm1, 16(%rsp,%rax,8) C410 .LVL14: .LBB10: .LBB11: 00cb BE000000 movl $.LC3, %esi 00 00d0 BF010000 movl $1, %edi 00 .LVL15: 00d5 31C0 xorl %eax, %eax 00d7 E8000000 call __printf_chk 00 .LVL16: .L12: .LBE11: .LBE10: 00dc 31ED xorl %ebp, %ebp .LVL17: 00de 6690 .p2align 4,,10 .p2align 3 .L13: .LBB13: .LBB14: 00e0 F20F105C movsd 16(%rsp,%rbp,8), %xmm3 EC10 00e6 BE000000 movl $.LC4, %esi 00 00eb BF010000 movl $1, %edi 00 00f0 B8010000 movl $1, %eax 00 00f5 4883C501 addq $1, %rbp .LVL18: 00f9 660F28C3 movapd %xmm3, %xmm0 00fd F20F115C movsd %xmm3, 8(%rsp) 2408 0103 E8000000 call __printf_chk 00 .LVL19: .LBE14: .LBE13: 0108 39EB cmpl %ebp, %ebx 010a 7DD4 jge .L13 .L14: 010c 31C0 xorl %eax, %eax 010e 488B9C24 movq 184(%rsp), %rbx B8000000 0116 6448331C xorq %fs:40, %rbx 25280000 00 .LVL20: 011f 752F jne .L35 0121 4881C4C8 addq $200, %rsp 000000 .cfi_remember_state .cfi_def_cfa_offset 24 0128 5B popq %rbx .cfi_def_cfa_offset 16 0129 5D popq %rbp .cfi_def_cfa_offset 8 012a C3 ret .LVL21: 012b 0F1F4400 .p2align 4,,10 00 .p2align 3 .L33: .cfi_restore_state 0130 31C0 xorl %eax, %eax 0132 EB86 jmp .L6 .LVL22: .L26: 0134 4863C7 movslq %edi, %rax 0137 EB81 jmp .L6 .LVL23: .L5: .LBB15: .LBB12: 0139 31C0 xorl %eax, %eax 013b BE000000 movl $.LC3, %esi 00 0140 BF010000 movl $1, %edi 00 0145 E8000000 call __printf_chk 00 .LVL24: .LBE12: .LBE15: 014a 85DB testl %ebx, %ebx 014c 75BE jne .L14 014e EB8C jmp .L12 .LVL25: .L35: 0150 E8000000 call __stack_chk_fail 00 .LVL26: .cfi_endproc .LFE13: .section .text.unlikely .LCOLDE5: .section .text.startup .LHOTE5: .text .Letext0: .section .text.unlikely .Letext_cold0:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote