Question

Explain steps also please. Thanks. - We want to implement "if (m != n) m--;" in...

Explain steps also please. Thanks.

- We want to implement "if (m != n) m--;" in LEGv8.

Suppose m and n are in X20 and X21, respectively. What should we use in the blank in the following code segment?

SUB X9,X20,X21

_____ EXIT

SUBI X20,#1

EXIT:

- Suppose X20 contain the decimal value 5 and X21 contains the decimal value -5. Which condition codes are set to 1 after the following instruction is executed?

ADDS X9,X20,X21

- We want to implement "if (m != n) m--;" in LEGv8.

Suppose m and n are in X20 and X21, respectively. What should we use in the blank in the following code segment?

SUB X9,X20,X21

_____ EXIT

SUBI X20,#1

EXIT:

Homework Answers

Answer #1

Part 1:

SUB X9,X20,X21

CBZ X9 EXIT

SUBI X20,#1

EXIT:

Knowledge behind above:

CBZ register, L1    if (register == 0) branch to instruction labeled L1;

CBNZ register, L1 if (register != 0) branch to instruction labeled L1;

Here, we will exit only when m==n otherwise we will do m--. So, we used here CBZ command.

Part 2:

The Z flag is set if the result of the flag-setting instruction is zero.

Here,

ADDS X9,X20,X21 result in X9 as 0

So, Z flag set to 1.

Knowledge behind above:

Condition codes, set from arithmetic instruction

negative (N): result had 1 in MSB

zero (Z): result was 0

overlow (V): result overflowed

carry (C): result had carryout from MSB

Part 3:

It is same as part 1. So, same answer as in part 1 can be used.

Hope it helps.

Thank you!

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
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from...
For this assignment you will implement a simple calculator or interpreter that reads arithmetic expressions from a file. Specifically, you will implement the following function: /* * Reads one arithmetic "expression" at a time from a file stream, computes, then * returns the result. If there are additional expressions in the file, they are * read and computed by successive calls to “calculator”. * * “Expressions” are groups of operations (add, subtract, multiply, divide). Your * calculator will read and...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
Description: In this assignment, you need to implement a recursive descent parser in C++ for the...
Description: In this assignment, you need to implement a recursive descent parser in C++ for the following CFG: 1. exps --> exp | exp NEWLINE exps 2. exp --> term {addop term} 3. addop --> + | - 4. term --> factor {mulop factor} 5. mulop --> * | / 6. factor --> ( exp ) | INT The 1st production defines exps as an individual expression, or a sequence expressions separated by NEWLINE token. The 2nd production describes an...
please can you make it simple. For example using scanner or hard coding when it is...
please can you make it simple. For example using scanner or hard coding when it is a good idea instead of arrays and that stuff.Please just make one program (or class) and explain step by step. Also it was given to me a txt.htm 1.- Write a client program and a server program to implement the following simplified HTTP protocol based on TCP service. Please make sure your program supports multiple clients. The webpage file CS3700.htm is provided. You may...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b, where a – b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a – b = 3 A = [10, 4, 6, 16, 1, 6, 12, 13] Then your method should return the following pairs: 4, 1 15, 12 13, 10 A poor solution: There are...