assambly language

Translate the c code project to assembly language mips with side comments explaining each line.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

#include

#include

#include

#include

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

#define SCREEN_WIDTH 60

#define SCREEN_HEIGHT 20

#define BALL_VELOCITY 1

#define PADDLE_WIDTH 20

#define PADDLE_Y SCREEN_HEIGHT -1

#define LEFT_HOLE_X 2

#define RIGHT_HOLE_X SCREEN_WIDTH – 1

#define HOLES_Y 1

#define SPEED_INCREASE_INTERVAL 100

int main()

{

// Initialize the random number generator.

srand(time(NULL));

// Initialize the ball position and velocity.

int ball_x = SCREEN_WIDTH / 2;

int ball_y = 1;

int ball_velocity_x = BALL_VELOCITY;

int ball_velocity_y = BALL_VELOCITY;

// Initialize the paddle position.

int paddle_x = SCREEN_WIDTH / 2 – PADDLE_WIDTH / 2;

// Initialize the timer variables.

time_t start_time = time(NULL);

time_t current_time;

// Initialize the speed increase variables.

int speed_increase_count = 100;

int speed_increase_amount = 100;

// Game loop.

while (1)

{

// Clear the screen.

system(“cls”);

// Draw the ceiling.

for (int i = 0; i < SCREEN_WIDTH + 2; i++)

{

printf(“M”);

}

printf(“\n”);

// Draw the ball.

for (int i = 0; i < ball_y; i++)

{

printf(“\n”);

}

for (int i = 0; i < ball_x; i++)

{

if (i == SCREEN_WIDTH / 2 – 3 || i == SCREEN_WIDTH / 2 + 2)

{

printf(” “);

}

else

{

printf(” “);

}

}

printf(“X\n”);

// Draw the paddle.

for (int i = ball_y + 1; i < SCREEN_HEIGHT; i++)

{

printf(“\n”);

}

for (int i = 0; i < paddle_x; i++)

{

printf(” “);

}

for (int i = 0; i < PADDLE_WIDTH; i++)

{

printf(“W”);

}

printf(“\n”);

// Check for user input to move the paddle.

if (_kbhit())

{

char key = _getch();

if (key == 77) // right arrow key

{

if (paddle_x < SCREEN_WIDTH - PADDLE_WIDTH)

{

paddle_x += 10;

}

}

else if (key == 75) // left arrow key

{

if (paddle_x > 0)

{

paddle_x -= 10;

}

}

}

// Update the ball position and velocity.

ball_x += ball_velocity_x;

ball_y += ball_velocity_y;

if (ball_x == 0 || ball_x == SCREEN_WIDTH – 1)

{

ball_velocity_x = -ball_velocity_x;

}

if (ball_y == 0)

{

ball_velocity_y = -ball_velocity_y;

}

if (ball_y == PADDLE_Y && ball_x >= paddle_x && ball_x < paddle_x + PADDLE_WIDTH)

{

ball_velocity_y = -ball_velocity_y;

}

if (ball_y % 10 == 0 && ball_y != 0 && ball_x != 0 && ball_x != SCREEN_WIDTH – 1) {

// Increase ball velocity every 10 seconds

ball_velocity_x *= 1.100;

ball_velocity_y *= 1.100;

}

if (ball_y == SCREEN_HEIGHT + 1)

{

printf(“Game over!\n”);

break;

}

if ((ball_x == LEFT_HOLE_X || ball_x == RIGHT_HOLE_X) && ball_y == HOLES_Y)

{

// Reset the ball’s position to the opposite side of the screen.

ball_x = SCREEN_WIDTH – ball_x – 1;

// Add two new balls with opposite velocities.

int new_ball_velocity_x = -ball_velocity_x;

int new_ball_velocity_y = -ball_velocity_y;

int new_ball_x1, new_ball_x2;

int new_ball_y1 = ball_y;

int new_ball_y2 = ball_y;

if (ball_velocity_x > 0) {

// Original ball was moving to the right.

new_ball_x1 = ball_x + 1;

new_ball_x2 = ball_x + 2;

}

else {

// Original ball was moving to the left.

new_ball_x1 = ball_x – 1;

new_ball_x2 = ball_x – 2;

}

if ((ball_x == LEFT_HOLE_X || ball_x == RIGHT_HOLE_X) && ball_y == HOLES_Y)

{

printf(” “);

}

else

{

printf(“*”);

}

// Draw the new balls.

for (int i = 0; i < ball_y; i++)

{

printf(“\n”);

}

for (int i = 0; i < ball_x; i++)

{

if (i == SCREEN_WIDTH / 2 – 3 || i == SCREEN_WIDTH / 2 + 2)

{

printf(” “);

}

else

{

printf(” “);

}

}

printf(“@\n”);

// Update the ball position and velocity.

ball_x += ball_velocity_x;

ball_y += ball_velocity_y;

if (ball_x == 0 || ball_x == SCREEN_WIDTH – 1)

{

ball_velocity_x = -ball_velocity_x;

}

if (ball_y == 0)

{

ball_velocity_y = -ball_velocity_y;

}

if (ball_y == PADDLE_Y && ball_x >= paddle_x && ball_x < paddle_x + PADDLE_WIDTH)

{

ball_velocity_y = -ball_velocity_y;

}

if (ball_y % 10 == 0 && ball_y != 0 && ball_x != 0 && ball_x != SCREEN_WIDTH – 1)

{

// Increase ball velocity every 10 seconds

ball_velocity_x *= 1.9;

ball_velocity_y *= 1.9;

}

if (ball_y == SCREEN_HEIGHT – 1)

{

printf(“Game over!\n”);

break;

}

}

}

return 0;

} #include
#include
#include
#include
#define SCREEN_WIDTH 60
#define SCREEN_HEIGHT 20
#define BALL_VELOCITY 1
#define PADDLE_WIDTH 20
#define PADDLE_Y SCREEN_HEIGHT -1
#define LEFT_HOLE_X 2
#define RIGHT_HOLE_X SCREEN_WIDTH – 1
#define HOLES_Y 1
#define SPEED_INCREASE_INTERVAL 100
int main()
{
// Initialize the random number generator.
srand(time(NULL));
// Initialize the ball position and velocity.
int ball_x = SCREEN_WIDTH / 2;
int ball_y = 1;
int ball_velocity_x = BALL_VELOCITY;
int ball_velocity_y = BALL_VELOCITY;
// Initialize the paddle position.
int paddle_x = SCREEN_WIDTH / 2 – PADDLE_WIDTH / 2;
// Initialize the timer variables.
time_t start_time = time(NULL);
time_t current_time;
// Initialize the speed increase variables.
int speed_increase_count = 100;
int speed_increase_amount = 100;
// Game loop.
while (1)
{
// Clear the screen.
system(“cls”);
// Draw the ceiling.
for (int i = 0; i < SCREEN_WIDTH + 2; i++) { printf("M"); } printf("\n"); // Draw the ball. for (int i = 0; i < ball_y; i++) { printf("\n"); } for (int i = 0; i < ball_x; i++) { if (i == SCREEN_WIDTH / 2 - 3 || i == SCREEN_WIDTH / 2 + 2) { printf(" "); } else { printf(" "); } } printf("X\n"); // Draw the paddle. for (int i = ball_y + 1; i < SCREEN_HEIGHT; i++) { printf("\n"); } for (int i = 0; i < paddle_x; i++) { printf(" "); } for (int i = 0; i < PADDLE_WIDTH; i++) { printf("W"); } printf("\n"); // Check for user input to move the paddle. if (_kbhit()) { char key = _getch(); if (key == 77) // right arrow key { if (paddle_x < SCREEN_WIDTH - PADDLE_WIDTH) { paddle_x += 10; } } else if (key == 75) // left arrow key { if (paddle_x > 0)
{
paddle_x -= 10;
}
}
}
// Update the ball position and velocity.
ball_x += ball_velocity_x;
ball_y += ball_velocity_y;
if (ball_x == 0 || ball_x == SCREEN_WIDTH – 1)
{
ball_velocity_x = -ball_velocity_x;
}
if (ball_y == 0)
{
ball_velocity_y = -ball_velocity_y;
}
if (ball_y == PADDLE_Y && ball_x >= paddle_x && ball_x < paddle_x + PADDLE_WIDTH) { ball_velocity_y = -ball_velocity_y; } if (ball_y % 10 == 0 && ball_y != 0 && ball_x != 0 && ball_x != SCREEN_WIDTH - 1) { // Increase ball velocity every 10 seconds ball_velocity_x *= 1.100; ball_velocity_y *= 1.100; } if (ball_y == SCREEN_HEIGHT + 1) { printf("Game over!\n"); break; } if ((ball_x == LEFT_HOLE_X || ball_x == RIGHT_HOLE_X) && ball_y == HOLES_Y) { // Reset the ball's position to the opposite side of the screen. ball_x = SCREEN_WIDTH - ball_x - 1; // Add two new balls with opposite velocities. int new_ball_velocity_x = -ball_velocity_x; int new_ball_velocity_y = -ball_velocity_y; int new_ball_x1, new_ball_x2; int new_ball_y1 = ball_y; int new_ball_y2 = ball_y; if (ball_velocity_x > 0) {
// Original ball was moving to the right.
new_ball_x1 = ball_x + 1;
new_ball_x2 = ball_x + 2;
}
else {
// Original ball was moving to the left.
new_ball_x1 = ball_x – 1;
new_ball_x2 = ball_x – 2;
}
if ((ball_x == LEFT_HOLE_X || ball_x == RIGHT_HOLE_X) && ball_y == HOLES_Y)
{
printf(” “);
}
else
{
printf(“*”);
}
// Draw the new balls.
for (int i = 0; i < ball_y; i++) { printf("\n"); } for (int i = 0; i < ball_x; i++) { if (i == SCREEN_WIDTH / 2 - 3 || i == SCREEN_WIDTH / 2 + 2) { printf(" "); } else { printf(" "); } } printf("@\n"); // Update the ball position and velocity. ball_x += ball_velocity_x; ball_y += ball_velocity_y; if (ball_x == 0 || ball_x == SCREEN_WIDTH - 1) { ball_velocity_x = -ball_velocity_x; } if (ball_y == 0) { ball_velocity_y = -ball_velocity_y; } if (ball_y == PADDLE_Y && ball_x >= paddle_x && ball_x < paddle_x + PADDLE_WIDTH) { ball_velocity_y = -ball_velocity_y; } if (ball_y % 10 == 0 && ball_y != 0 && ball_x != 0 && ball_x != SCREEN_WIDTH - 1) { // Increase ball velocity every 10 seconds ball_velocity_x *= 1.9; ball_velocity_y *= 1.9; } if (ball_y == SCREEN_HEIGHT - 1) { printf("Game over!\n"); break; } } } return 0; }

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER