Write an LC3 program that would implement if (x == 0) then y = y + 1; else y = y - 1;. Assume than variables x and y are at locations with labels x and y, respectively.
LD R0, x ;load x
BRnp ELSE
; if x is zero then it will enter in clause else
branch to ELSE
LD R1, y ;
load y for add 1 in y
ADD R1, R1, #1
LD R1, y ;
restore R1 in y
BR END_ELSE
ELSE
LD R2, y ;
load y in R2
LD R3, #1 ;
load 1 in R3
NOT R3, R3
; taking compliment for subtraction
ADD R3, R3, 1
ADD R2, R2, R3 ; (y=y-1)
LD R2, y ;
restore R2 in y
// if you got your solution then please give like to question
Write an LC3 program that would implement if (x == 0) then y = y + 1; else y = y - 1;. Assume than variables x and y are...
| 25 pts 25 pts) 2. 2. Write an LC3 program that compares two numbers x and y and puts the larger number in RI. Assume initially that variables x and y are at locations with labels x and y, respectively.
Write a c++ expression representing the following algebraic expression. Assume that all variables in your program are of the type double and that your program has already included the <cmath> header file. 3x + 1/y - 10 + Squareroot g Your answer: (b) Rewrite the same expression assuming that variables x and y in your program are of type int your answer: Convert the following switch statement into an equivalent if-else if statement switch (ch) {case 'A'; cout << "...
Write a coding sequence with the variables x=1 y=10 z=0 that equals 123 after you run the program using += or *= or -= commands
Write a program in LEGv8 assembly to copy a null-terminated ASCII string from array y to array x; converting every 'a' character in the source string to 'b' in the destination string. In other words, for each character in array y: else Assume that the base address of the arrays x and y are in registers X0 and X1, respectively. The ASCII code for characters 'a' and 'b' is 113 and 114 respectively [25 pts]. * Null-terminated means that a...
EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement that multiplies payRate by 1.5 iſ hours is greater than 40. Write variable declarations for the variables payRate and hours first. Hint: Look for keyword if first, your boolean comes after the keyword [. This translates into Java as: double hours, payRate; if (hours > 40) { //{-} are optional here but I recommend that you them payRate = payRate 1.5; pay Rato pay...
0〈z,0〈y Given the following joint distributionfrY(x,y)-, cez+2y else Calculate the following 1. The value of c that makesfxy a proper pdf 2. The marginal distribution function fx(z) 3. The marginal distribution function fy () 4. P(X 1) 7. The random variables X and Y are independent if it is possible to write fxy (x, y) as the product of Íx (x) and fy (y) such that/xy(z, y) = k . Íx (x) . fy(y) for some value of k. Are...
2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...
7. Write the following code segment in MARIE's assembly language (If-Else): If x < Y Then X = Y - X; Y = Y + 1; Else X = Y; Y = 0; Endif;
16. Verify the correctness of the following program segment with the assertions shown. x=z+1 y=x+2 y-6) if y >0 then z=y' + 1 else z=2*y end if (z = 7} 16. Verify the correctness of the following program segment with the assertions shown. x=z+1 y=x+2 y-6) if y >0 then z=y' + 1 else z=2*y end if (z = 7}
g(a,b,c)=(a^x)+(b^y)+(c^z)+x(a)+y(b)+z(c) If variables a,b,c are greater than 0, and variables x,y,z are values between 0 and 1, is this function convex, strictly convex, concave, strictly concave, or none of the stated options?