/ void bcdadd( / unsigned char x1[ISIZE], / unsigned char y1[ISIZE], / unsigned char z1[ISIZE], / const int c); / add 2 positive bcd numbers, z1=x1+y1, c is the max of number of digits in / x1 or y1 / 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 "@(#)bcdadd.s 1.6 5/24/96 11:29:55" .file "bcdadd.s" .text .globl bcdadd .align 4 COUNT = 20 ZONE = 16 YONE = 12 XONE = 8 bcdadd: pushl %ebp movl %esp,%ebp pushl %eax pushl %ecx pushl %edx pushl %esi pushl %edi movl ZONE(%ebp),%edi movl YONE(%ebp),%edx movl XONE(%ebp),%esi movl COUNT(%ebp),%ecx xorl %eax,%eax myloop: movb %ah,%al xorb %ah,%ah addb (%esi),%al addb (%edx),%al / if your assembler does not like aaa, then uncomment the following instead / .byte 0x37 aaa movb %al,(%edi) incl %esi incl %edx incl %edi loop myloop / assume that a store is faster than a conditional jump / testb %ah,%ah / jz myexit movb %ah,%al movb %al,(%edi) myexit: popl %edi popl %esi popl %edx popl %ecx popl %eax leave ret .type bcdadd,@function .size bcdadd,.-bcdadd