Name: Date:
HW8
-
(20 points) Below is a snippet from a Checkers game program in C.
void setKing(int row, int col, int isKing) { int* rowAddr = getRowAddr(row); //returns the memory address of row rowAddr[col] = isKing; }
Fill in the missing portions of the
setKing
function below, adhering to the RISC-V procedure call conventions. You should assumesetKing
is called according to RISC-V convention. Do not implement getRowAddr, assume it is already implemented following the conventions. You are encouraged to use register names (e.g. t0) instead of register ids (e.g. x5) in this code.setKing: #entry point to setKing procedure
jal ra, getRowAddr #call to getRowAddr
jalr x0, 0(ra) #return form setKing