/ void bcdmul( / unsigned char x1[ISIZE], / unsigned char y1[ISIZE], / unsigned char z1[ISIZE*2+1], / const int c1, / const int c2); / multiply 2 positive bcd numbers, z1=x1*y1 / c1 is the number of digits in x1 / c2 is the number of digits in y1 / z1 must be able to hold at least c1+c2+1 digits / output array should be initialized to zeros before this is called / / Copyright John Moyer 1996 / permission is granted to use this for any purpose provided proper / credit is given to the author #ident "@(#)bcdmul.s 1.2 5/24/96 11:29:57" .file "bcdmul.s" .text .globl bcdmul .align 4 XONE = 8 YONE = 12 ZONE = 16 XCOUNT = 20 YCOUNT = 24 bcdmul: pushl %ebp movl %esp,%ebp pushl %eax pushl %ebx pushl %ecx pushl %edx pushl %esi pushl %edi movl YONE(%ebp),%edx / movl YCOUNT(%epb),%ebx xorl %ebx,%ebx .myloop2: movl XONE(%ebp),%esi movl XCOUNT(%ebp),%ecx movl ZONE(%ebp),%edi addl %ebx,%edi xorl %eax,%eax .myloop: movb (%esi),%al mulb (%edx) / .byte 0xd4 / .byte 0x0a aam pushl %eax pushl %edx pushl %edi pushl %ecx movl %eax,%edx / save value in ah,al movl XCOUNT(%ebp),%ecx addl YCOUNT(%ebp),%ecx subl %ebx,%ecx / movl ZONE(%ebp),%edi / addl %ebx,%edi xorb %ah,%ah addb (%edi),%al aaa movb %al,(%edi) incl %edi addb %dh,%ah .myloop3: movb %ah,%al xorb %ah,%ah addb (%edi),%al / .byte 0x37 aaa movb %al,(%edi) incl %edi testb %ah,%ah loopnz .myloop3 popl %ecx popl %edi popl %edx popl %eax incl %esi incl %edi loop .myloop incl %edx incl %ebx cmpl %ebx,YCOUNT(%ebp) jnz .myloop2 .myexit: popl %edi popl %esi popl %edx popl %ecx popl %ebx popl %eax leave ret .type bcdmul,@function .size bcdmul,.-bcdmul