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

This is a ARM program question and the orginal program is modify the program so

ID: 3697785 • Letter: T

Question

This is a ARM program question and the orginal program is

modify the program so that siatify the below condition

1.the “simple2.s” program will “iteratively” sum up the double of each integer element in the arrA by looping until the end of the array signaled by a negative integer. For instance, if arrA = [1, 3, 5, -1], the final result stored in r0 should be : 1 × 2 + 3 × 2 +5 × 2 = 1

2.To produce an optimized program, the “simple2.s” program should use conditional execution of the ARM instructions, the short-cut trick for array bounds checking and the integration of shift operations to the 2nd operands

3.

Plz show the complete assembly program code

Explanation / Answer

Answer:

Assembly Language Code :

.Ltext0:

        .section   .rodata
    .LC1:
0000 20456E74        .string   " Enter the value of N"

    .LC2:

0019 00000000        .align 8

    .LC3:
0020 20456E74        .string   " Enter numbers of your choice ) "


    .LC5:
0048 20417272        .string   " Array elements"

    .LC6:
0058 25640A00        .string   "%d "
005c 00000000        .align 8
    .LC7:
0060 2053756D        .string   " Sum of all positive numbers =%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 4881ECF0        subq   $240, %rsp
  
000b 64488B04        movq   %fs:40, %rax

0014 488945F8        movq   %rax, -8(%rbp)
0018 31C0        xorl   %eax, %eax
001a C78524FF        movl   $0, -220(%rbp)

0024 660FEFC0        pxor   %xmm0, %xmm0
0028 F20F1185        movsd   %xmm0, -216(%rbp)

0030 BF000000        movl   $.LC1, %edi

0035 E8000000        call   puts

003a 488D851C        leaq   -228(%rbp), %rax

0041 4889C6        movq   %rax, %rsi
0044 BF000000        movl   $.LC2, %edi

0049 B8000000        movl   $0, %eax

004e E8000000        call   __isoc99_scanf

0053 8B851CFF        movl   -228(%rbp), %eax

0059 89C6        movl   %eax, %esi
005b BF000000        movl   $.LC3, %edi

0060 B8000000        movl   $0, %eax

0065 E8000000        call   printf
  
006a C78520FF        movl   $0, -224(%rbp)

0074 EB30        jmp   .L2
    .L3:
009f 838520FF        addl   $1, -224(%rbp)
  
0076 488D8530        leaq   -208(%rbp), %rax

007d 8B9520FF        movl   -224(%rbp), %edx

0083 4863D2        movslq   %edx, %rdx
0086 48C1E202        salq   $2, %rdx
008a 4801D0        addq   %rdx, %rax
008d 4889C6        movq   %rax, %rsi
0090 BF000000        movl   $.LC4, %edi

0095 B8000000        movl   $0, %eax

009a E8000000        call   __isoc99_scanf

    .L2:
00a6 8B851CFF        movl   -228(%rbp), %eax

00ac 398520FF        cmpl   %eax, -224(%rbp)

00b2 7CC2        jl   .L3
00b4 BF000000        movl   $.LC5, %edi

00b9 E8000000        call   puts

00be C78520FF        movl   $0, -224(%rbp)

00c8 EB27        jmp   .L4
    .L5:
00ea 838520FF        addl   $1, -224(%rbp)

00ca 8B8520FF        movl   -224(%rbp), %eax

00d0 4898        cltq
00d2 8B848530        movl   -208(%rbp,%rax,4), %eax

00d9 89C6        movl   %eax, %esi
00db BF000000        movl   $.LC6, %edi

00e0 B8000000        movl   $0, %eax

00e5 E8000000        call   printf

    .L4:
00f1 8B851CFF        movl   -228(%rbp), %eax
  
00f7 398520FF        cmpl   %eax, -224(%rbp)
  
00fd 7CCB        jl   .L5
00ff C78520FF        movl   $0, -224(%rbp)
  
0109 EB5C        jmp   .L6
    .L9:
010b 8B8520FF        movl   -224(%rbp), %eax

0111 4898        cltq
0113 8B848530        movl   -208(%rbp,%rax,4), %eax

011a 85C0        testl   %eax, %eax
011c 7917        jns   .L8
011e 8B8520FF        movl   -224(%rbp), %eax

0124 4898        cltq
0126 8B848530        movl   -208(%rbp,%rax,4), %eax

012d 01C0        addl   %eax, %eax
012f 018524FF        addl   %eax, -220(%rbp)

    .L8:
0160 838520FF        addl   $1, -224(%rbp)
  
0135 8B8520FF        movl   -224(%rbp), %eax
  
013b 4898        cltq
013d 8B848530        movl   -208(%rbp,%rax,4), %eax

0144 660FEFC0        pxor   %xmm0, %xmm0
0148 F20F2AC0        cvtsi2sd   %eax, %xmm0
014c F20F108D        movsd   -216(%rbp), %xmm1
  
0154 F20F58C1        addsd   %xmm1, %xmm0
0158 F20F1185        movsd   %xmm0, -216(%rbp)

    .L6:
0167 8B851CFF        movl   -228(%rbp), %eax
  
016d 398520FF        cmpl   %eax, -224(%rbp)

0173 7C96        jl   .L9
0175 8B8524FF        movl   -220(%rbp), %eax

017b 89C6        movl   %eax, %esi
017d BF000000        movl   $.LC7, %edi

0182 B8000000        movl   $0, %eax

0187 E8000000        call   printf

018c 90        nop
018d 488B45F8        movq   -8(%rbp), %rax
0191 64483304        xorq   %fs:40, %rax

019a 7405        je   .L10
019c E8000000        call   __stack_chk_fail

    .L10:
01a1 C9        leave
        .cfi_def_cfa 7, 8
01a2 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