Question

Write C code that perform the same as the assembly code. Hint:data is an integer avariable in C. OUT is a name of a function:- //code part is the following.. L1 LDR R0, =0X006 ;The hexadecimal of 0110...

Write C code that perform the same as the assembly code. Hint:data is an integer avariable in C. OUT is a name of a function:- //code part is the following..

L1 LDR R0, =0X006 ;The hexadecimal of 0110 is 0x006

L2 LDR R1, =data

L3 LDR R2, [data]

L4 AND R2, #0X006

L5 CMP R2, #0X006

L6 BLEQ OUT

L7 ..................

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

Lets understand what each instruction is doing.

L1 LDR R0, =0X006   //Load into R0 the value 6

L2 LDR R1, =data    //Load into R1 the value of data

L3 LDR R2, [data] //load into R2, the address of variable data

L4 AND R2, #0X006 //Perform AND operation of R2 with value 6 and store in R2

L5 CMP R2, #0X006 //compare the content of R2 and 0x006

L6 BLEQ OUT   //If content of R2 is less than or equal to 6 then call the function at address OUT.

Below is the equivalent C code:-

int a,b,*c;

a = 6; //load value 6 into variable a

b = data;   //load the value of data in b

c = &data; //load the address of variable data into point c

c = c & 6; //perform bitwise AND operation of pointer c with 6

if( c <= 6)

OUT();    //call the function OUT if c is <= 6

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
Write C code that perform the same as the assembly code. Hint:data is an integer avariable in C. OUT is a name of a function:- //code part is the following.. L1 LDR R0, =0X006 ;The hexadecimal of 0110...
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 equivalent C function and explain what it computes. 3. (10 marks) The following is...

    Write an equivalent C function and explain what it computes. 3. (10 marks) The following is the assembly language translation of a C function mystery: r3, [r0, #0] r3, #0 L3 ldrb cmp beq r3, #0 mov L4: r3, r3, #1 r2, [ro, r3] r2, #0 L4 add ldrb cmp bne .L3: ro, r3 lr mov bx Annotate each line of the function with commentss to explain what each line does. Write an equivalent C function and explain what it...

  • 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...

  • 1.The following pseudocode algorithm is used to calculate the average of two numbers. Perform a desk...

    1.The following pseudocode algorithm is used to calculate the average of two numbers. Perform a desk check on this algorithm assuming the firstValue is 12.5 and the secondValue is 7.5. You should use a table to show your answer. L1: Program AverageCalculator; L2: Data firstValue as float; L3: Data SecondValue as float; L4: Data average as float; L5: Output “Enter the first Number”; L6: Input firstValue; L7: Output “Enter the second Number”; L8: Input secondValue; L9: average = (firstValue+secondValue)/2; L10:...

  • Exercise 3 [Conditionals] Consider the following assembly code for a function F3 with two integer arguments:...

    Exercise 3 [Conditionals] Consider the following assembly code for a function F3 with two integer arguments: F3: push EBP mov EBP, ESP mov EDX, DWORD PTR [ebp+12] mov EAX, DWORD PTR [ebp+8] cmp EAX, EDX # setup stack #if # goto .L1 #EAX- mov EAX, EDX # ignore for now mov DWORD PTR [EBP-4], EAX mov ESP, EBP pop EBE ret # cleanup stack To the right of each instruction, show the contents of the register whose value changes as...

  • Write a program in ARM assembly using ARMSim# to perform the following tasks: 1. Open a...

    Write a program in ARM assembly using ARMSim# to perform the following tasks: 1. Open a file named "integers.dat" and keep track of the following information: a.The first integer value is (i) b. The ith integer value is (j) c. Count the total number of integers in the file d. Count the number of integers that are less than j e. Count how many even numbers are less than j f. And how many odd numbers are less than j...

  • Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In...

    Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In this scheme, some procedure is used to identify when a deadlock occurs, and then another procedure is used to deal with the blocked processes. One technique to identify a deadlock is to maintain a resource graph that identifies all processes, all resources, and the relationships between them (that is, which processes exclusively own which resources, and which processes are blocked waiting for which...

  • Write out C++ code for the following: Declare a templated function that has a return type...

    Write out C++ code for the following: Declare a templated function that has a return type of T". It has two parameters: An array of T items named arr, and an integer named size. This function is assumed to work with numerical data types. Within the function, create a new T variable named sum and initialize it to 0. Use a for-loop to go from 0 (inclusive) to size (exclusive), adding each element from arr to the sum. Finally, return...

  • PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs...

    PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to:             -define a recursive procedure/function and call it.             -use syscall operations to display integers and strings on the console window             -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9                      if n <= 5              =...

  • please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop...

    please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop a "Schedule Book System that runs in the command line environment. The system stores the schedule of events input by user and allows users to add view or delete events. You can assume that the system can at most store 100 events Each group is required to write a Win32 Console Application program called ScheduleBook.cpp The requirements are listed below. RO When the program...

  • C++ 1. Start with a UML diagram of the class definition for the following problem defining a utility class named Month. 2. Write a class named Month. The class should have an integer field named month...

    C++ 1. Start with a UML diagram of the class definition for the following problem defining a utility class named Month. 2. Write a class named Month. The class should have an integer field named monthNumber that holds the number of the month (January is 1, February is 2, etc.). Also provide the following functions: • A default constructor that sets the monthNumber field to 1. • A constructor that accepts the number of month as an argument and sets...

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
ADVERTISEMENT