Write down the values assigned to register R14 in four steps

Write down the values assigned to register R14 in four steps (labeled in Listing 7.16). The assembly code for Prob. 7.14. .cdecls C, LIST, \"msp430.h\" .text .retain .retainrefs RESET mov.w #WDTPW|WDTHOLD, WDTCTL mov.w #_ _STACK_END, SP mov.w #0006h, &0200h mov.w #000 Aha, &0202h mov.w #0014h, &0204h mov.w #008Dh, &0206h mov.w #0200h, R13 mov.w 2(R13), R14;step 1 sub.w 0(R13), R14;step 2 add.W 4(R13), R14;step 3 ada.W 6(R13), R14;step 4 jmp $;-------------;Stack Pointer definition;-------------

Solution

#include //for: atexit
using namespace std;


const double POINTS_PER_INCH=96.0;


struct Point {
double x;
double y;
double inches;
double deg;
Point(double a, double b, double c, double in) : x(a), y(b), deg(c), inches(in){}
};

const double Pi=atan(1)*4;
const double DegPerRad=57.2957795;

static Point currentPoint(0.0,0.0,0.0/DegPerRad, 0.25);
static std::vector v;


void moveForward(double inches)
{
double x,y;
x=cos(currentPoint.deg)*POINTS_PER_INCH*inches;
y=-sin(currentPoint.deg)*POINTS_PER_INCH*inches;
v.push_back(Point(x,y,currentPoint.deg, inches));
currentPoint.x=x;
currentPoint.y=y;
}

void moveBackward(double inches)
{
double x,y;
x=cos(currentPoint.deg+Pi)*POINTS_PER_INCH*inches; //Add Pi Radians to reverse direction
y=-sin(currentPoint.deg+Pi)*POINTS_PER_INCH*inches; //Add Pi Radians to reverse direction
v.push_back(Point(x,y,currentPoint.deg, inches));
currentPoint.x=x;
currentPoint.y=y;
}

void turnRightBy(double deg)
{
currentPoint.deg=(currentPoint.deg-deg/DegPerRad);

}

void turnLeftBy(double deg)
{
currentPoint.deg=((currentPoint.deg+deg/DegPerRad));
}

static double ymax=0.0;//std::numeric_limits::min();
static double ymin=0.0;//std::numeric_limits::max();
static double xmax=0.0;//std::numeric_limits::min();
static double xmin=0.0;//std::numeric_limits::max();

double _yelem_min(double d, const Point& p)
{
double newsum=d+p.y;
ymin=(newsum < ymin) ? newsum : ymin;
return newsum;
}

double _yelem_max(double d, const Point& p)
{
double newsum=d+p.y;
ymax=(newsum > ymax) ? newsum : ymax;
return newsum;
}

double _xelem_min(double d, const Point& p)
{
double newsum=d+p.x;
xmin = (newsum < xmin) ? newsum : xmin;
return newsum;
}

double _xelem_max(double d, const Point& p)
{
double newsum=d+p.x;
xmax=(newsum > xmax) ? newsum : xmax;
return newsum;
}

static double verticalMarginInches=0.5*POINTS_PER_INCH;
static double horizontalMarginInches=0.5*POINTS_PER_INCH;

void printpage()
{
// A hack. Use this iterator to compute the summed minimum of each axis
std::accumulate(v.begin(), v.end(), 0.0, _yelem_min);
std::accumulate(v.begin(), v.end(), 0.0, _yelem_max);
std::accumulate(v.begin(), v.end(), 0.0, _xelem_min);
std::accumulate(v.begin(), v.end(), 0.0, _xelem_max);

double offx=0.0-xmin+horizontalMarginInches/2.0;
double offy=0.0-ymin+verticalMarginInches/2.0;

cout.precision(3);
cout << fixed;

cout << \"\" << endl;
cout << \"

\" << endl;
cout << \"Hexagon Challenge!

\" << endl;
cout << \"

\" << endl;

cout << \"\" << endl;


cout << \"

//starting point
cout << offx << \",\" << offy << \" \";
for(int j=0; j {
offx+=v[j].x;
offy+=v[j].y;
cout << offx << \",\" << offy << \" \";
}
cout << \'\\\"\' << endl;
cout << \"style=\\\"fill:white;stroke:black;stroke-width:2\\\" />\" << endl;
cout << \"\" << endl;
cout << \"\" << endl;
cout << \"\" << endl;
}

class Wrapper {
public:
Wrapper() {atexit(printpage);}
};
static Wrapper w; //force the atexit function to be set up

Code 2:

// draw_hexes.cpp

#include\"hexagon.h\"
int main()
{
for(int i=0; i<6; ++i)
{
moveForward();
turnRightBy(60);
}
return 0;
}

 Write down the values assigned to register R14 in four steps (labeled in Listing 7.16). The assembly code for Prob. 7.14. .cdecls C, LIST, \
 Write down the values assigned to register R14 in four steps (labeled in Listing 7.16). The assembly code for Prob. 7.14. .cdecls C, LIST, \
 Write down the values assigned to register R14 in four steps (labeled in Listing 7.16). The assembly code for Prob. 7.14. .cdecls C, LIST, \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site