28 November 2011, 09:43 | #1 |
Registered User
Join Date: Nov 2010
Location: Grenoble, Isère, Rhône-Alpes, France, Europe, Earth
Posts: 293
|
Move it Move it... (68000)
I have a steam of data like that U0N0I0X0 and I want to transform it as faster as 68000 can do into UNIX (skip one byte data on two)
Here the code the string U0N0I0X0 is pointed by A0 and the move_xxx is called in a infernal loop between two time() in C langage to get the time taken by each function... move_optimized movem D0-D3/A1,-(SP) move.l A0,A1 move.l (A1)+,D0 ; move.l (A1)+,D1 ; U0N0 I0X0 lsr.w #8,D0 ; lsr.w #8,D1 ; U00N I00X clr.l D2 move.l D2,D3 move.w D0,D2 move.w D1,D3 clr.w D0 clr.w D1 ; U000 I000 000N 000X swap D1 ; U000 00I0 000N 000X swap D2 ; U000 00I0 0N00 000X or.l D1,D0 ; U0I0 00I0 0N00 000X or.l D2,D0 ; UNI0 00I0 0N00 000X or.l D3,D0 ; UNIX 00I0 0N00 000X move.l D0,(A0) movem (SP)+,D0-D3/A1 rts move_not_optimized movem D0-D3/A1,-(SP) move.b 0(A0),0(A0) move.b 2(A0),1(A0) move.b 4(A0),2(A0) move.b 6(A0),3(A0) movem (SP)+,D0-D3/A1 rts And... it's lame !! the move_not_optimized is faster |
28 November 2011, 09:51 | #2 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
|
Sounds like a job for MOVEP (unless you need it to run on ALL 680x0).
|
28 November 2011, 09:54 | #3 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
movep.l 0(a0),d0
move.l d0,(a0) should do the trick I think. Not tested. Edit: too slow again... Musashen was faster. |
28 November 2011, 10:01 | #4 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
|
|
28 November 2011, 12:00 | #5 |
Registered User
Join Date: Nov 2010
Location: Grenoble, Isère, Rhône-Alpes, France, Europe, Earth
Posts: 293
|
boiîing! movep is illegal on 68060... but I will try it for testing purpose on 68000 (thanks )
|
28 November 2011, 12:13 | #6 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
well, well: Anyway, the common 060 patchers (Oxypatcher etc.) make the movep instruction available, even on 060. Anyway, time to think about another solution w/o movep. |
|
28 November 2011, 15:09 | #7 |
Posts: n/a
|
Gilloo, as musashi5150 and StingRay mentioned this is task for MOVEP.
below you can find my 060 friendly routine (input text should be word/long aligned): Code:
lea data_in(PC),a0 lea data_out(PC),a1 move.l (A0)+,D0 ; U0N0 move.l D0,D2 lsl.l #8,D2 or.l D2,D0 move.l (A0)+,D1 ; I0X0 move.l D1,D3 lsl.l #8,D3 or.l D3,D1 swap.w D1 move.w D1,D0 move.l D0,(A1)+ even data_in dc.b 'U',0,'N',0,'I',0,'X',0 data_out dc.l 0 Last edited by CyprianK; 29 November 2011 at 13:05. |
29 November 2011, 17:02 | #8 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,030
|
Quote:
For your example, simple: move.b 2(A0),1(A0) ; 20c move.b 4(A0),2(A0) ; 20c move.b 6(A0),3(A0) ; 20c rts is one of the fastest (60 cycles for 68000) solution. Movep version need 24cycles + 12cycles, and extra 24 cycles, if all (D0 too) registers are preserved. Other versions has no big sense to use for this example, especially for 68000 CPU. |
|
29 November 2011, 19:17 | #9 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
|
Heartily agree and yes optimize for 68000 unless you intend to break new performance records on AGA 060
|
29 November 2011, 21:44 | #10 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
My approach ( a0 - start of data )
Code:
move.l a0,a1 ;4 (added after Don Adan post) move.w (a0)+,d0 ;8 move.b (a0),d0 ;8 move.l (a0)+,d1 ;12 move.b (a0),d1 ;8 movem.w d0-d1,-(a1) ;16 ;total 56 cycles Last edited by Asman; 02 December 2011 at 14:32. Reason: correction |
01 December 2011, 14:12 | #11 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,030
|
Quote:
movem.w D0-D2,-(A0) ; 20 c or subq.w #2,A0 ; 8c ? or move.l A0,A1 ; 4c .... movem.w D0-D1, (A1) ; 16c |
|
01 December 2011, 21:41 | #12 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Sorry Don Adan, I don't catch what you mean. For sure subq.l #2,a0 takes 8c. Please post full routine, thanks.
|
01 December 2011, 22:05 | #13 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,187
|
lea -2(a0),a0 would save a couple wouldn't it?
|
02 December 2011, 07:51 | #14 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
No, both instructions have the same cycle count. And since lea x(ax),ax is 2 bytes larger than subq #x,ax, it's best to use that one here.
|
02 December 2011, 12:55 | #15 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,030
|
Quote:
Code:
move.w (a0)+,d0 ;8 move.b (a0),d0 ;8 move.l (a0)+,d1 ;12 move.b (a0),d1 ;8 subq.w #2,A0 ; 8c movem.w d0-d1,-(a0) ;16 ;total 60 cycles Code:
move.l A0,A1 ; 4c move.w (a0)+,d0 ;8 move.b (a0),d0 ;8 move.l (a0)+,d1 ;12 move.b (a0),d1 ;8 movem.w d0-d1,(a1) ;16 ;total 56 cycles |
|
02 December 2011, 12:59 | #16 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,030
|
|
02 December 2011, 13:30 | #17 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
According to the Motorola 68000 User Manual: addq.w #x,Ax == 4 cycles, addq.l #x,Ax == 8 cycles
For the #x,(Ax) variant you need to add the effective address calc time on top of that which is another 4 cycles for word sized operations or 8 cycles for longword sized operations. |
02 December 2011, 14:33 | #18 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
@Don Adan
Right. I edited my original post. Thank you. |
04 December 2011, 15:38 | #19 | |
Registered User
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
|
Quote:
You quoted a known mistake in the 68k user manual. In reality addq.w,Ax == 8 cycles, addq.l #x,Ax == 8 cycles We already discussed the issue: http://eab.abime.net/showthread.php?...ghlight=addq.w Last edited by TheDarkCoder; 04 December 2011 at 15:40. Reason: added link to previous discussion |
|
04 December 2011, 17:36 | #20 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
LOL
I'm just too trusting in the documentation Thanks for reminding me! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Move Em | amigapd | request.Old Rare Games | 1 | 13 March 2011 02:22 |
[68000 ASM] Move memory to memory | AmigaBoy | Coders. General | 7 | 08 December 2009 08:16 |
How to move files from PC with Catweasel ? | zimgr5 | support.Hardware | 2 | 20 February 2009 11:21 |
Please delete or move if necessary | JSemple3 | support.Games | 7 | 30 June 2003 13:59 |
|
|