View Single Post
Old 27 May 2021, 09:41   #4
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,423
Yes, d16(An) is more compact than specifying a 32 bit address and that is why it's faster.

It all has to do with how instructions are encoded by the 68000 (and up). The 68000 series uses single words for instructions, with optionally one or more extension words. This means that the move instruction (in it's many, many forms) is encoded as a word for the base instruction and optionally one or more extra words for any extra information needed. Each word the 68000 fetches from memory adds at least 4 cycles* to the cost of the instructions (and, obviously, 2 bytes to the program size).

In case of a d16(An), the d16 does not fit in the first word along with the move instruction because it can be 16 full bits on it's own, so it's put in a separate word. The same goes for a xxx.L: those 32 full bits can't be put alongside the instruction in the first word, so have to be stored separately. The result is that move.w d0,xxx.L takes up 3 words in memory and move.w d0,d16(An) takes up 2. Meanwhile, a simpler instruction like move.w d0,d0 only requires the word for the instruction itself and so takes up only 1 word in memory.

*) To be a bit more precise, it adds 4 cycles for each word fetched for the instruction, plus whatever amount of cycles is needed to get/store the required data in memory. So a move.w d0,d0 has no extension words and needs just 4 cycles (to read the single instruction word), while a move.w d0,(a0) also has no extension words but takes 8 cycles: 4 cycles to read the instruction word and 4 cycles to store d0 to the address pointed to by a0.

It can get a bit more complicated with other addressing modes and more complication instructions such as multiply/divide and shift. It also changes quite a bit with processors above the 68010. But '4 cycles per word accessed in memory' is the base rule for the 68000/010.

Last edited by roondar; 27 May 2021 at 10:14.
roondar is offline  
 
Page generated in 0.07510 seconds with 11 queries