![]() |
![]() |
#101 | ||||
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Quote:
![]() Quote:
![]() Quote:
![]() |
||||
![]() |
![]() |
#102 |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
|
![]() |
![]() |
#103 | |||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 854
|
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. |
|||
![]() |
![]() |
#104 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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 |
![]() |
![]() |
#105 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
btw. you can remove from source code
; clr cv is not necessary. |
![]() |
![]() |
#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. ![]() Thank you. This gives us 9280 digits for the Amiga 1200 variant! |
||
![]() |
![]() |
#107 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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. |
![]() |
![]() |
#108 | ||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 854
|
Quote:
Quote:
|
||
![]() |
![]() |
#109 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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 |
![]() |
![]() |
#110 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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 |
![]() |
![]() |
#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. |
|
![]() |
![]() |
#112 |
Registered User
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 821
|
|
![]() |
![]() |
#113 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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. |
![]() |
![]() |
#114 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,437
|
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. |
|
![]() |
![]() |
#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.
![]() 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. |
|
![]() |
![]() |
#116 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Last edited by litwr; 18 May 2021 at 20:32. |
|
![]() |
![]() |
#117 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,044
|
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 |
![]() |
![]() |
#118 | ||
Registered User
Join Date: Aug 2010
Location: Italy
Posts: 854
|
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 ![]() Quote:
|
||
![]() |
![]() |
#119 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
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. |
|
![]() |
![]() |
#120 | |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,734
|
Quote:
|
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
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 |
|
|