Here I am converting given c++ code to assembly language,see below.
CPP_Code:-
#include<bits/stdc++.h>
int main()
{
int speed,lower,a,b;
if(speed<90)
{
if(speed<80)
{
lower++;
}
else
{
b++;
}
}
else
{
a++;
}
}
Assembly code:-
main:
str fp, [sp, #-4]!
add fp, sp, #0
sub sp, sp, #20
ldr r3, [fp, #-8]
cmp r3, #89
bgt .L2
ldr r3, [fp, #-8]
cmp r3, #79
bgt .L3
ldr r3, [fp, #-12]
add r3, r3, #1
str r3, [fp, #-12]
b .L5
.L3:
ldr r3, [fp, #-16]
add r3, r3, #1
str r3, [fp, #-16]
b .L5
.L2:
ldr r3, [fp, #-20]
add r3, r3, #1
str r3, [fp, #-20]
.L5:
mov r3, #0
mov r0, r3
add sp, fp, #0
ldr fp, [sp], #4
bx lr
__static_initialization_and_destruction_0(int, int):
push {fp, lr}
add fp, sp, #4
sub sp, sp, #8
str r0, [fp, #-8]
str r1, [fp, #-12]
ldr r3, [fp, #-8]
cmp r3, #1
bne .L9
ldr r3, [fp, #-12]
ldr r2, .L10
cmp r3, r2
bne .L9
ldr r0, .L10+4
bl std::ios_base::Init::Init() [complete object constructor]
ldr r2, .L10+8
ldr r1, .L10+12
ldr r0, .L10+4
bl __aeabi_atexit
.L9:
nop
sub sp, fp, #4
pop {fp, lr}
bx lr
.L10:
.word 65535
.word _ZStL8__ioinit
.word __dso_handle
.word _ZNSt8ios_base4InitD1Ev
_GLOBAL__sub_I_main:
push {fp, lr}
add fp, sp, #4
ldr r1, .L13
mov r0, #1
bl __static_initialization_and_destruction_0(int, int)
sub sp, fp, #4
pop {fp, lr}
bx lr
.L13:
.word 65535
Brief Explanation:-
Here is the assembly code from the given c++ code,you can check it in your IDE,And make a inputs.
Thank you..!!
2) Write an assembly program that is algorithmically equivalent to the following C+t code Consider the variables to be 8-bit unsigned integers; you may initialize them to any values 0-255 if you like...
avr assembly please 3) Write an assembly program that is algorithmically equivalent to the following C++ code. Treat the variable y as a short int (16 bits) 1 int y; 2 for (int x = 2; x <= 20; x = x + 2) { 3 ¡f (x < 18) { 4 5 у 24 6 else f 7 8 9 3) Write an assembly program that is algorithmically equivalent to the following C++ code. Treat the variable y as...
Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...
LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which has six working functions that use looping (for, while, or do loops) to repeat the same set of statements multiple times. You will create six equivalent functions that use recursion instead of looping. Although looping and recursion can be interchanged, for many problems, recursion is easier and more elegant. Like loops, recursion must ALWAYS contain a condition; otherwise, you have an infinite recursion (or...
In C code 1. Write and submit the algorithm OR flowchart to indicate you understand the problem 2. Create a project and name the source code lastname_firstname_prog5.c 3. Use the prog5.c as a guide, copy/ paste into your project source code *** build run and test, the outline code - You will need to declare an integer variable called again and initialize it 4. Add the function prototype and implement the function definition for the Greeting function 5. Add the...
== Programming Assignment == For this assignment you will write a program that reads in the family data for the Martian colonies and stores that data in an accessible database. This database allows for a user to look up a family and its immediate friends. The program should store the data in a hashtable to ensure quick access time. The objective of this assignment is to learn how to implement and use a hashtable. Since this is the objective, you...
Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
1. Write a C or C++ program A6p2.c[pp] that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 39 inclusive and store them in a 5 by 12 two dimensional integer array (e.g.,int a[5][12];). Use pthread to create n threads to convert all 60 array elements modulo 11 (i.e. take the remainder after division by 11) in place. You should divide this update task among the n threads as evenly as possible. Print the array both before and after...
Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...
Summary Write a program that demonstrates the skills you’ve learned throughout this quarter. This type of project offers only a few guidelines and requirements, allowing you to invest as much time, effort and imagination as you want. Submit your java programs (*.java) and any other I/O (*.txt) via Canvas You’ve worked quite hard to make it this far, so have a bit of fun with this project! Design Brief: Use Case Scenario You are hired to develop a...
You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...