[Solved] ICS Problem sheet 10

$25

File Name: ICS_Problem_sheet_10.zip
File Size: 188.4 KB

SKU: [Solved] ICS Problem sheet 10 Category: Tag:
5/5 - (1 vote)
Problem 10.1: assembler programming

The following program has been written for the simple central processing unit introduced in class. The table below shows the initial content of the 16 memory cells. The first column denotes the memory address and the second column shows the memory content in hexadecimal notation.

Cell Hex Binary Assembler Description
0 2f
1 6a
2 4f
3 21
4 71
5 41
6 a9
7 d0
8 e0
9 6f
10 01
11 02
12 03
13 04
14 05
15 06
  1. Convert the machine code from hexadecimal notation into binary notation.
  2. Write down the assembler code for the machine code. Add meaningful descriptions.
  3. The program leaves a result in memory cell 15 when it halts. What is the value? Explain how the program works.
  4. What happens if the value stored in memory cell 9 is changed to 0x70 before execution starts? Explain.

Problem 10.2: integer multiplication in risc-v rv32i assembler (2+1 = 3 points)

The 32-bit RISC-V base integer instruction set (rv32i) does not support multiplication and division operations. To deal with this, a compiler may call a function when a multiplication is needed. For example, gcc expects that a function mulsi3(unsigned int a, unsigned int b) is provided to multiply two integers. A multiplication can be carried out by repeated additions and shifts:

unsigned int __mulsi3 (unsigned int a, unsigned int b)

{

unsigned int r = 0;

while (a) { if (a & 1) { r += b;

}

a >>= 1; b <<= 1;

} return r;

}

  1. Translate the above C code into equivalent RISC-V rv32i assembler code. Comment the assembler code to explain how the calculation proceeds. Note that the arguments are passed via the registers a0 (x10) and a1 (x11) and that the result is returned in a0 (x10).
  2. Does the function need function call prolog and epilog? Explain why or why not.

You are invited to use emulsiV to develop and test your assembler code.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] ICS Problem sheet 10[Solved] ICS Problem sheet 10
$25