Question

Write an LC-3 program (machine code) that compares the two numbers located in x3600 and x3601...

Write an LC-3 program (machine code) that compares the two numbers located in x3600 and x3601 and puts the value 0 in R1 if the two numbers are equal, 1 if the first number is larger than the second number, and -1 if the first number is smaller than the second number.

Homework Answers

Answer #1

1). ANSWER :

GIVENTHAT :

To write an LC-3 program

.ORIG x3500

LDI R1,x3600 ; Load R1 from memory content at x36000

LDI R2,x3601 ;Load R1 from memory content at x36001

AND R0,R0,#0 ;Initilize R0=0

NOT R3,R2 ;Negate Number 2

ADD R4,R3,R1 ;R4=R1-R3;

BRz eq ; if above step results zero,which indiacates both numbers are equal zero flag enabled

BRn le ;if above step results negative value negative flag enabled ,which indiacates first  numbers ;smaller than second number

BRp gr    ;if above step results negative value negative flag enabled ,which indiacates first  numbers ;igger than second number

eq  AND R0,R0,#0 ;make  R0=0

BRnzp end

le ADD R0,R0,#-1 ;R0=-1

BRnzp end

gr ADD R0,R0,#1 ;R0=1

   BRnzp end

HALT ;End

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1.Write pseudocode for a program that allows the user to input two numbers (X and Y)...
1.Write pseudocode for a program that allows the user to input two numbers (X and Y) and a code C. If the code has value 1, the program should output the larger of X and Y and otherwise output the smaller. Now convert your pseudocode to an assembly language program. Enter the program into the lab software assembler. Assemble the program and execute it with different input data. 2. Write pseudocode for a program that allows the user to input...
(Write in C++) Write a program that reads in two numbers and, if the input is...
(Write in C++) Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop...
Please code C# Write a method with an int return type that has two int parameters....
Please code C# Write a method with an int return type that has two int parameters. The method returns the larger parameter as an int. If neither is larger, the program returns -1. Call this method three times, once with the first argument larger, once with the second argument larger, and once with both arguments equal
Using C++, Create a program that: 1. Asks for a first number 2. Asks for a...
Using C++, Create a program that: 1. Asks for a first number 2. Asks for a second number 3. Evaluate if those two numbers are the same 4. Evaluate if those two numbers are bigger or smaller than the other one, example: a > b, a < b, b > a, b < a. Show only the code.
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
The following code to run as the described program on python. The extra test file isn't...
The following code to run as the described program on python. The extra test file isn't included here, assume it is a text file named "TXT" with a series of numbers for this purpose. In this lab you will need to take a test file Your program must include: Write a python program to open the test file provided. You will read in the numbers contained in the file and provide a total for the numbers as well as the...
Write a machine language program to input two one-digit numbers, add them, and output the one-digit...
Write a machine language program to input two one-digit numbers, add them, and output the one-digit sum. There can be no space between the two one-digit numbers on input. Write the program in a format suitable for the loader and execute it on the Pep/9 simulator. It needs to be in hexadecimal, I am just confused on how to input numbers on the PEP/9 machine.
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Python code Write a complete program with for loop which calculates the sum of the numbers...
Python code Write a complete program with for loop which calculates the sum of the numbers from 1 to 100