The solution should be in a similar pattern using instructions like memory refer
ID: 3768778 • Letter: T
Question
The solution should be in a similar pattern using instructions like memory reference(ADD,AND,LDA,BUN,STA,ISZ,BSA ), non memory reference(CLA,CLE,CIR,CIL,CMA,CME,INC, SPA,SNA,SZA,SZE,HLT,INP,OUT,SKI), pseudo instructions (ORG, DEC,HEX,END) Below is the example of multiplying two positive number using instructions. In this assignment, you are going to write an assembly language program to perform the following operation. Input a positive integer (say N), and then compute the sum as follows: Sum 1 + 3+5+ + N The user input will ALWAYS be a two-digit decimal number (between 01 and 99), You need NOT check the correctness of the input. For example, if the user input is "15" then your program will output "64" Hints You can use the following algorithm to compute the sum. int compute sum (int n) i = 1; sum-0 while (iExplanation / Answer
.Ltext0: .section .rodata .LC0: 0000 456E7465 .string "Enter an integer number " 7220616E 20696E74 65676572 206E756D .LC1: 0019 256400 .string "%d" 001c 00000000 .align 8 .LC2: 0020 53756D20 .string "Sum of first %d natural numbers = %d " 6F662066 69727374 20256420 6E617475 .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 4883EC10 subq $16, %rsp 0008 C745FC00 movl $0, -4(%rbp) 000000 000f BF000000 movl $.LC0, %edi 00 0014 E8000000 call puts 00 0019 488D45F4 leaq -12(%rbp), %rax 001d 4889C6 movq %rax, %rsi 0020 BF000000 movl $.LC1, %edi 00 0025 B8000000 movl $0, %eax 00 002a E8000000 call __isoc99_scanf 00 002f C745F801 movl $1, -8(%rbp) 000000 0036 EB0A jmp .L2 .L3: 003e 8345F801 addl $1, -8(%rbp) 0038 8B45F8 movl -8(%rbp), %eax 003b 0145FC addl %eax, -4(%rbp) .L2: 0042 8B45F4 movl -12(%rbp), %eax 0045 3945F8 cmpl %eax, -8(%rbp) 0048 7EEE jle .L3 004a 8B45F4 movl -12(%rbp), %eax 004d 8B55FC movl -4(%rbp), %edx 0050 89C6 movl %eax, %esi 0052 BF000000 movl $.LC2, %edi 00 0057 B8000000 movl $0, %eax 00 005c E8000000 call printf 00 0061 C9 leave .cfi_def_cfa 7, 8 0062 C3 ret .cfi_endproc .LFE0: .Letext0: