mirror of
https://github.com/Comp211-SP24/lab-05-Rushilwiz.git
synced 2025-04-18 19:00:17 -04:00
fixed task0
This commit is contained in:
parent
d9520b92df
commit
d30900c18a
4
memory.c
4
memory.c
|
@ -16,10 +16,10 @@ unsigned int addr_bits;
|
||||||
|
|
||||||
int number_of_blocks(unsigned int addr_bits,
|
int number_of_blocks(unsigned int addr_bits,
|
||||||
unsigned int num_block_offset_bits) {
|
unsigned int num_block_offset_bits) {
|
||||||
if (addr_bits < num_block_offset_bits || num_block_offset_bits < 0 || addr_bits < 0)
|
if (addr_bits < num_block_offset_bits || num_block_offset_bits <= 0 || addr_bits <= 0)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
return addr_bits / exp2(num_block_offset_bits);
|
return exp2(addr_bits - num_block_offset_bits);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user