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

To assess your understanding of basic programming structures in assembly languag

ID: 3862712 • Letter: T

Question

To assess your understanding of basic programming structures in assembly language to assess your knowledge of programming with MASM (Microsoft Macro Assembler) and Visual Studio Write an assembly language program in MASM to perform the following tasks Generate the first N numbers of the sequel 0, 1, 1, 2, 4, 7, 13, 24 .... the sequence is generated as F_n = F_n - 1 + F_n - 2 - F_n - 3 with seed values F_1 = 0, F_2 = 1, F_3 = 1. You will define a DWORD array to store the sequence, and define the following procedures main: prompt users to enter the length of the sequence N, call gen Sew to generate the sequence of N integers, call sum Sew to calculate the sum of the sequence, call display Sew to display the sequence and the sum gen Sew: generate the sequence sum Sew calculate the sum of the sequence display Sew: display the sequence and the sum with a call Write Dec statement How man's integers in the sequence will be generated the sequence is the sum of the sequence is ...

Explanation / Answer

Answer:

.LC0:
   .string   "The sequence is: "
.LC1:
   .string   "%d "
.LC2:
   .string   " The sum of Sequence %d "
   .text
   .globl   _Z6getSeqi
   .type   _Z6getSeqi, @function
_Z6getSeqi:
.LFB0:
   .cfi_startproc
   pushq   %rbp
   .cfi_def_cfa_offset 16
   .cfi_offset 6, -16
   movq   %rsp, %rbp
   .cfi_def_cfa_register 6
   pushq   %rbx
   subq   $72, %rsp
   .cfi_offset 3, -24
   movl   %edi, -68(%rbp)
   movq   %fs:40, %rax
   movq   %rax, -24(%rbp)
   xorl   %eax, %eax
   movq   %rsp, %rax
   movq   %rax, %rbx
   movl   $1, -44(%rbp)
   movl   $0, -52(%rbp)
   movl   -68(%rbp), %eax
   cltq
   subq   $1, %rax
   movq   %rax, -40(%rbp)
   movq   %rax, %rdx
   addq   $1, %rdx
   movq   %rdx, %r10
   movl   $0, %r11d
   movq   %rax, %rdx
   addq   $1, %rdx
   movq   %rdx, %r8
   movl   $0, %r9d
   addq   $1, %rax
   salq   $2, %rax
   leaq   3(%rax), %rdx
   movl   $16, %eax
   subq   $1, %rax
   addq   %rdx, %rax
   movl   $16, %esi
   movl   $0, %edx
   divq   %rsi
   imulq   $16, %rax, %rax
   subq   %rax, %rsp
   movq   %rsp, %rax
   addq   $3, %rax
   shrq   $2, %rax
   salq   $2, %rax
   movq   %rax, -32(%rbp)
   cmpl   $0, -68(%rbp)
   jg   .L2
   movl   $1, -44(%rbp)
   jmp   .L3
.L2:
   leaq   .LC0(%rip), %rdi
   call   puts@PLT
   movl   $1, -56(%rbp)
.L5:
   movl   -56(%rbp), %eax
   cmpl   -68(%rbp), %eax
   jg   .L4
   movl   -44(%rbp), %eax
   imull   -56(%rbp), %eax
   movl   %eax, %ecx
   movq   -32(%rbp), %rax
   movl   -56(%rbp), %edx
   movslq   %edx, %rdx
   movl   %ecx, (%rax,%rdx,4)
   movl   -44(%rbp), %eax
   addl   %eax, -52(%rbp)
   addl   $1, -56(%rbp)
   jmp   .L5
.L4:
   movl   $0, -48(%rbp)
.L7:
   movq   -32(%rbp), %rax
   movl   -48(%rbp), %edx
   movslq   %edx, %rdx
   movl   (%rax,%rdx,4), %eax
   testl   %eax, %eax
   je   .L6
   movq   -32(%rbp), %rax
   movl   -48(%rbp), %edx
   movslq   %edx, %rdx
   movl   (%rax,%rdx,4), %eax
   movl   %eax, %esi
   leaq   .LC1(%rip), %rdi
   movl   $0, %eax
   call   printf@PLT
   addl   $1, -48(%rbp)
   jmp   .L7
.L6:
   movl   -52(%rbp), %eax
   movl   %eax, %esi
   leaq   .LC2(%rip), %rdi
   movl   $0, %eax
   call   printf@PLT
.L3:
   movq   %rbx, %rsp
   nop
   movq   -24(%rbp), %rcx
   xorq   %fs:40, %rcx
   je   .L8
   call   __stack_chk_fail@PLT
.L8:
   movq   -8(%rbp), %rbx
   leave
   .cfi_def_cfa 7, 8
   ret
   .cfi_endproc
.LFE0:
   .size   _Z6getSeqi, .-_Z6getSeqi
   .section   .rodata
.LC3:
   .string   "Enter the number "
.LC4:
   .string   "%d"
   .text
   .globl   main
   .type   main, @function
main:
.LFB1:
   .cfi_startproc
   pushq   %rbp
   .cfi_def_cfa_offset 16
   .cfi_offset 6, -16
   movq   %rsp, %rbp
   .cfi_def_cfa_register 6
   subq   $16, %rsp
   movq   %fs:40, %rax
   movq   %rax, -8(%rbp)
   xorl   %eax, %eax
   leaq   .LC3(%rip), %rdi
   call   puts@PLT
   leaq   -12(%rbp), %rax
   movq   %rax, %rsi
   leaq   .LC4(%rip), %rdi
   movl   $0, %eax
   call   scanf@PLT
   movl   -12(%rbp), %eax
   movl   %eax, %edi
   call   _Z6getSeqi
   movl   $0, %eax
   movq   -8(%rbp), %rdx
   xorq   %fs:40, %rdx
   je   .L11
   call   __stack_chk_fail@PLT
.L11:
   leave
   .cfi_def_cfa 7, 8
   ret
   .cfi_endproc

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