You are tasked to calculate a specific algebraic expansion. i.e. compute the val
ID: 663283 • Letter: Y
Question
You are tasked to calculate a specific algebraic expansion. i.e. compute the value of f and g for the expression: f = (A^4-4B^3+3C^2-2D) g = (AB^2+C^2D^3) without using any intrinsic multiplication instructions. More formally. write MIPS assembly code that accepts four positive integers a. b. c. and d as input parameters. The code shall execute in MARS to prompt the user to enter four positive integers represented in decimal. each separated by the Enter key. The program shall calculate f= (A^4-4B^3+3C^2-2D) and g= (AB^2+C^2D^3) using your own self-written multiplication routine. The program will then output f in decimal and binary, using syscall routines for each output. Note: To receive credit. no multiplication, no division, and no shift instructions shall be used. Namely. noneof{mul, mul.d, mul.s, mulo, mulou, mult, multu, mulu, div, divu, rem, sll, sllv, sra, srav, srl, srlv} or else a zero score will result. Thus. it is necessary to compose your own multiplication technique. In addition. use of a loop is required for credit to realize the multiplication code.Explanation / Answer
.Ltext0:
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.section .rodata
.align 8
.LC0:
.string "Enter 4 positive integers separated by the enter key:"
.text
.globl main
main:
.LFB971:
.cfi_startproc
.cfi_personality 0x3,__gxx_personality_v0
.cfi_lsda 0x3,.LLSDA971
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $32, %rsp
.LBB2:
movl $.LC0, %esi
movl $_ZSt4cout, %edi
.LEHB0:
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
leaq -24(%rbp), %rax
001b 4889C6 movq %rax, %rsi
001e BF000000 movl $_ZSt3cin, %edi
00
0023 E8000000 call _ZNSirsERi
00
0028 488D45EC leaq -20(%rbp), %rax
002c 4889C6 movq %rax, %rsi
002f BF000000 movl $_ZSt3cin, %edi
00
0034 E8000000 call _ZNSirsERi
00
0039 488D45F0 leaq -16(%rbp), %rax
003d 4889C6 movq %rax, %rsi
0040 BF000000 movl $_ZSt3cin, %edi
00
0045 E8000000 call _ZNSirsERi
00
004a 488D45F4 leaq -12(%rbp), %rax
004e 4889C6 movq %rax, %rsi
0051 BF000000 movl $_ZSt3cin, %edi
00
0056 E8000000 call _ZNSirsERi
00
005b 8B55E8 movl -24(%rbp), %edx
005e 8B45E8 movl -24(%rbp), %eax
0061 0FAFD0 imull %eax, %edx
0064 8B45E8 movl -24(%rbp), %eax
0067 0FAFD0 imull %eax, %edx
006a 8B45E8 movl -24(%rbp), %eax
006d 0FAFD0 imull %eax, %edx
0070 8B4DEC movl -20(%rbp), %ecx
0073 8B45EC movl -20(%rbp), %eax
0076 0FAFC8 imull %eax, %ecx
0079 8B45EC movl -20(%rbp), %eax
007c 0FAFC8 imull %eax, %ecx
007f B8000000 movl $0, %eax
00
0084 29C8 subl %ecx, %eax
0086 C1E002 sall $2, %eax
0089 8D0C02 leal (%rdx,%rax), %ecx
008c 8B55F0 movl -16(%rbp), %edx
008f 8B45F0 movl -16(%rbp), %eax
0092 0FAFD0 imull %eax, %edx
0095 89D0 movl %edx, %eax
0097 01C0 addl %eax, %eax
0099 01D0 addl %edx, %eax
009b 01C1 addl %eax, %ecx
009d 8B55F4 movl -12(%rbp), %edx
00a0 B8000000 movl $0, %eax
00
00a5 29D0 subl %edx, %eax
00a7 01C0 addl %eax, %eax
00a9 01C8 addl %ecx, %eax
00ab 8945F8 movl %eax, -8(%rbp)
00ae 8B55E8 movl -24(%rbp), %edx
00b1 8B45EC movl -20(%rbp), %eax
00b4 0FAFD0 imull %eax, %edx
00b7 8B45EC movl -20(%rbp), %eax
00ba 0FAFD0 imull %eax, %edx
00bd 8B4DF0 movl -16(%rbp), %ecx
00c0 8B45F0 movl -16(%rbp), %eax
00c3 0FAFC8 imull %eax, %ecx
00c6 8B75F4 movl -12(%rbp), %esi
00c9 8B45F4 movl -12(%rbp), %eax
00cc 0FAFF0 imull %eax, %esi
00cf 8B45F4 movl -12(%rbp), %eax
00d2 0FAFC6 imull %esi, %eax
00d5 0FAFC1 imull %ecx, %eax
00d8 01D0 addl %edx, %eax
00da 8945FC movl %eax, -4(%rbp)
00dd 8B45F8 movl -8(%rbp), %eax
00e0 89C6 movl %eax, %esi
00e2 BF000000 movl $_ZSt4cout, %edi
00
00e7 E8000000 call _ZNSolsEi
00
.LEHE0:
.LBE2:
00ec B8000000 movl $0, %eax
00
00f1 EB08 jmp .L5
.L4:
00f3 4889C7 movq %rax, %rdi
.LEHB1:
00f6 E8000000 call _Unwind_Resume
00
.LEHE1:
.L5:
00fb C9 leave
.cfi_def_cfa 7, 8
00fc C3 ret
.cfi_endproc
.LFE971:
.globl __gxx_personality_v0
.section .gcc_except_table,"a",@progbits
.LLSDA971:
0000 FF .byte 0xff
0001 FF .byte 0xff
0002 01 .byte 0x1
0003 0B .uleb128 .LLSDACSE971-.LLSDACSB971
.LLSDACSB971:
0004 12 .uleb128 .LEHB0-.LFB971
0005 DA01 .uleb128 .LEHE0-.LEHB0
0007 F301 .uleb128 .L4-.LFB971
0009 00 .uleb128 0
000a F601 .uleb128 .LEHB1-.LFB971
000c 05 .uleb128 .LEHE1-.LEHB1
000d 00 .uleb128 0
000e 00 .uleb128 0
.LLSDACSE971:
.text
_Z41__static_initialization_and_destruction_0ii:
.LFB975:
011a BF000000 movl $_ZStL8__ioinit, %edi
00
011f E8000000 call _ZNSt8ios_base4InitC1Ev
00
0124 BA000000 movl $__dso_handle, %edx
00
0129 BE000000 movl $_ZStL8__ioinit, %esi
00
012e BF000000 movl $_ZNSt8ios_base4InitD1Ev, %edi
00
0133 E8000000 call __cxa_atexit
00
.cfi_startproc
00fd 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
00fe 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
0101 4883EC10 subq $16, %rsp
0105 897DFC movl %edi, -4(%rbp)
0108 8975F8 movl %esi, -8(%rbp)
010b 837DFC01 cmpl $1, -4(%rbp)
010f 7527 jne .L6
0111 817DF8FF cmpl $65535, -8(%rbp)
FF0000
0118 751E jne .L6
.L6:
0138 C9 leave
.cfi_def_cfa 7, 8
0139 C3 ret
.cfi_endproc
.LFE975:
_GLOBAL__sub_I_main:
.LFB976:
.cfi_startproc
013a 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
013b 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
013e BEFFFF00 movl $65535, %esi
00
0143 BF010000 movl $1, %edi
00
0148 E8B0FFFF call _Z41__static_initialization_and_destruction_0ii
FF
014d 5D popq %rbp
.cfi_def_cfa 7, 8
014e C3 ret
.cfi_endproc
.LFE976:
.section .init_array,"aw"
.align 8
0000 00000000 .quad _GLOBAL__sub_I_main
00000000
.text
.Letext0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.