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

need help with ARM assembly program : This is the source code for arm assembly :

ID: 3890728 • Letter: N

Question

need help with ARM assembly program :

This is the source code for arm assembly :

I need to write a two program code that is able to calculate the following using above code :

1 ) RESULT = A + ( B * C ) - D

2) Use MLA instruction to reduce the number of instructions in question 1

Place the result as the return value so you can print it afterwards in the command prompt.

Thank you.

@ File: labe.s global start start: MOV R0, #1 MOV R1, #4 ADD Re, Re, R1 @Moves the constant 1 to the Register Re @ Moves the constant 4 to the Register R1 a The lines below exit the code back to the command line prompt @ Register R7 holds the System call number @ Syscal1 #1 indicates exit @Moves the constant 1 to the Register R7 MOV R7, #1 SWI e Executes Software Interrupt determined by R7

Explanation / Answer

NOTE :-

As there was no information for where the values of A,B,C and D are stored.I defined them as data value as did the operation.If
the data values are present in some registers,we can skip all LDR instruction and directly write MLA instruction


ARM ASSEMBLY CODE:-

   .data
    A: .word 3
    B: .word 4
    C: .word 5
    D: .word 6

    .text
    .global _start
  
    _start:
    MOV R0,#1
    MOV R1,#4
    ADD R0,R0,R1
  
    LDR R0,A
    LDR R1,B
    LDR R2,C
    LDR R3,D
    LDR R4,[R0] ;VALUE OF A
    LDR R5,[R1] ;VALUE OF B
    LDR R0,[R2] ;VALUE OF C
    LDR R1,[R3] ;VALUE OF D
    MLA R2,R5,R0,R4 ;CALCULATES A+(B*C) AND STORE IN R2
    SUB R2,R2,R1
  
    MOV R0,R2 ;placed the result in return value register
    MOV R7,#1
    SWI 0