jeylam26

jeylam26

Lv1

jeylam26Carroll University

0 Followers
1 Following
0 Helped

ANSWERS

Published2

Subjects

Computer Science1Mathematics1
Answer: shift sin-1 =4:6

Hey, I need help adding the first code into the second by modifying the second code by adding a variable temp into the code: (Code must be in Assembly Language Linux 64 bit Ubuntu)

Here's the first code:

Add a new variable temp.

If (sum >= 0 && sum<50)

{

      If (remainder == 0)

             Temp = 0;

      Else

     {

           Temp = 60;

     }

}

Else

{

     If (average < 10 || remainder == 0)

      {

               Temp = 100;

      }

      Else

      {

              Temp = 50;

      }

}

The following Assembly Code that I need modified is the following:

sum1: PUSH %BP %BP ;the state of base pointer is saved to the stack and stack pointer is incremented MOV %SP, %BP ; move the value of stack pointer to the base pointer @sum1_body: MOV 8(%BP), %0;moves value of operand to next free register MOV (%0), %0 ; moves value stored in memmory register into itself MOV 8(%BP), %1 %0;moves value of operand to next free register MOV 4(%1), %1 ; moves value stored in memmory register into itself ADD %0, %1, %0 ;add first and second operand and save in third MOV 8(%BP), %1 MOV 8(%1), %1 ADD %0, %1, %0 MOV 8(%BP), %1 %0;moves value of operand to next free register MOV 12(%1), %1 ADD %0, %1, %0 ;add first and second operand and save in third MOV %0, %13 ;moves the value to second operand from first JMP @sum1_exit ;unconditional jummp to sum1 exit routine @sum1_exit: MOV %BP, %SP ;moves value of base pointer to stack pointer POP %BP ;pop the value of stack which was added at time of function entry RET ;pops the value from stack main: PUSH %BP MOV %SP, %BP @main_body: SUB %SP, $16, %SP ;space for 1 local variable will be reserved on the stack MOV $2, -16(%BP) ;moves the value to second operand from first MOV $3, -12(%BP) ;moves the value to second operand from first MOV $1, -8(%BP) ;moves the value to second operand from first MOV $3, -4(%BP) ;moves the value to second operand from first MOV $10, -16(%BP) ;moves the value to second operand from first MOV $11, -12(%BP) ;moves the value to second operand from first MOV $12, -8(%BP) ;moves the value to second operand from first MOV $13, -4(%BP) LEA -16(%BP), %0 ;moves the value to second operand from first PUSH %0 CALL sum1 ADD %SP, $4, %SP SUB %SP, $4, %SP ;space for 1 local variable will be reserved on the stack MOV %13, -20(%BP) LEA -16(%BP), %0 PUSH %0 CALL sum1 ADD %SP, $4, %SP ;add first and second operand and save in third DIV %13, $4, %0 ;divide first and second operand and save in third SUB %SP, $4, %SP ;space for 1 local variable will be reserved on the stack MOV %0, -24(%BP) ;moves the value to second operand from first SUB %SP, $4, %SP ;space for 1 local variable will be reserved on the stack MOV $0, -28(%BP) ;moves the value to second operand from first DIV -20(%BP), $4, %0 ;divide first and second operand and save in third MOV %0, -24(%BP) ;moves the value to second operand from first @main_exit: MOV %BP, %SP ;moves value of base pointer to stack pointer POP %BP ;pop the value of stack which was added at time of function entry RET ;pops the value from stack

So I essentially need the first code to be inserted into the second code somehow that works.

Again all code must be in Assembly Language Linux 64 bit Ubuntu. Thank you.

Answer: t

Weekly leaderboard

Start filling in the gaps now
Log in