Question

Write an ARM assembly language program to translate the following sequence of statements . Assume x...

Write an ARM assembly language program to translate the following sequence of statements . Assume x and y are memory locations that store two unsigned integers. Use the following: x is in R1, y is in R2, and z in R3. Make sure that your program works for any value of x and y.

if (x > 15)

{

    x = 1;

    if (y > 15) {

         y = 2;

        }

else {

      y = y + 2;

     }

}

else {

     x = x + 1;

     }

z = x + y;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

main:
; storing the values
   MOV   %rsp, %rbp
   SUB   $48, %rsp
   CALL   __main
   CMP   $15, -4(%rbp)
   J   Loop2
;moving the values
   MOV   $1, -4(%rbp)
   CMP   $15, -8(%rbp)
;checkgin the condition
   jle   Loop3
   MOV   $2, -8(%rbp)
   JMP   Loop4
Loop3:
;going for the annother condition
   ADD   $2, -8(%rbp)
   jmp   Loop4
Loop2:
;going for the else condition
   ADD   $1, -4(%rbp)
Loop4:
; ending the last loop by finalizing the result
   MOV   -4(%rbp), %edx
   MOV   -8(%rbp), %eax
   MOV   %edx, %eax
   MOV   %eax, -12(%rbp)
   MOV   $0, %eax
   ADD   $48, %rsp
ENDP
END

PLEASE REVERT IN THE COMMENTS FOR ANY FURTHER HELP!!!!!!!!!

Add a comment
Know the answer?
Add Answer to:
Write an ARM assembly language program to translate the following sequence of statements . Assume x...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write an ARM assembly language program to translate the following sequence of statements . Assume x...

    Write an ARM assembly language program to translate the following sequence of statements . Assume x and y are memory locations that store two unsigned integers. Use the following: x is in R1, y is in R2, and z in R3. Make sure that your program works for any value of x and y. if (x > 15) {     x = 1;     if (y > 15) {          y = 2;         } else {       y =...

  • (10 points) Translate the following algorithm into assembly language. IF 65 < X THEN X = 9+(X^...

    (10 points) Translate the following algorithm into assembly language. IF 65 < X THEN X = 9+(X^2) ELSE X = - Y 3. (10 points) Translate the following algorithm into assembly language. X=0 FOR K = I TO 5 X=X+5 END_FOR 4. (10 points) Translate the following algorithm into assembly language. X=0 Y=5 Z=5 WHILE Z = 5 X=X+1 Y=Y-1 Z=X+Y 2. (10 points) Translate the following algorithm into assembly language. IF65 < X THEN X = 9t(X^2) ELSE X...

  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • 2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z r...

    2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...

  • Write a program in assembly language that loads register R2 with the word in memory location...

    Write a program in assembly language that loads register R2 with the word in memory location which is 10 bytes above the address in R0; and loads register R3 with the word in memory location which is 10 bytes below the address in R1. Your program must compare the two numbers in R2 and R3. If number in R2 is less than or equal to the number in R3 it must add the two numbers and save the result in...

  • 1. Translate the following tasks into a single ARM instruction: a. Add 32 times of the...

    1. Translate the following tasks into a single ARM instruction: a. Add 32 times of the content of registers r0 and the content of r1 only if N is clear. Store the result in register r2 b. Subtract the content of register r0 from 0x990 and put the results in register r3 only if C is set and Z is clear. c. Clear the 2nd least significant byte of the content of register r1, i.e., store (00000000)2 in it, and...

  • Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language...

    Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language statements. Assume that each variable (A, B. C, and D) is one word in memory. If notequalto B then C: =5; else C: =10; D: =50;

  • Write a program in ARM assembly language that copies each element of array A to consecutive...

    Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.

  • Given the following C Code segment convert it to ARM assembly. Assume the following register assignment...

    Given the following C Code segment convert it to ARM assembly. Assume the following register assignment have been made before your section of code begins. C Variable Register assignment r1 y r2 r3 r10 j r11 int x=0, y=0, z=0; int main() { for (int i = 0; i<10; i++) for (int j 0; j < 20; j++) if (i* j > 100) X++; if (i j >= 15) y++; + فہه Z = X + y; }

  • Could you please help me doing this? Slide #14: Slide #15 The question: ARM Assembly Language...

    Could you please help me doing this? Slide #14: Slide #15 The question: ARM Assembly Language label mnemonic operand1, operand2, operand3 comments R2+R1->R3 Loc ADD R3, R2 R1 Label is a symbolic reference to this instruction's address in memory. Mnemonic represents the operation to be performed .The number of operands varies, depending on each specific instruction. Some instructions have no operands at all. operand1 is typically the destination register, and operand2 and operand3 are source operands. operand2 is usually a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT