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

The Eqn is = 3x ^4 – 10x^ 2 - 15x Program Description: Write an assembly languag

ID: 3673132 • Letter: T

Question

The Eqn is = 3x^4 – 10x^2 - 15x

Program Description: Write an assembly language program to find the maximum of y=3x4-10x-15x for the range -4 sxS 6, by stepping one by one through the range During each iteration, print out a message stating the current value of x and the corresponding value of y. After all iterations, print out a final message stating the max value of y and the corresponding value of x that generated yma generate max, you only need to indicate one of them. Also, make sure to define the values of the coefficients 3, 10 and 15 as constants a1, a2, and a3. If there are multiple values of x that Try to eliminate as many nop instructions as possible and also try to minimize the length of your code. You may run the program using gdb to verify correctness. Make sure to pay close attention to the requirements above Output Format: For input of x =-4, output y = 668 For input of x--3, output y = 198 For input of.x-6, output y -3438 The maximum output value is y -3438. when input x-(6 m output value is y-3438. when input x 6 Requirements: 1. 2. Follow the requirements as described above. Make sure to comment your code Name your source file 'lastname2.m' and store it in your class account. [It is a .m file rather than a.., file since you will have macro definitions.] nano compute.m will create the buffer for you to enter your code To expand the macros and to create the .s assembly code file, run: 3. m4 compute·m> computes 4. To compile your code and create the executable, run: gcc-o compute compute.s

Explanation / Answer

Answer:

Assembly Language Code:

Ltext0:
        .local   _ZStL8__ioinit
        .comm   _ZStL8__ioinit,1,1
        .section   .rodata
    .LC0:
0000 456E7465        .string   "Enter x value: "
    .LC1:
0010 466F7220        .string   "For input of x="

    .LC2:
0020 2C00        .string   ","
    .LC3:
0022 6F757470        .string   "output y="

002c 00000000        .align 8
    .LC4:
0030 456E7465        .string   "Entered x value is out of bounds.Please Check"

        .text
        .globl   main
    main:
    .LFB971:
        .cfi_startproc
0000 55        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
0001 4889E5        movq   %rsp, %rbp
        .cfi_def_cfa_register 6
0004 53        pushq   %rbx
0005 4883EC18        subq   $24, %rsp
        .cfi_offset 3, -24
    .LBB2:
0009 BE000000        movl   $.LC0, %esi
  
000e BF000000        movl   $_ZSt4cout, %edi

0013 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

0018 488D45E8        leaq   -24(%rbp), %rax
001c 4889C6        movq   %rax, %rsi
001f BF000000        movl   $_ZSt3cin, %edi

0024 E8000000        call   _ZNSirsERi

0029 8B45E8        movl   -24(%rbp), %eax
002c 83F8FC        cmpl   $-4, %eax
002f 0F8CC200        jl   .L
0035 8B45E8        movl   -24(%rbp), %eax
0038 83F806        cmpl   $6, %eax
003b 0F8FB600        jg   .L2

0041 C745E8FC        movl   $-4, -24(%rbp)
  
0048 E99C0000        jmp   .L3
  
    .L4:
00e0 8B45E8        movl   -24(%rbp), %eax
00e3 83C001        addl   $1, %eax
00e6 8945E8        movl   %eax, -24(%rbp)
004d 8B55E8        movl   -24(%rbp), %edx
0050 8B45E8        movl   -24(%rbp), %eax
0053 0FAFD0        imull   %eax, %edx
0056 8B45E8        movl   -24(%rbp), %eax
0059 0FAFD0        imull   %eax, %edx
005c 8B45E8        movl   -24(%rbp), %eax
005f 0FAFD0        imull   %eax, %edx
0062 89D0        movl   %edx, %eax
0064 01C0        addl   %eax, %eax
0066 8D0C10        leal   (%rax,%rdx), %ecx
0069 8B55E8        movl   -24(%rbp), %edx
006c 8B45E8        movl   -24(%rbp), %eax
006f 0FAFD0        imull   %eax, %edx
0072 89D0        movl   %edx, %eax
0074 C1E002        sall   $2, %eax
0077 01D0        addl   %edx, %eax
0079 01C0        addl   %eax, %eax
007b F7D8        negl   %eax
007d 01C1        addl   %eax, %ecx
007f 8B55E8        movl   -24(%rbp), %edx
0082 89D0        movl   %edx, %eax
0084 C1E004        sall   $4, %eax
0087 29D0        subl   %edx, %eax
0089 F7D8        negl   %eax
008b 01C8        addl   %ecx, %eax
008d 8945EC        movl   %eax, -20(%rbp)
0090 8B5DE8        movl   -24(%rbp), %ebx
0093 BE000000        movl   $.LC1, %esi

0098 BF000000        movl   $_ZSt4cout, %edi
  
009d E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
  
00a2 89DE        movl   %ebx, %esi
00a4 4889C7        movq   %rax, %rdi
00a7 E8000000        call   _ZNSolsEi

00ac BE000000        movl   $.LC2, %esi

00b1 4889C7        movq   %rax, %rdi
00b4 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

00b9 BE000000        movl   $.LC3, %esi

00be 4889C7        movq   %rax, %rdi
00c1 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

00c6 8B55EC        movl   -20(%rbp), %edx
00c9 89D6        movl   %edx, %esi
00cb 4889C7        movq   %rax, %rdi
00ce E8000000        call   _ZNSolsEi
  
00d3 BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
  
00d8 4889C7        movq   %rax, %rdi
00db E8000000        call   _ZNSolsEPFRSoS_E
  
    .L3:
00f5 EB1C        jmp   .L5
00e9 8B45E8        movl   -24(%rbp), %eax
00ec 83F806        cmpl   $6, %eax
00ef 0F8E58FF        jle   .L4
  
    .L2:
00f7 BE000000        movl   $.LC4, %esi
  
00fc BF000000        movl   $_ZSt4cout, %edi
  
0101 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
  
0106 BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
  
010b 4889C7        movq   %rax, %rdi
010e E8000000        call   _ZNSolsEPFRSoS_E
  
    .L5:
0113 B8000000        movl   $0, %eax

    .LBE2:
0118 4883C418        addq   $24, %rsp
011c 5B        popq   %rbx
011d 5D        popq   %rbp
        .cfi_def_cfa 7, 8
011e C3        ret
        .cfi_endproc
    .LFE971:
    _Z41__static_initialization_and_destruction_0ii:
    .LFB980:
013c BF000000        movl   $_ZStL8__ioinit, %edi

0141 E8000000        call   _ZNSt8ios_base4InitC1Ev

0146 BA000000        movl   $__dso_handle, %edx
  
014b BE000000        movl   $_ZStL8__ioinit, %esi
  
0150 BF000000        movl   $_ZNSt8ios_base4InitD1Ev, %edi

0155 E8000000        call   __cxa_atexit

        .cfi_startproc
011f 55        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
0120 4889E5        movq   %rsp, %rbp
        .cfi_def_cfa_register 6
0123 4883EC10        subq   $16, %rsp
0127 897DFC        movl   %edi, -4(%rbp)
012a 8975F8        movl   %esi, -8(%rbp)
012d 837DFC01        cmpl   $1, -4(%rbp)
0131 7527        jne   .L7
0133 817DF8FF        cmpl   $65535, -8(%rbp)

013a 751E        jne   .L7
    .L7:
015a C9        leave
        .cfi_def_cfa 7, 8
015b C3        ret
        .cfi_endproc
    .LFE980:
    _GLOBAL__sub_I_main:
    .LFB981:
        .cfi_startproc
015c 55        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
015d 4889E5        movq   %rsp, %rbp
        .cfi_def_cfa_register 6
0160 BEFFFF00        movl   $65535, %esi
  
0165 BF010000        movl   $1, %edi

016a E8B0FFFF        call   _Z41__static_initialization_and_destruction_0ii
  
016f 5D        popq   %rbp
        .cfi_def_cfa 7, 8
0170 C3        ret
        .cfi_endproc
    .LFE981:
        .section   .init_array,"aw"
        .align 8
0000 00000000        .quad   _GLOBAL__sub_I_main
  
        .text
    .Letext0:

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