Answer: Here is an Incomplete question submitted
Explanation:
Using the knowledge in computational language in LC-3 Assembly it is possible to write a code that replaces the value in R0 with its absolute value
<h3>Writting the code </h3>
.ORIG x0200
START
AND R0, R0, #0 ; copy R0 to itself to set the condition codes based on R0;
; i.e performing addition operation with Zero option to set the flags
BRzp DONE ; if R0 is NON-NEGATIVE, skip the negation (already correct);
; Branch to DONE if number is poistive
NOT R0, R0 ; R0 is negative, so negate it i.e taking 2's complement
ADD R0, R0, #1 ; R0 = -R0 is performed successfully
DONE BR START
.END
See more about LC-3 Assembly at brainly.com/question/12978370
#SPJ1
Answer:
Given
The above lines of code
Required
Rearrange.
The code is re-arrange d as follows;.
#include<iostream>
int main()
{
int userNum;
scanf("%d", &userNum);
if (userNum > 0)
{
printf("Positive.\n");
}
else
{
printf("Non-positive, converting to 1.\n");
userNum = 1;
printf("Final: %d\n", userNum);
}
return 0;
}
When rearranging lines of codes. one has to be mindful of the programming language, the syntax of the language and control structures in the code;
One should take note of the variable declarations and usage
See attachment for .cpp file
Answer:
Rights and Responsibilities
Explanation: