English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 28 November 2011, 09:43   #1
Gilloo
Registered User
 
Join Date: Nov 2010
Location: Grenoble, Isère, Rhône-Alpes, France, Europe, Earth
Posts: 287
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
Gilloo is online now  
Old 28 November 2011, 09:51   #2
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
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).
musashi5150 is offline  
Old 28 November 2011, 09:54   #3
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
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.
StingRay is offline  
Old 28 November 2011, 10:01   #4
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
Quote:
Originally Posted by StingRay View Post
Edit: too slow again... Musashen was faster.
Muhahaha! But we'll call it even as you wrote some code too
musashi5150 is offline  
Old 28 November 2011, 12:00   #5
Gilloo
Registered User
 
Join Date: Nov 2010
Location: Grenoble, Isère, Rhône-Alpes, France, Europe, Earth
Posts: 287
boiîing! movep is illegal on 68060... but I will try it for testing purpose on 68000 (thanks )
Gilloo is online now  
Old 28 November 2011, 12:13   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Gilloo View Post
boiîing! movep is illegal on 68060... but I will try it for testing purpose on 68000 (thanks )

well, well:

Quote:
Originally Posted by Gilloo View Post
I have a steam of data like that U0N0I0X0 and I want to transform it as faster as 68000 can do
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.
StingRay is offline  
Old 28 November 2011, 15:09   #7
CyprianK
 
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.
 
Old 29 November 2011, 17:02   #8
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by Gilloo View Post
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

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.
Don_Adan is offline  
Old 29 November 2011, 19:17   #9
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Quote:
Originally Posted by StingRay View Post
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.
Heartily agree and yes optimize for 68000 unless you intend to break new performance records on AGA 060
Photon is offline  
Old 29 November 2011, 21:44   #10
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
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
Asman is offline  
Old 01 December 2011, 14:12   #11
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by Asman View Post
My approach ( a0 - start of data )
Code:
    move.w    (a0)+,d0    ;8
    move.b    (a0),d0        ;8
    move.l    (a0)+,d1    ;12
    move.b    (a0),d1        ;8
    movem.w    d0-d1,-(a0)    ;16
                ;total 52 cycles
Perhaps
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
Don_Adan is offline  
Old 01 December 2011, 21:41   #12
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Sorry Don Adan, I don't catch what you mean. For sure subq.l #2,a0 takes 8c. Please post full routine, thanks.
Asman is offline  
Old 01 December 2011, 22:05   #13
Codetapper
2 contact me: email only!
 
Codetapper's Avatar
 
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
lea -2(a0),a0 would save a couple wouldn't it?
Codetapper is offline  
Old 02 December 2011, 07:51   #14
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
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.
StingRay is offline  
Old 02 December 2011, 12:55   #15
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by Asman View Post
Sorry Don Adan, I don't catch what you mean. For sure subq.l #2,a0 takes 8c. Please post full routine, thanks.
Simple, you change A0, 6 bytes forward by "+" commands, but only 4 bytes back by "-" command :

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
Don_Adan is offline  
Old 02 December 2011, 12:59   #16
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,960
Quote:
Originally Posted by StingRay View Post
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.
Do you know how many cycles used addq,w #x,Ax? 4c or 8c?
Of course for 68000.
Don_Adan is offline  
Old 02 December 2011, 13:30   #17
pmc
gone
 
pmc's Avatar
 
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.
pmc is offline  
Old 02 December 2011, 14:33   #18
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@Don Adan
Right. I edited my original post. Thank you.
Asman is offline  
Old 04 December 2011, 15:38   #19
TheDarkCoder
Registered User
 
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
Quote:
Originally Posted by pmc View Post
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.
pmc, you should stop believing in manuals!

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
TheDarkCoder is offline  
Old 04 December 2011, 17:36   #20
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
LOL

I'm just too trusting in the documentation

Thanks for reminding me!
pmc is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.29167 seconds with 13 queries