English Amiga Board div and mul of BCD or Hex?
 User Name Remember Me? Password
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 08 September 2020, 10:48 #1 JoeJoe Registered User   Join Date: Feb 2020 Location: Germany Posts: 91 div and mul of BCD or Hex? Hello coder, I am currently working on the display and calculation of scores. I have already read the thread "BCD Arithmetic - howto^". The simple adding and subtracting is no problem. But I have to divide the score by 50. Also the points can be increased by graduation 3*90 or 5*240 etc. Now to my problem. For dividing and multiplying with BCD there are no 1:1 commands. Multiplying can be avoided by using LookUp tables and adding. But for x:50 there is no alternative. Of course I can calculate everything in hex and convert the hex values to decimal for the display. But this eats a lot of cycles. How can I solve the problem without overloading the computer. Thanks in advance JoeJoe @Admins: please move to right section, sorry Last edited by JoeJoe; 08 September 2020 at 11:44. Reason: wrong section
 08 September 2020, 11:13 #2 meynaf son of 68k   Join Date: Nov 2007 Location: Lyon / France Age: 48 Posts: 4,256 You can convert the divide into a multiply. First, add the number to itself to do *2. Then, remove the two last digits to do /100. You will have achieved /50.
 08 September 2020, 11:18 #3 alkis Registered User   Join Date: Dec 2010 Location: Athens/Greece Age: 50 Posts: 579 /50 can be achieved by /100 (dropping last byte) and add the number to itself (so /100*2)
 08 September 2020, 11:46 #4 JoeJoe Registered User   Join Date: Feb 2020 Location: Germany Posts: 91 thanks for your replies
08 September 2020, 13:11   #5
8bitbubsy
Registered User

Join Date: Sep 2009
Location: Norway
Posts: 1,535
Quote:
 Originally Posted by meynaf Then, remove the two last digits to do /100.
How is this achieved in a fast way when working with binary?

08 September 2020, 13:18   #6
meynaf
son of 68k

Join Date: Nov 2007
Location: Lyon / France
Age: 48
Posts: 4,256
Quote:
 Originally Posted by 8bitbubsy How is this achieved in a fast way when working with binary?
Who cares ? This thread is about BCD, not binary.

 08 September 2020, 14:10 #7 JoeJoe Registered User   Join Date: Feb 2020 Location: Germany Posts: 91 That's right, but we don't want to be like that I do this with the reciprocal method. x/50 = x*(1/50)
08 September 2020, 16:07   #8
Thomas Richter
Registered User

Join Date: Jan 2019
Location: Germany
Posts: 1,107
Quote:
 Originally Posted by JoeJoe I am currently working on the display and calculation of scores. I have already read the thread "BCD Arithmetic - howto^". The simple adding and subtracting is no problem. But I have to divide the score by 50. Also the points can be increased by graduation 3*90 or 5*240 etc. Now to my problem. For dividing and multiplying with BCD there are no 1:1 commands. Multiplying can be avoided by using LookUp tables and adding. But for x:50 there is no alternative.

:50 is simple enough (already answered by others), but general multiplication or division in BCD is slow, in general. To multply, use the pen-and-paper algorithm of multiplying digit by digit, then add the partial products by a BCD add. Similarly, a BCD division follows the pen-and-paper algorithm of continuous subtraction until an overflow, and keeping the number of times a number was subtracted, then carry over the remainder, and continue with the next digit.

All these algorithms are slow...

08 September 2020, 16:09   #9
Thomas Richter
Registered User

Join Date: Jan 2019
Location: Germany
Posts: 1,107
Quote:
 Originally Posted by 8bitbubsy How is this achieved in a fast way when working with binary?

If you have no division instruction, the same way as in BCD, except that each digit can be either 0 or 1, which simplifies continuous subtraction to a single compare. If you do, well, use the division instruction.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 Thread Tools

 Similar Threads Thread Thread Starter Forum Replies Last Post meynaf Coders. Asm / Hardware 9 02 December 2017 22:20 Herpes Coders. General 49 16 September 2014 19:42 Hanzu HOL contributions 2 13 November 2013 16:57 Aria support.Games 4 16 June 2011 20:20 dlfrsilver support.WinUAE 3 01 November 2005 11:31

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.Amiga File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials

All times are GMT +2. The time now is 04:12.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.07568 seconds with 15 queries