
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Compile the RISC-V assembly code for the following C code.

Transcribed Image Text:int func (int a, int b, int c) {
if (a<=c)
return 4;
else if (a<b)
return 8
else
return a+c
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- Subject name: Microcomputer principle Application Determine the mode words for the following 8255 configuration: Mode 1, A-out, B-out, C-inarrow_forwardA, B are two integers arrays. The base address of A and B are in register x10 and x11, respectively. Register x10 holds number 8 and register x11 holds number 20. Variables i and j are in x12, and x13 respectively. The size of each array element is 4 bytes for both arrays A and B. Write the RISC-V assembly code for the following C statement (Use only true instructions). B[3*i-4]=A[16 *j-i] + 12;arrow_forwardFor the following C statement, write the corresponding RISC-V assembly code. Assume that the base addresses of long long int arrays A and B are in registers x6 and x7 respectively. Each element of A or B is 8 bytes, and the variables i and j are assigned to registers x5 and x10 respectively. j = B[A[i*2]] - 16;arrow_forward
- Using the following C code and assembly code answer the following; C: long int nothingGreater(long int num) { if (num > 240) { return 240 - num; } else { return num; } } Assembly: 0x00000000004004ed <+0>: push %rbp 0x00000000004004ee <+1>: mov %rsp,%rbp 0x00000000004004f1 <+4>: mov %rdi,-0x8(%rbp) 0x00000000004004f5 <+8>: cmpq $0xf0,-0x8(%rbp) 0x00000000004004fd <+16>: jle 0x40050a <nothingGreater+29> 0x00000000004004ff <+18>: mov $0xf0,%eax 0x0000000000400504 <+23>: sub -0x8(%rbp),%rax 0x0000000000400508 <+27>: jmp 0x40050e <nothingGreater+33> 0x000000000040050a <+29>: mov -0x8(%rbp),%rax 0x000000000040050e <+33>: pop %rbp 0x000000000040050f <+34>: retq The instruction mov $0xf0,%eax at address 0x4004ff puts a value into register %eax but there are no other references to %eax in the program. Which instruction makes use of this value? What is the address of the instruction (0x-prefixed hex)? What…arrow_forwardDescribe three categories of software architecture structures as presented in Chapter 1 of the textbookarrow_forwardThe portion of the generated assembly code implementing the C function int (int x, int y, int z) is as follows: Based on this assembly code, fill in the missing portions of the C code. Verify your answer using gcc compiler. Note: x in %edi, y in %esi, z in %edx.arrow_forward
- For the whole question, pseudo-instructions are not allowed except “j target_label”and “jr ra”. One suggestion for assembly programming problems is that you can includecomments to one or a block of instructions. Consider a RISC-V assembly function func1. func1 has three passingarguments stored in registers a0, a1 and a2, uses temporary registers t0-t3 andsaved registers s4–s10. func1 needs to call func2 and other functions may call func1also. func2 has two passing arguments stored in registers a0 and a1, respectively. Infunc1, after the program returns to func1 from func2, the code needs the originalvalues stored in registers t1 and a0 before it calls func2. (a) How many words are the stack frames of function func1?(b) Indicate which registers are stored on the stack of func1.arrow_forwardPlease answer the below images with a detailed solution and a full explanation. Answer the question like you are answering an engineer's question. For the coding questions, please use both Java and C++.arrow_forwardFor the following assembly code that is vaguely MIPS-like, trace itsexecution in both the R3000 and R4000 pipelines using a Gantt chart (ortable of some kind).LOAD R1, Memory(12340)LOAD R2, Memory(12350)ADD R3, R1, R2 // R3 = R1 + R2ADD R3, R3, R3 // R3 = R3 + R3STORE R3, Memory(12360)arrow_forward
- Provide the format and assembly language instruction for the following hex values Address 1001: 03arrow_forwardlibrary IEEE; use IEEE.STD_LOGIC_1164.ALL; entity GCC is Port ( systemClock, reset : in STD_LOGIC; state Output : out STD_LOGIC_VECTOR (4 downto 0)); end GCC; architecture Behavioral of GCC is component FreqDivider is Port (systemClock : in STD_LOGIC; slowClock : out STD_LOGIC); end component; signal nextState, presentState: std_logic_vector(5 downto 0) := "00000"; signal slowClock: std_logic; begin FDO: FreqDivider port map (systemClock => systemClock, slowClock => slowClock); process (slowClock, reset) begin if (reset = '1') then presentState end Behavioral;arrow_forwardFor pep/9 Name one use for each of the two addressing mode: immediate (i) addressing mode: stack-indexed-(sx)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY