09 June 2017, 18:15 | #1 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
68040 memory access
Most 68k CPUs are faster when using a PC relative addressing mode to access memory, instead of an absolute 32bit address. Is it also true for the 68040? I heard it is different in this aspect. Can somebody confirm?
|
09 June 2017, 21:00 | #2 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
jmp (d16,PC) 1) sign extend d16 to d32 2) PC = PC + d32 jmp (xxx).W 1) sign extend (xxx).W to (xxx).L 2) PC = (xxx).L jmp (xxx).L 1) PC = (xxx).L It looks like the 68040 is able to do the sign extension for free in the case of (xxx).W vs (xxx).L as there is no timing difference (sign extension is a cheap operation). The EA calc cost of (d16,PC) is 3 cycles where (xxx).W and (xxx).L are 1 cycle. With no penalty for fetching the longer instructions, the 68040 is often faster using absolute addressing. An exception is the Bcc instruction which implicitly uses PC relative addressing and appears to have optimizations which make it faster than using (d16,PC). There can be an ICache performance penalty to larger instructions so the shorter code is usually preferable. Highly optimized 68040 specific code can can be quite large and you would probably want to look up timings in the MC68040UM. |
|
09 June 2017, 21:06 | #3 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,038
|
Yeah, PC relative modes are slower on 040 (slower EA calc stage). Assuming extra code size due to absolute EAs won't screw up the cache.
Here are some speed test results I did on my A4000/040 long time ago (1000 repeats, code/raster_time/avg_cycles), not many PC relatives but it shows that absolute addressing is as fast as it gets: Code:
lea (a0),a1 ; 1112 1 lea (d.w,a0),a1 ; 2391 2 lea (d.b,a0,d0.*),a1 ; 4954 4 lea (d.w,pc),a0 ; 4954 4 lea (d.b,pc,d0.*),a0 ; 6232 5 lea ($1234).w,a0 ; 1112 1 lea ($12345678),a0 ; 1112 1 move. d0,d1 ; 1112 1 move. a0,d0 ; 1112 1 move. (a0),d0 ; 1112 1 move. (d.w,a0),d0 ; 1112 1 move. #,d0 ; 1112 1 move. ($12345678),d0 ; 1159 1 move. d0,($12345678) ; 1141 1 movea.w d0,a0 ; 3528 3 movea.l d0,a0 ; 1767 1.5 movea. a0,a1 ; 1112 1 movea. a0,($12345678) ; 1141 1 movea.w (a0),a1 ; 3533 3 movea.l (a0),a1 ; 2254 2 movea. #,a0 ; 1112 1 |
10 June 2017, 17:41 | #4 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Thanks all! The bad performance with PC-relative modes is really surprising.
And the 060 changed that again? So PC-relative modes have at least no disadvantage there? |
10 June 2017, 18:32 | #5 | ||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Quote:
|
||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
illegal memory access not working | jotd | support.WinUAE | 7 | 07 July 2019 21:23 |
memory access speed question | Lord Riton | Coders. General | 42 | 27 February 2019 14:26 |
Break on Memory Access? | Khyron | support.WinUAE | 3 | 21 August 2010 00:10 |
access emulated memory | ara | support.WinUAE | 6 | 03 April 2010 13:05 |
WTB: 4M Zip RAM / Memory for 68040 board | Photon | MarketPlace | 4 | 14 November 2008 22:07 |
|
|