Usefull code snippets
krusty - 26 July 2012 - 22:39:38
|
326 posts |
|---|---|
| Waiting loop Use this thread to share interesting code. I start it with a code from Rhino which eased my coding a lot... This is a version for vasm, the original one must be found with the link
|
|
TFM - 14 August 2012 - 23:51:11
|
146 posts |
|---|---|
| not "stolen to...", please use "stolen from..." ;-) |
|
krusty - 15 August 2012 - 12:06:03
|
326 posts |
|---|---|
| @tfm: corrected | |
krusty - 18 August 2012 - 15:58:16
|
326 posts |
|---|---|
Small modification of the waiting macro if the number of nops is inferior to 64
|
|
Grim - 26 November 2012 - 21:54:08
|
521 posts |
|---|---|
;;Signed 16x16 multiplication, 32 bits resultFor extra speed, unroll and remove the first jr nc,$+3:add hl,bc |
|
Grim - 27 November 2012 - 16:34:26
|
521 posts |
|---|---|
;;Signed 8x8 multiplication, 16 bits resultFor extra speed, unroll and remove the first jr nc,$+3:add a,h |
|
Grim - 28 November 2012 - 00:49:33
|
521 posts |
|---|---|
Macro for WinAPE/Maxam assembler.;; Wait N number of CPU-CycleUsage: GNOP 6128 ; Wait for 6128µs with a BC Loop |
|
Grim - 28 November 2012 - 18:49:11
|
521 posts |
|---|---|
;;Test all the 64k-pages (0 to 7) of extended RAM with standard MMR.Usage: ; Check the expansion RAM |
|
TFM - 28 November 2012 - 23:05:17
|
146 posts |
|---|---|
| ;-) | |
Grim - 29 November 2012 - 18:23:59
|
521 posts |
|---|---|
| Facts: * The original CPC has no reset-button. * Most democoders bragging about doing stuff only for the original hardware rely on expansions or custom-mods with a reset-button to exit their productions. * Real users of original hardware have to switch OFF/ON their CPC after watching a demo. * Often switching ON/OFF a CPC is harsh for the already aging electronic parts. Truth revealed: * CPC Democoders aim to destroy the original hardware! ;; ESC-Key testUsage: call EscApeBANANA! |
|
TFM - 29 November 2012 - 23:40:55
|
146 posts |
|---|---|
| What's about: _banana ld bc,&7f80 ;Select lower ROM, stay in Mode 0 out (c),c ;bank lower ROM in rst 0 ;jump to address 0000, firmware boots... That shall always work |
|
Grim - 30 November 2012 - 00:08:22
|
521 posts |
|---|---|
| If you do that with your routine located within &0001-&3FFF, the RST 0 won't be executed because the CPU will fetch it's next opcode off the Lower ROM that just got paged-in. I wouldn't call that a soft-reset, but something more like a Russian-roulette :) | |
TFM - 30 November 2012 - 03:53:19
|
146 posts |
|---|---|
| Haha. Right, it must be between &4000-&7FFF. But ... &0000-&3FFF and &C000-&FFFF ... are .... IMHO... screen RAM ;-) |
|
Grim - 08 February 2013 - 17:42:21
|
521 posts |
|---|---|
;; Automatically select Absolute or Relative jump instructionUsage: calvin equ &3fa0 Nobody else has nice code snippets to share? :( |
|
Toms - 14 February 2013 - 13:29:34
|
272 posts |
|---|---|
Grimmy: I just read the Booth's multiplication algorithm and I spotted a bug into your signed 8x8 multiplication routine. Here are the corrected lines:
Assuming that the two least significant bits of P are L register's least significant bit and Carry flag. It works better like this. Am I right? :) |
|
PulkoMandy - 14 February 2013 - 18:26:43
|
633 posts |
|---|---|
Nobody else has nice code snippets to share? :( I'm working on C code runing on a 6809 CPU. Do you think you have an use for it ? http://pulkomandy.tk/projects/thomson/browser It works better like this. Am I right? :) All code snippets in this threads are DRM protected to make sure you understand them before using them ;) |
|
krusty - 14 February 2013 - 18:32:54
|
326 posts |
|---|---|
I'm working on C code runing on a 6809 CPU. Do you think you have an use for it ? and what about your part for the MD?:-) |
|
Grim - 14 February 2013 - 18:44:52
|
521 posts |
|---|---|
@Toms: Duh! Yeah! It seems my copy/paste skill sucks, I copied a bad version. (I fixed it) But you win an extra code snippet! (DRM-free... hopefully :);; 8-bit PRNG (Galois LFSR)Usage: ; This is somewhere at the beginning of your program. @PulkoMandy: C on 6809, dont care much. (I hate 6809 :) And posting code-snippets doesnt require much effort actually, you just have to pick into your existing codebase (assuming, of course, it exists :) |
|
PulkoMandy - 14 February 2013 - 20:17:44
|
633 posts |
|---|---|
| Krusty: well, as far as I know the Forever party comes first ! The Megademo comes next... @Grimmy: well, I'll look at my small codebase then :) |
|
Grim - 15 February 2013 - 06:15:07
|
521 posts |
|---|---|
;; 8-bit signed magnitude approximation (2.8% accuracy)@Toms: I thought you might like this one better :) |
|
Apollo - 20 February 2013 - 20:18:11
|
36 posts |
|---|---|
| @Grim: You are an incredible source of knowledge and new ideas! I want to thank you very much for sharing this interesting code snippets!! I was working on a approximation of sqrt(x^2+y^2) myself without knowing of that paper you linked. I hope I can contribute one day as well! By the way, any chance you get some time and mood to finish your article about the CRTC and GA any time? *blinking with the eyes* |
|
CloudStrife - 20 February 2013 - 20:42:32
|
161 posts |
|---|---|
| Grim: in a bit less precise but simpler, you also have the alpha*max + beta*min, it give an accuracy better than 7% with alpha=1 and beta=3/8... Edit: well, need to open my eyes, they speak about it in the paper... |
|
Grim - 27 February 2013 - 05:45:44
|
521 posts |
|---|---|
| @Apollo: CRTC and GA are so booooring! Would you not prefer an atan2 approximation routine instead by any chance? :) @Cloudstrife: yep, this is just an improved amax+bmin with two coefficient sets instead of one. It takes a bit longer to execute, but the gain in accuracy is worth a handful of microseconds more imo. |
|
Toms - 01 March 2013 - 12:19:34
|
272 posts |
|---|---|
| Grimmy: an atan2 approximation would be a very appreciated late birthday gift :) | |
CloudStrife - 01 March 2013 - 15:09:31
|
161 posts |
|---|---|
Happy birthday Toms !;; A very high speed atan2 approximation |
|
bonefish - 01 March 2013 - 23:41:29
|
40 posts |
|---|---|
| :))))))))))) | |
Grim - 02 March 2013 - 17:21:38
|
521 posts |
|---|---|
| @Cloudstrife: Flags are not modified :) | |
CloudStrife - 02 March 2013 - 19:50:53
|
161 posts |
|---|---|
| Oups :) And now with a better approximation on the [-128;127] range for x and y ! |
|
PulkoMandy - 02 March 2013 - 22:44:34
|
633 posts |
|---|---|
I can do it faster !
|
|
Grim - 02 March 2013 - 23:06:10
|
521 posts |
|---|---|
| @PulkoMandy: But flags are modified :) | |
Online: nobody
Tom & Jerry
Color Lines - Theme 16
Color Lines - Theme 16



