RISC V- C with examples

txt

School

McMaster University *

*We aren’t endorsed by this school

Course

2GA3

Subject

Arts Humanities

Date

Oct 30, 2023

Type

txt

Pages

2

Uploaded by DoctorPower9486

Report
x5 – x7, x28 – x31: temporary registers - not preserved by the callee only save x1 and x10 at start when its non leaf/recursive procedure. addi sp sp -8 adjust stack for 2 items sw x1 4(sp) save return address sw x10 0(sp) save the argument n lw x10, 0(sp) #restore argument n lw x1, 4(sp) #restore return address if (i==j) f = g+h; else f = g-h; g,h,i,j... in x19, x20,...x23 bne x22, x23, Else add x19, x20, x21 // f = g + h beq x0, x0, Exit// unconditional Else:sub x19, x20, x21 // f = g −h Exit: while (save[i] == k) i += 1; •i in x22, k in x24, address of save in x25 Loop: slli x10, x22, 2 // x10 = i * 4 add x10, x10, x25 // x10 = address of save[i] lw x9, 0(x10) // x9 = save[i] bne x9, x24, Exit // go to Exit if save[i]!=k addi x22, x22, 1 // i = i+1 beq x0, x0, Loop Exit: .. temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; swap: slli x6, x11, 2 // reg x6 = k * 4 add x6, x10, x6 // reg x6 = v + (k * 4) lw x5, 0(x6) // reg x5 (temp) = v[k] lw x7, 4(x6) // reg x7 = v[k + 1] sw x7, 0(x6) // v[k] = reg x7 sw x5, 4(x6) // v[k+1] = reg x5 (temp)
jalr x0, 0(x1) // return to calling routine clear2(int *array, size_t int size){ int *p; for (p = &array[0]; p < &array[size]; p = p + 1) *p = 0; } addi x5, x10, 0 // p = address of array[0] loop2: sw x0, 0(x5) // Memory[p] = 0 addi x5, x5, 4 // p = p + 4 slli x6, x11, 2 // x6 = size * 4 add x7, x10, x6 // x7 = address of array[size] bltu x5, x7, loop2 // if (p<&array[size]) go to loop2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: 33) A star is observed to be having an absolute magnitude of -5.6 and is located at a distance of…
Q: Given u and v, find proj, u. u = [4, 6, 5] v = [0, -7, -6] proj, u = Ex: 1.234€, Ex: 1.234, Ex:…
Q: Insert: 73, 35, 68, 94, 26, 29, 16, 44, 38, 81, 59, 61 draw 2-3-4 tree showing each value inserted…
Q: Question 1 Question 2 Question 3 Question 4 Question 5 Question 6 Question 7 Question 8 Question 9…
Q: 9270- Rate PR interval Rhythm interpretation GRAPHIC CONTROLS CORPORATION Rhythm QRS interval…
Q: 1. The figure below shows the graph of f', the derivative of the function f, on the closed interval…
Q: If A = (a) √3x + 4x + then A-1 = (x, y) = ) = ( −1,1 = (¹1-3). Use this fact and the method of…
Q: √t 12. If a factory continuously dumps pollutants into a river at the rate of tons per day, then the…
Q: On an ECG, which of the following is generally produced from myocardial ischemia? Group of answer…
Q: Choose the correct linear equation for this graph. ·Ň 0 2
Q: Clinical exercise tests can be: Group of answer choices Submaximal or maximal   Measured with EKG…
Q: An object of mass 3.08 kg, moving with an initial velocity of 5.04  m/s, collides with and sticks to…
Q: Draw the major product of this reaction. Include stereochemistry if applicable. Ignore byproducts.
Q: Using disks or washers, find the volume of the solid obtained by rotating the region bounded by the…
Q: Your firm received an RFP (request for proposal) on a wire harness from GM with fixed costs of $1…
Q: Melanie Bolar (62) will use the single filing status. Her adjusted gross income during the year was…
Q: Write the equation of the line tangent to the graph of the function at the indicated point. As a…
Q: Porcupines have 34 chromosomes. If a specific porcupine has 5 heterozygous chromosomes, how many…
Q: Meaning behind the Goddess of Coatlicue
Q: The additive identity is 1. O True O False
Q: Problem 10.8 - A beam is built up from two standard rolled-steel mỹímýmỹmm mỹmmmmjumm mmg…
Q: Calculate the gravitational redshift of radiation of wavelength 550 nm that is emitted from a…