22 May 2021, 19:18 | #201 | |||
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
What crazy things are you talking about?! How to connect addx.w D3,D3 with you code? About BTST just read the manual and study yourself a bit. Quote:
Thank you very much. I wish Don_Adan could explain his thoughts so clearly. However my code doesn't use absolute addressing. Quote:
EDIT. I dare to ask you how to test 8-bit systems without 64 KB limit? |
|||
22 May 2021, 19:38 | #202 | |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
|
Quote:
Code:
F00:0160 .longdiv F00:0161 if __VASM&28 ;68020/30? F00:0162 divul d4,d7:d3 F00:0163 else F00:0164 swap d3 S01:000000CE: 48 43 Code:
F00:0213 subq #2,d4 ;i <- i - 1 S01:00000102: 55 44 F00:0214 bcc .l2 ;the main loop |
|
22 May 2021, 19:44 | #203 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
|
22 May 2021, 20:19 | #204 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,840
|
Quote:
Quote:
Last edited by Thorham; 22 May 2021 at 20:27. |
||
22 May 2021, 22:55 | #205 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
I found one bug, in my version D7 is not handled correctly for odd values. I must rethink this routine again.
|
23 May 2021, 01:44 | #206 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
Perhaps fixed now, but code is longer.
Code:
clr.l -(SP) ; cv moveq #0,D7 .l0 clr.l d5 ;d <- 0 move.l d6,d4 ;i <- kv, i <- i*2 adda.l d4,a3 subq.l #1,d4 ;b <- 2*i-1 move.w #10000,d1 bra.b .l4 .l2 sub.l d3,d5 sub.l d7,d5 lsr.l #1,d5 .l4 move -(a3),d0 ; r[i] mulu.w d1,d0 ;r[i]*10000 add.l d0,d5 ;d += r[i]*10000 move.l d5,d3 lsr.l #1,D3 divu.w d4,d3 move.w d3,d7 clr.w d3 swap d3 addx.w D3,D3 move.w D4,D0 ; D4 sub.w D3,D0 ; check if D3 is greater or equal D4 sls D0 ; if yes then $FF, if not then 0 extb.l D0 ; -1 or 0 add.l D7,D7 sub.l D0,D7 and.w D4,D0 ; D4 or 0 sub.w D0,D3 ; fixed D3 exg D3,D7 move.w D7,(A3) ;r[i] <- d%b subq.w #2,d4 ;i <- i - 1 bcc.b .l2 ;the main loop divu.w d1,d5 ;removed with MULU optimization add.w (SP),D5 ; cv move.l D5,(SP) ; cv ext.l D5 ; necessary only for litwr version of PR0000 routine bsr PR0000 sub.w #28,d6 ;kv bne.b .l0 addq.l #4,SP ; restore stack Last edited by Don_Adan; 23 May 2021 at 03:10. |
23 May 2021, 04:07 | #207 | ||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,719
|
Quote:
One of my goals in life (if I can find the time) is to do some assembly language programming on all of the retro computers in my collection. litwr's 'pipack' has working examples for many of them in one handy archive, so it is useful to me even if the benchmark results aren't very relevant. Quote:
Seriously though, who cares what optimizations can be done on larger systems? It's not like computing 9000 digits of pi has any practical application. I would rather see the original algorithm reproduced 'accurately', ie. in a form that closely follows it in an obvious way, rather than 'cheating' with lookup tables etc. Otherwise it opens up the possibility of ridiculous developments like what happened with America's Cup racing boats - which had strict hull dimension rules except that nowhere did the rules state it had to be a single hull (!), opening the way for catamarans and hydrofoils that blew conventional designs out of the water. |
||
23 May 2021, 09:33 | #208 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
Last edited by modrobert; 23 May 2021 at 11:22. |
|
23 May 2021, 12:40 | #209 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,840
|
Quote:
This thread is eleven pages long. |
|
23 May 2021, 19:43 | #210 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
|
|
23 May 2021, 19:47 | #211 | ||
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
I just point the manual snippet about BTST for you afore. Please read it now. Quote:
|
||
23 May 2021, 19:56 | #212 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
However if we want 10000 digits for 32-bit and some 16-bit systems this makes the algo slower for those systems because they have to use bigger tables and variables even for 1000 digits. And let me repeat again this excludes a lot of systems from the benchmarking. So it gives nothing good. You know every sport has rules. |
|
23 May 2021, 20:13 | #213 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
Your code snippet is wrong again. Just try to use D4=1 this can overflow DIVU D4,D3. Please if you want to continue try to run your code at first. |
|
23 May 2021, 20:29 | #214 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,436
|
Quote:
Original post follows... I've had enough with everyone in this thread bickering over this. Litwr is correct: the code is 54 bytes long. And because I no longer want to see any silly discussion about it, you can find attached a screenshot of the output that VASM gives for the following code when assembled: Code:
.longdiv move d3,d7 divu d4,d7 swap d7 move d7,d3 swap d3 divu d4,d3 move d3,d7 exg.l d3,d7 clr d7 swap d7 move d7,(a3) ;r[i] <- d%b bra.s .enddiv .l2 sub.l d3,d5 sub.l d7,d5 lsr.l d5 .l4 move -(a3),d0 ; r[i] mulu d1,d0 ;r[i]*10000 add.l d0,d5 ;d += r[i]*10000 move.l d5,d3 divu d4,d3 bvs.s .longdiv move d3,d7 clr d3 swap d3 move d3,(a3) ;r[i] <- d%b .enddiv subq #2,d4 ;i <- i - 1 bcc .l2 ;the main loop .endcode printv .endcode-.longdiv Last edited by BippyM; 01 June 2021 at 18:24. |
|
23 May 2021, 20:39 | #215 | |
Registered User
Join Date: Mar 2016
Location: Ozherele
Posts: 229
|
Quote:
A lot of algos exist for the pi-number computation. IMHO the pi-spigot is the easiest. It is not the fastest but it is the shortest. |
|
23 May 2021, 20:43 | #216 | ||
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
|
Quote:
That's all well and good, but you haven't counted the swap at the start of the listing, the $4843 at address $ce. Quote:
Yes, indeed, I see the 0x104 - however, the 0x5544 at 0x102 is *not* the bcc, it's the "subq #4, d4". The bcc *starts* at 0x104, and thus ends at 0x106 - therefore you're not counting the bcc. |
||
23 May 2021, 20:59 | #217 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,436
|
Quote:
Sorry, I find it really funny that I try to get a 100% answer on this and then make an error myself. Especially considering how I phrased it. So errr, yeah... About that... You're right, I did accidentally cut off the swap while reformatting the listing. I do appologize, I used the program listing as supplied by litwr (the one with all the line numbers, offsets and such added in) and deleted one line more than I should've. Which means, yeah - it is 56 bytes if the instruction I managed to delete were added back in. In most assemblers, you can certainly use a larger number than 0-7 using BTST in memory, but be aware that the instruction itself only has encoding space for 3 bits when used to test bits in memory and only tests on a single byte. So BTST #14,<<memory>> doesn't check the 14th bit, but the 6th bit. Last edited by roondar; 24 May 2021 at 00:49. Reason: Corrected my statement on BTST |
|
23 May 2021, 21:13 | #218 | |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,157
|
Quote:
The funniest part is how much effort and energy we've all expended over two bytes! It has been an interesting thread, though - I love that we can still learn new things about instruction timings decades after the CPUs were released. |
|
23 May 2021, 22:06 | #219 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 56
Posts: 2,039
|
Quote:
|
|
23 May 2021, 23:47 | #220 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,840
|
Quote:
For example, there's a division by 10000 in the original program. It might be possible to make a division table for this and get some benefit. The artificial limitation prevents this. Another one might be a division + binary to decimal conversion table where the whole thing is done in one go. Has nothing to do with the spigot algorithm, and therefore doesn't affect the smaller systems at all. |
|
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 |
|
|