views:

133

answers:

1

i have this question:

in 80486 computer what is the worst case (include the FETCH) number of memory access of the instruction:

add dword [x],0x123FA4

if it known that an opcode with no operands is 2 byte len

+4  A: 

From memory, the instruction has an opcode byte ("add"), an address mode byte, an offset for x (4 bytes) and the constant (4 bytes) ==> 10 bytes. I assume the 486 fetches 4 bytes at a time from memory with a bus address aligned to 4 byte DWORD boundaries. So 10 bytes arguably takes 3 memory reads (= 10/4 rounded up) no matter where you place them. Howevever, if the opcode byte is place in the last byte of a DWORD, the remaining 9 bytes span 3 more DWORDS to the total number of reads can actually be 4.

To do the add, the location X must be fetched. Assume X is split across a DWORD boundary -> 2 reads. Adding the constant happens inside the CPU, and the sum is written back across that same DWORD boundary split --> 2 writes.

So, the worst case should be 8 memory operations.

Ira Baxter