]> git.sur5r.net Git - cc65/commitdiff
Make the 8x32 unsigned multiplication routine C callable.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 10 Jul 2011 14:52:35 +0000 (14:52 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 10 Jul 2011 14:52:35 +0000 (14:52 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5079 b7a2c559-68d2-44c3-8de9-860c34a00d81

include/cc65.h
libsrc/common/Makefile
libsrc/common/cc65_umul16x8r32.s [new file with mode: 0644]

index 8c743121db59292381f19b5313a3946cf64519d0..e1c23e1bcfd6e58e4492eb18039ae5df5d77be42 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2009,      Ullrich von Bassewitz                                      */
+/* (C) 2009-2011, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -67,6 +67,11 @@ long __fastcall__ cc65_imul16x16r32 (int lhs, int rhs);
 unsigned __fastcall__ cc65_umul8x8r16 (unsigned char lhs, unsigned char rhs);
 /* Multiplicate two unsigned 8 bit to yield an unsigned 16 bit result */
 
+unsigned long __fastcall__ cc65_umul16x8r32 (unsigned lhs, unsigned char rhs);
+/* Multiplicate an unsigned 16 bit by an unsigned 8 bit number yielding a 24
+ * bit unsigned result that is extended to 32 bits for easier handling from C.
+ */
+
 unsigned long __fastcall__ cc65_umul16x16r32 (unsigned lhs, unsigned rhs);
 /* Multiplicate two unsigned 16 bit to yield an unsigned 32 bit result */
 
index 37888b9e8c7f3d17cbe7a4d0be5a65c1a926c819..77a77e990d331699a9efcffbe316186fcb369112 100644 (file)
@@ -105,6 +105,7 @@ S_OBJS =    _cwd.o                  \
                 cc65_sincos.o           \
                 cc65_udiv32by16r16.o    \
                 cc65_umul16x16r32.o     \
+                cc65_umul16x8r32.o      \
                 chdir.o                 \
                copydata.o              \
                 creat.o                 \
diff --git a/libsrc/common/cc65_umul16x8r32.s b/libsrc/common/cc65_umul16x8r32.s
new file mode 100644 (file)
index 0000000..8af3493
--- /dev/null
@@ -0,0 +1,27 @@
+;
+; Ullrich von Bassewitz, 2011-07-10
+;
+; CC65 library: 16x8 => 32 unsigned multiplication
+;
+
+        .export         _cc65_umul16x8r32
+        .import         umul8x16r24, popax
+
+        .include        "zeropage.inc"
+
+
+;---------------------------------------------------------------------------
+; 16x8 => 32 unsigned multiplication routine. We use 8x16 => 24 and clear
+; the high byte of the result
+
+.proc   _cc65_umul16x8r32
+
+        sta     ptr1
+        lda     #0
+        sta     sreg+1                  ; Clear high byte of result
+        jsr     popax
+        jmp     umul8x16r24
+
+.endproc
+
+