freshbrood Posted January 6, 2021 Share Posted January 6, 2021 Am I doing something wrong? I understand that I need to insert "include div_mul.asm" at the start but it still doesn't seem to work with anything that doesn't divide evenly. n = 105 / 7 crashes. n = (105 / 7) crashes. I don't need any floating number, I only want the int. Also, unrelated, why are there only 6 banks listed in the dpc+ template instead of 8? Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted January 6, 2021 Share Posted January 6, 2021 17 minutes ago, freshbrood said: Am I doing something wrong? I understand that I need to insert "include div_mul.asm" at the start but it still doesn't seem to work with anything that doesn't divide evenly. n = 105 / 7 crashes. n = (105 / 7) crashes. I don't need any floating number, I only want the int. Also, unrelated, why are there only 6 banks listed in the dpc+ template instead of 8? Not a solution to your problem, but just a bit of advice: avoid division like the plague. It is slow, and there are nearly always better ways to organise things into shifts and/or adds/subtracts/increments/decrements For example, if you could somehow change the need for a 7 into an 8, then you could just shift right 3 times. 8 cycles. The general purpose division routine is going to be lots more than that - say... 50... 100? More? 2 Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted January 6, 2021 Share Posted January 6, 2021 Note to self: I'm assuming the division doesn't use the ARM!!! 1 Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 6, 2021 Share Posted January 6, 2021 This probably should be posted in the BBasic sub-forum. But I can give an answer for the last question: You only have 6 code banks available in DPC+ (24k). The other 8k is used as follows: 4k is used for the Display Data RAM. 3k is used by the DPC bankswitching driver. 1k is used for music frequencies/only accessible via ARM code. 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 6, 2021 Share Posted January 6, 2021 Yes, this should be in the bB forum. Your example should work, but make sure you put the "include div_mul.asm" before "set romsize" or "set kernel". If you have some code where this causes a crash, I'd be happy to take a look at it. 1 Quote Link to comment Share on other sites More sharing options...
jaybird3rd Posted January 6, 2021 Share Posted January 6, 2021 2 hours ago, Karl G said: Yes, this should be in the bB forum. I've moved the topic to batari Basic. 1 1 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted January 6, 2021 Share Posted January 6, 2021 As @Andrew Davie mentions division by powers of 2 can be done fast, others not so much. That said, @Omegamatrix has a blog entry with a number of optimized division routines, such as this for divide by 7. Note that the code in the blog entry is messed up due to the last forum upgrade, so download the file DivisionRoutines(rev2).asm ;Divide by 7 (From December '84 Apple Assembly Line) ;15 bytes, 27 cycles sta temp lsr lsr lsr adc temp ror lsr lsr adc temp ror lsr lsr This is the DPC+ cartridge layout, can read more about it here - DPC+ARM - Part 6, DPC+ Cartridge Layout 1 Quote Link to comment Share on other sites More sharing options...
ScumSoft Posted January 6, 2021 Share Posted January 6, 2021 (edited) Not sure if this addresses your 2nd question directly: The template was made by me a long time ago, I don't know if it was updated after iesposta noticed an error in it. Batari Basic indexes the banks starting at 1 through 6, the template said that bank 6 was reserved for the graphics bank because I had indexed the banks starting from 0 back then. Bank 6 is in fact usable as it translates to bank 5 as SpiceWare posted above. So if your coding in ASM then DPC+ uses banks 0-5 for user code, bank 6 is reserved for the graphic data copies and fast fetcher access. In bB you have banks 1-6 for use, and bank 7 is the graphics bank. Edited January 6, 2021 by ScumSoft 1 Quote Link to comment Share on other sites More sharing options...
freshbrood Posted January 6, 2021 Author Share Posted January 6, 2021 Thanks for all your clear replies, I appreciate it! You save me a lot of headache and make writing games fun. I'm just getting into dpc now and even peeked at Karl G's asm for beginners tutorials, excellent. It's less daunting with you guys to help and your awesome input. Btw I thought I was already posting in the batari forum?? 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.