15 May 2021, 15:44 | #101 | ||||
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Quote:
Quote:
Quote:
|
||||
15 May 2021, 15:50 | #102 |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
|
15 May 2021, 18:34 | #103 | |||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 787
|
Quote:
Quote:
Code:
lsr.l d5 move -(a3),d0 ;r[i] mulu d1,d0 ;r[i]*10000 add.l d0,d5 ;d += d + r[i]*10000 move.l d5,d6 Quote:
Last edited by saimo; 15 May 2021 at 19:14. |
|||
15 May 2021, 19:10 | #104 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
You can use next optimisations:
Code:
lea cv(pc),a0 ; add cv(pc),d5 ;c + d/10000 add.w (A0),D5 ; swap d5 ;c <- d%10000 ; move d5,cv move.l D5,(A0)+ ; A0 is buf now ; clr d5 ; swap d5 and.l #$0000FFFF,D5 ; or ext.l D5, if D5.W cant be minus value ; bsr PR0000 bsr.w PR0001 endif sub.w #14,d6 ;kv bne .l0 PR0000 ;prints d5, uses a0,a1(scratch),d0,d1,d2,d3 lea.l buf(pc),a0 PR0001 move.l a0,d2 bsr.s .l1 moveq #4,d3 move.l cout(pc),d1 jmp Write(a6) ;call Write(stdout,buff,size) .l1 divu #1000,d5 bsr .l0 clr d5 swap d5 divu #100,d5 bsr .l0 clr d5 swap d5 divu #10,d5 bsr .l0 swap d5 .l0 eori.b #'0',d5 move.b d5,(a0)+ rts ; cv dc.w 0 time dc.l 0 cout dc.l 0 cnop 0,4 ; for fastest longword write cv dc.l 0 buf ds.b 4 |
15 May 2021, 19:31 | #105 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
btw. you can remove from source code
; clr cv is not necessary. |
16 May 2021, 11:27 | #106 | ||
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Quote:
The mulu-variant is only useful for the 68000 and maybe 68060. I doubt about the latter. I checked it and found out that your code became 4 bytes longer. And any speed optimization outside the main loop is senseless unless you find a way to save hundreds cycles. Thank you. This gives us 9280 digits for the Amiga 1200 variant! |
||
16 May 2021, 14:27 | #107 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Code:
lea cv(pc),a0 4 bytes opt ; add cv(pc),d5 ;c + d/10000 4 bytes ori add.w (A0),D5 2 bytes opt ; swap d5 ;c <- d%10000 2 bytes ori ; move d5,cv 6 bytes ori move.l D5,(A0)+ ; A0 is buf now 2 bytes opt ; clr d5 2 bytes ori ; swap d5 2 bytes ori and.l #$0000FFFF,D5 ; or ext.l D5, if D5.W cant be minus value 6 bytes or 2 bytes opt original code 16 bytes, optimised code 10 or 14 bytes max ; cv dc.w 0 time dc.l 0 cout dc.l 0 cnop 0,4 ; for fastest longword write cv dc.l 0 buf ds.b 4 And you wrote that speed is important, not size. When i asked. |
16 May 2021, 15:12 | #108 | ||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 787
|
Quote:
Quote:
|
||
16 May 2021, 17:42 | #109 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Anyway, if you need only shortest code, you can use:
Code:
lea cv(PC),A0 add.w (A0),D5 move.l D5,(A0) ext.l D5 ; or "and.l #$0000FFFF,D5" bsr PR0000 time dc.l 0 cout dc.l 0 cv dc.w 0 buf ds.b 4 |
17 May 2021, 07:34 | #110 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
You can use next version too, shortest next 2 bytes.
Code:
clr.l -(SP) ; cv .l0 .... add.w (SP),D5 ; cv move.l D5,(SP) ; cv ext.l D5 ; or "and.l #$0000FFFF,D5" bsr PR0000 endif sub.w #14,d6 ;kv bne .l0 addq.l #4,SP time dc.l 0 cout dc.l 0 ; cv dc.w 0 buf ds.b 4 |
17 May 2021, 10:51 | #111 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
IMHO such things must be hardwired and instant. Sorry, you are wrong about this. Just look at the next figure from the official manual. Last edited by BippyM; 01 June 2021 at 18:24. |
|
17 May 2021, 10:59 | #112 |
Registered User
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 818
|
|
17 May 2021, 12:47 | #113 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Maybe this is only small optimisation compared to current PR0000 routine, which is very slow and wasted many CPU cycles. I think that you can wrote much fastest version of this routine. And you can learn something more about 68k coding.
BTW. Small hint for you, use sub.w. |
17 May 2021, 14:26 | #114 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
Quote:
But to be fair here, that notation did catch me off guard a couple of times as well when I first started doing 68000 code. It took a little while for that to click. I guess it was because I was used to the 6502, which doesn't use this notation at all. So for anyone else who, like me, might misread this: as long as you remember that EA means Effective Address, it'll all be fine. |
|
18 May 2021, 18:56 | #115 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
It seems that the code for the 68k pi-spigot variant has become almost perfect. Thanks a million to everybody. However I must list our major achievements:
1) a/b helped to find out the BVS optimization, it saves us 2 cycles; 2) modrobert discovered the MULU optimization advantage, this saves 4 cycles on the 68020 - it will be also interesting to run pi-mulu and pi-opt on the 68030 hardware to get exact number of saved cycles - http://eab.abime.net/showpost.php?p=...2&postcount=92 ; 3) saimo could get an almost impossible thing and save 2 cycles in the main loop; 4) Don_Adan helped to minimize the size of the code; 5) Thomas Richter provided some pieces of interesting information. I have prepared maybe the last code for this thread. It helps clarify whether 68020/30 depends on alignment of an instruction after a jump. Please run pi-align and pi-na for me for 3000 digits on the 68020/30 hardware. These programs print only timings after about 30s of calculation. Quote:
I am curious what kind of game have you told about? BTW do you know about my project http://aminet.net/package/game/misc/xlife-8 ? Last edited by BippyM; 01 June 2021 at 18:24. |
|
18 May 2021, 20:02 | #116 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Last edited by litwr; 18 May 2021 at 20:32. |
|
18 May 2021, 20:19 | #117 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Write code works in loop too. You can check this version. If no my bugs can be fastest more than 100 cycles.
Code:
clr.l -(SP) ; cv .l0 .... add.w (SP),D5 ; cv move.l D5,(SP) ; cv bsr PR0000 endif sub.w #14,d6 ;kv bne .l0 addq.l #4,SP ; restore stack ..... PR0000 ;prints d5, uses a0,a1(scratch),d0,d1,d2,d3 lea $100.W,A0 move.l #$30403030,D2 move.w #1000,D3 b1000 sub.w D3,D5 bcs.b n100 add.w A0,D2 bra.b b1000 n100 add.w D3,D5 moveq #100,D3 b100 sub.w D3,D5 bcs.b n10 addq.b #1,D2 bra.b b100 n10 add.w D3,D5 swap D2 moveq #10,D3 b10 sub.w D3,D5 bcs.b n1 add.w A0,D2 bra.b b10 n1 add.b D5,D2 lea cout(PC),A0 move.l (A0)+,D1 move.l D2,(A0) move.l A0,D2 ; buf moveq #4,D3 jmp Write(A6) ;call Write(stdout,buff,size) time dc.l 0 cout dc.l 0 buf dc.l 0 |
18 May 2021, 21:53 | #118 | ||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 787
|
Quote:
It's a minor game _not_ written in assembly, but in AMOS Professional (the fun is precisely to make a game that implements original effects that would have been unthinkable before in such a language). Basically, all that's left to do is the music - I have the base ready, but I'm rather uninspired lately It's called Follix, and you can see the last (and a bit outdated) preview in this video: [ Show youtube player ]. (For completeness, I've had also the update of this 100% assembly game in the works since a very long time, and I'm stuck because there's one last tiny showstopper that happens only on a very specific machine, the one betatester of mine that could run tests for me isn't able to help me at the moment and I couldn't find someone else with an appropriate machine.) Quote:
|
||
18 May 2021, 23:14 | #119 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 775
|
Quote:
Code:
> pi-align number pi calculator v12 (68020) number of digits (up to 9280)? 3000 30.74 Code:
> pi-na number pi calculator v12 (68020) number of digits (up to 9280)? 3000 30.50 Last edited by modrobert; 18 May 2021 at 23:23. |
|
19 May 2021, 01:02 | #120 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,546
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
68020 Bit Field Instructions | mcgeezer | Coders. Asm / Hardware | 9 | 27 October 2023 23:21 |
68060 64-bit integer math | BSzili | Coders. Asm / Hardware | 7 | 25 January 2021 21:18 |
Discovery: Math | Audio Snow | request.Old Rare Games | 30 | 20 August 2018 12:17 |
Math apps | mtb | support.Apps | 1 | 08 September 2002 18:59 |
|
|