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

Write a program that take 10 64-bit variables and adds them using the 64-bit gen

ID: 3773023 • Letter: W

Question

Write a program that take 10 64-bit variables and adds them using the 64-bit general purpose registers to get a sum that is equal to0xffffffffffffffff. The sum itself should be a 64-bit value and should contain the hexadecimal value 0xffffffffffffffff after all 10 64-bit variables have been added to produce the sum.

Program Requirements

The 64-bit registers that can be used are rax, rbx, rcx, and rdx. These are the 64-bit versions of the 32-bit general purpose registers eax, ebx, ecx, and edx. A 64-bit variable is declared as a QWORD. All 64-bit variables for this program must have a length equal to a QWORD. The 10 variables may have only decimal or hexadecimal numeric values in them. The 10 variables are added much like the variables were for program 1 in that thevariables have their initial values hardcoded to whatever values you’d like to choose, as long as their sum adds up to 0xffffffffffffffff.

There must be a variable declared named sum in addition to the 10 variables that you must declare. You use the 64-bit registers to add the 10 variables to get 0xffffffffffffffff, and the variable sum must have the final value of the addition of all 10 variables assigned to it before the program ends.

Unlike previous 32-bit programs in the course, the 64-bit program does not need any directives for the processor type or the memory model. So there will be no .386, .586, or .model directives you need to supply.

Explanation / Answer

.Ltext0: .section .rodata .LC0: 0000 25642564 .string "%d%d%d%d%d%d%d%d%d%d" 25642564 25642564 25642564 25642564 .LC1: 0015 256400 .string "%d" .text .globl main main: .LFB0: .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 4883EC60 subq $96, %rsp 0008 4C8D45E4 leaq -28(%rbp), %r8 000c 488D7DE0 leaq -32(%rbp), %rdi 0010 488D4DDC leaq -36(%rbp), %rcx 0014 488D55D8 leaq -40(%rbp), %rdx 0018 488D45D4 leaq -44(%rbp), %rax 001c 488D75F8 leaq -8(%rbp), %rsi 0020 48897424 movq %rsi, 32(%rsp) 20 0025 488D75F4 leaq -12(%rbp), %rsi 0029 48897424 movq %rsi, 24(%rsp) 18 002e 488D75F0 leaq -16(%rbp), %rsi 0032 48897424 movq %rsi, 16(%rsp) 10 0037 488D75EC leaq -20(%rbp), %rsi 003b 48897424 movq %rsi, 8(%rsp) 08 0040 488D75E8 leaq -24(%rbp), %rsi 0044 48893424 movq %rsi, (%rsp) 0048 4D89C1 movq %r8, %r9 004b 4989F8 movq %rdi, %r8 004e 4889C6 movq %rax, %rsi 0051 BF000000 movl $.LC0, %edi 00 0056 B8000000 movl $0, %eax 00 005b E8000000 call __isoc99_scanf 00 0060 8B55D4 movl -44(%rbp), %edx 0063 8B45D8 movl -40(%rbp), %eax 0066 01C2 addl %eax, %edx 0068 8B45DC movl -36(%rbp), %eax 006b 01C2 addl %eax, %edx 006d 8B45E0 movl -32(%rbp), %eax 0070 01C2 addl %eax, %edx 0072 8B45E4 movl -28(%rbp), %eax 0075 01C2 addl %eax, %edx 0077 8B45E8 movl -24(%rbp), %eax 007a 01C2 addl %eax, %edx 007c 8B45EC movl -20(%rbp), %eax 007f 01C2 addl %eax, %edx 0081 8B45F0 movl -16(%rbp), %eax 0084 01C2 addl %eax, %edx 0086 8B45F4 movl -12(%rbp), %eax 0089 01C2 addl %eax, %edx 008b 8B45F8 movl -8(%rbp), %eax 008e 01D0 addl %edx, %eax 0090 8945FC movl %eax, -4(%rbp) 0093 8B45FC movl -4(%rbp), %eax 0096 89C6 movl %eax, %esi 0098 BF000000 movl $.LC1, %edi 00 009d B8000000 movl $0, %eax 00 00a2 E8000000 call printf 00 00a7 B8000000 movl $0, %eax 00 00ac C9 leave .cfi_def_cfa 7, 8 00ad C3 ret .cfi_endproc .LFE0: .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