Nios/cacheset2

From ASMBits

Consider the following cache:

  • 2S sets
  • 2B block size

Write a function that will determine whether two addresses will map to the same cache set in this cache. Your function will be provided S, B, and two addresses. It must return 1 or 0 to indicate whether the two addresses map to the same cache set. S and B will be valid values for a 32-bit address.

int cacheset(unsigned int S, unsigned int B, unsigned int addr1, unsigned int addr2);

Expected solution length: Around 10 lines.

Sample Input

cacheblock(8, 4, 0, 2) (256 sets, 16-byte blocks, addresses 0 and 2)

Sample Output

r2=1

Case 13 and 14: The shift instructions cannot shift by 32.

Write your solution here

x
 
1
.global _start
2
_start:
3
    movi r4, 8
4
    movi r5, 4
5
    movia r6, 0
6
    movia r7, 2
7
    call cacheset
8
1:  br 1b    # Done
9
10
cacheset:
11
    
12
    
Upload a source file...