Question

In: Computer Science

1.a. RISC-V has several addressing modes. Describe 4 addressing modes. For each, describe what it does...

1.a. RISC-V has several addressing modes. Describe 4 addressing modes. For each, describe what it does and give an example assembly instruction that uses that addressing mode. b. Starting with a C source code file, describe the steps that must occur in order to actually begin executing the program on your computer.

Solutions

Expert Solution

1.a) RISC V - reduced instruction set computer principles based open standard instruction set architecture. It is an open source licensed design. RISC follows a load-store architecture. It has the bit patterns used to simplify the multiplexers in CPU. RISC V has 32 integer registers and have 32 floating point registers. It is designed to increase computer speed, and reduces cost and power usage. Memory is addressed as 8 bit bytes. it is the minimal set of instructions which leads to many lines of code.

In RISC V there are several addressing modes. The addressing mode defines the way to specify an operand in assembly language program. The four basic addressing modes are:

1. Register

Operand is in a register. It can be direct or indirect

eg: Add R1,R2 which means R1 is added with R2 and result is stored in R1.(direct)

ADD R1,(R2) means R1<---- R1+memory(R2)

add $s1, $s2, $s3 $s1 = $s2+$s3

2. Immediate

Operand is specified in the instruction itself. constants are encoded in the instruction itself.

Add R2, #5 , R2 is added with direct value 5 and result is stored in R2.

eg: addi $ s1, $s2, 10 $s1= $s2 + 10

3. Displacement

Operand is in memory and it is calculated as Base + Offset.

Add R3, 100(R2), R3 <--- R3 + memory(100+R2)

eg: load word, lw $s1, 100($s2) $s1= memory (100+$s2)

4. PC-Relative

Operand is in memory and the address is calculated as PC + Offset . It is used for branch instructions

branch R2 <R1,1500

beq $s1 , $s2, 25   If ($s1== $s2) then goto PC + 4 + 100

1.b) A program is written in a language , and it is saved using its extension then it becomes a source code file .It is executed by the system only, when it is converted into an object code which follows a number of steps and linked with library to form an executable file. C program is a high level language which is converted into machine language for execution.

A program written in C language is saved .c extension. It is the source code and it is compiled to check if there any errors and also it is converted into an object file. Then this object file is linked with library functions to form an .exe file which is executable.

Eg: set.c (source file/code)---------> set.obj (object file/code) --------------> set.exe (executable file)

There are four steps when a program is converted to an executable file ,they are

1. preprocessing

* comments are removed

* macros and include files are expanded

* conditional compilation

stored as intermediate file , set.c becomes set.i

2. compilation

set.i (preprocessed file ) becomes set.s(intermediate compiled output file) which contains assembly level instructions.

3. assembly

set.s becomes set.o by the assembler which contains machine level instructions. this is the object code which contains only the existing code

4. linking

set.o becomes set.exe which contains all the linked functions and libraries.


Related Solutions

Describe the indirect indexed addressing modes of CPU12. Illustrate with detailed examples of all addressing modes....
Describe the indirect indexed addressing modes of CPU12. Illustrate with detailed examples of all addressing modes. In the response space, give two paragraphs: 1- An Explanation: complete this part in the answer section 2- An example: complete this part in the answer section
Run the following RISC-V codes separately and explain what each code does and how you interpret...
Run the following RISC-V codes separately and explain what each code does and how you interpret the register results: Code 1. addi x3, x3, 1 slli x3, x3, 62 addi x4, x4, 7 mul x5, x4, x3 mulh x6, x4, x3 Code 2. addi x3, x3, 1 slli x3, x3, 63 addi x4, x4, 1 mul x5, x4, x3 mulhsu x6, x4, x3 Code 3. addi x3, x3, 1 slli x3, x3, 63 addi x4, x4, 1 mul x5, x4,...
What does the RISC-V code below do? Write the C equivalent. Assume that i is in...
What does the RISC-V code below do? Write the C equivalent. Assume that i is in register x5 and that the base address of array A that holds doubleword integers is in x20. addi x5, x0, 0 addi x6, x0, 50 addi x28, x20, 0 loop: bge x5, x6, end ld x7, 0(x28) bge x7, x0, next sub x7, x0, x7 sd x7, 0(x28) next: addi x5, x5, 1 addi x28, x28, 8 jal x0, loop end: Can you rewrite...
4 – The following 32-bit binary word written in hexadecimal format represents a single RISC-V assembly...
4 – The following 32-bit binary word written in hexadecimal format represents a single RISC-V assembly instruction. What is the RISC-V instruction format and specific assembly language instruction? 0x00156A33
1. Which Interrupt Has The Highest Priority? 2. Name 5 Different Addressing Modes? 3. How Many...
1. Which Interrupt Has The Highest Priority? 2. Name 5 Different Addressing Modes? 3. How Many Interrupts Are There In 8085? 4. In 8085 Which Is Called As High Order / Low Order Register? 5. What Are Input & Output Devices?
3. What are the seven modes of entry into foreign markets? Briefly describe each.
3. What are the seven modes of entry into foreign markets? Briefly describe each.
1. For the following C statement, write the corresponding RISC-V assembly code. Assume that the C...
1. For the following C statement, write the corresponding RISC-V assembly code. Assume that the C variables a, b, and c, have already been placed in registers x10, x11, and x12 respectively. Use a minimal number of RISC-V assembly instructions. a = b + (c − 2); 2. Write a single C statement that corresponds to the two RISC-V assembly instructions below. add e, f, g add e, h, e 3. Assume that registers x5 and x6 hold the values...
what are the different addressing modes used in unconditional branch/ jump instructions? Illustrate how the new...
what are the different addressing modes used in unconditional branch/ jump instructions? Illustrate how the new program counter value is calculated in each case.
There are 3 forms of Program Memory Addressing Modes: Direct, Relative and Indirect. Explain/Illustrate what happens...
There are 3 forms of Program Memory Addressing Modes: Direct, Relative and Indirect. Explain/Illustrate what happens to CS and IP registers if the JMP THERE instruction is stored at memory address 10000H (CS=1000H, IP=0000H) and the address of THERE is: (A) 10020H (B) 30000H
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main()...
Please convert the following C program into the RISC-V assembly code 1) #include <stdio.h> int main() { int i = 2, j = 2 + i, k; k = i * j; printf("%d\n", k + j); return 0; } 2) #include <stdio.h> int main() { int i = 2, j = 2 + i, k = j / 2; if (k == 1) { printf("%d\n", j) k = k * 2; if ( k == j) { printf("%d\n|, j); }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT