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
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...
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
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....
Write the below code to use HTML and JavaScript. 1)Write a JavaScript program to create a...
Write the below code to use HTML and JavaScript. 1)Write a JavaScript program to create a new string from a given string changing the position of first and last characters. The string length must be greater than or equal to 1. 2)Write a JavaScript program to check whether a string starts with 'Java' and false otherwise
Write a piece of assembly code in SimpleRisc to find out if a number is a...
Write a piece of assembly code in SimpleRisc to find out if a number is a Factorian number or Dudeney number. Save 1 in r1 if it is a Factorian number; otherwise, save 0. Save 1 in r2 if it is a Dudeney number; otherwise, save 0. You have to write a single program to test both these conditions.
Write a program that finds the largest number among two numbers and store the result in...
Write a program that finds the largest number among two numbers and store the result in any register. Value1: 0x18345678 (hexidecimal) Value2: 0x15678245 (hexidecimal) (Code in ARM assembly language, Using Keil software)
1- Write a program to print only the even numbers from 100 to 200 2- Write...
1- Write a program to print only the even numbers from 100 to 200 2- Write a program to print the odd numbers from 22 – 99 3- Write a program to calculate howe many even number from 10 to 120 1- Write a program to find only the even numbers for 12 different numbers 2- Write a program to find the odd numbers for 10 different numbers 3- Write a program to calculate howe many even number and how...
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code...
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code using a while loop, which keeps asking the user to enter an number divisible by 5. The program(i.e the while loop) terminates when the user enters a number divisible by 5, but keeps running if the user fails to enter a number divisible by 5. Also print appropriate message after each failed try. When successful, tell the user how many attempts were needed for...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT