Question: How would I do this? 1.1 Integer Division Write RISC-V code to implement this function: int intdiv(int numer, int denom); This will return the largest
How would I do this?
1.1 Integer Division Write RISC-V code to implement this function: int intdiv(int numer, int denom); This will return the largest integer r such that r x denom 0 and that denom > 0. If either of these conditions is not true, then "crash. Here's hacky way to force a "crash in the interpreter: crash: beq x0, x0, 1 This represents a misaligned branch offset and will cause the interpreter to stop and display an error. So to cause a crash, branch or jump to the label crash. Use the pattern of the two parameters, one local variable as a framework for your function. Use only the a0 and al registers during your computation, and put the result of the division in the al register. Load a variable from memory (from the stack) before you modify it, and save it back to memory after you modify it, as is shown in the example code we looked at in class. This means that local variables must have stack space. Function parameters don't need to go in memory: pass the first function parameter through ao and the second parameter through al. 1.1 Integer Division Write RISC-V code to implement this function: int intdiv(int numer, int denom); This will return the largest integer r such that r x denom 0 and that denom > 0. If either of these conditions is not true, then "crash. Here's hacky way to force a "crash in the interpreter: crash: beq x0, x0, 1 This represents a misaligned branch offset and will cause the interpreter to stop and display an error. So to cause a crash, branch or jump to the label crash. Use the pattern of the two parameters, one local variable as a framework for your function. Use only the a0 and al registers during your computation, and put the result of the division in the al register. Load a variable from memory (from the stack) before you modify it, and save it back to memory after you modify it, as is shown in the example code we looked at in class. This means that local variables must have stack space. Function parameters don't need to go in memory: pass the first function parameter through ao and the second parameter through al