Consider a main memory of 8K bytes and cache memory of 2k words. If associative mapping is used, then the size of each word of cache memory is
In associative mapping, each word in the cache must store both the data and its address (tag).
Therefore, the size of each word in the cache memory is equal to the number of bits required to address the main memory.
We know:
1K = 1024 bytes = 2^10 bytes
1byte = 8 bits = 2^3 bits
Main memory size in bytes = 8K bytes = 8 x 1K bytes
= 8 x 1024 bytes
= 2^3 x 2^10 bytes
= 2^13 bytes
Main memory size in bits = 2^13 x 8
= 2^13 x 2^3
= 2^16 bits
The size of each word of cache memory is 16 bits.
If a byte is used as a storage unit, number 5 and character 5 in assembly language are stored as:
Number 5: The decimal number 5 directly translates to the binary representation 00000101B when stored in a byte.
Character '5': If stored as an ASCII character, it would be represented as 00110101B, which is the binary equivalent of the ASCII code 53 (in decimal)
Video on Alphanumeric Codes - ASCII
Video on Base Conversions
Let f be a Boolean expression in 8 variables which has true value exactly for 4 combinations out of 2^8 possible combinations. Then f can be expressed as sum of ____ minterms.
A minterm is a product term that contains all the variables, either complemented or uncomplemented.
The sum-of-minterms expression of a Boolean function is the OR of all the minterms for which the function is true.
The function is true for 4 combinations. Each true combination corresponds to one minterm. Therefore, the function can be expressed as the sum of 4 minterms
Using 16’s complement method of subtraction compute (CB2)H – (972)H
Base H means hexadecimal number.
16's complement can be computed in 2 ways.
Here, we will compute using: 15's complement + 1
Therefore, 16's complement of a hexadecimal number is obtained by adding 1 to its 15's complement.
To learn about subtraction using complements, please refer to my video below:
Let's take CB2 as minuend and 972 as subtrahend.
Subtraction using 16's complement = Minuend + 16's complement of Subtrahend
If there is an end carry after addition, discard the carry.
Let's compute 16's complement of subtrahend:
16's complement of 972 = 15's complement of 972 + 1
15's complement is obtained by subtracting each digit of the number from F.
For calculation sake, we will use 15 instead of F.
0-9 of decimal are represented as 0-9 in hexadecimal, but from 10 to 15 we have to use A-F.
From the above calculation, we obtained 15's complement of 972 as 68E.
Subtraction = CB2 + 16's complement of 972
= CB2 + 68E
2+14 = 16, but in hexadecimal 16 is represented as 10, so we keep the zero and take 1 to the carry.
11+ 8 + the carry 1 = 20, 20 is represented as 14, so we keep the four and take 1 to the carry.
12 + 6 + the carry 1 = 19, 19 is represented as 13, so we keep the three and take 1 to the carry.
When we use subtraction using 16's complement we have to discard the end carry, so we don't the carry.
We have the answer as (340)H
CB2H - 972H = CB2H + 68EH = 340H
How many memory accesses require the following instructions?
ADD r1, r2, r3
ADD r1, r2, (r3)
ADD r1, r2, @r3
Suppose every instruction is one word long, as well as every address.
ADD r1, r2, r3 require only one memory access, reading the instruction;
ADD r1, r2, (r3) require two memory accesses, the first to read the instruction and the other one to read the value from memory location(s), whose address is in r3;
ADD r1, r2, @(r3) three memory accesses are made in this case, the first to read the instruction, the second to get M[r3], and the third one to get M[M[r3]].
(since r1,r2,r3 are all registers, no memory access is needed to retrieve operands)
Explanation:
ADD r1, r2, r3 means: r1 <--- r2 + r3 (used when a value is in a register)
ADD r1, r2, 1 means: r1 <--- r2 + 1 (used when a constant is needed)
ADD r1, r2, (r3) means: r1 <--- r2 + M[r3] (the register r3 contains the address of a memory location)
ADD r1, r2, @r3 means: r1 <--- r2 + M[M[r3]] (used in pointer addressing; if r3 contains the address of a pointer p, then M[M[r3]] yields *p )
How many memory access required for the following instructions
add R1,R2,r3add r4,r5,(r6)
Sub R2,R1(r3)
As per the previous question,
add r1,r2,r3 requires one memory access
add r4,r5,(r6) requires two memory access
sub r2,r2,(r3) requires two memory access, totally = 5 memory accesses.
But the official answer given for this question is 6:
If the answer has to be 6, then the question should be modified as:
third instruction could be sub r2,r1, @(r3)
OR
second instruction could be add r4, r5, @(r6)
OR
first instruction could be add r1, r2, (r3)
Comments
Post a Comment