long_add function

This commit is contained in:
7u83 2024-07-03 07:06:33 +02:00
parent 6c2e631e56
commit 6153bb3fb4
4 changed files with 34 additions and 13 deletions

View File

@ -28,6 +28,7 @@ LIBSRC = uart_init_.c uart_send_chr.c uart_send_str.c \
long_tobcd__.c long_tobcd.c \
bcd_tolong__.c bcd_tolong.c \
long_addbyte__.c long_addbyte.c \
long_add__.c long_add.c \
long_1cpl__.c long_invert__.c long_invert.c

View File

@ -9,23 +9,17 @@ uint8_t long_add(__idata uint8_t *v1, __idata uint8_t *v2,uint8_t len) __reentra
__asm
mov a,_bp
add a,#0xfd
mov sp,a
pop ar1
pop ar7
mov ar0,dpl
clr c
001$:
mov a,@r0
addc a,@r1
mov @r0,a
inc r0
inc r1
djnz r7,001$
mov r0,a
mov a,@r0 ; *v2
mov r1,a
mov a,@r0 ; len
mov r7,a
mov r0,dpl
lcall long_invert
mov dpl,#0x00
jnc $002
inc dpl
$002:
mov sp,_bp
__endasm;
}

25
long_add__.c Normal file
View File

@ -0,0 +1,25 @@
/*
* @r0 = @r0+@r1
* r7=len
*/
static void long_add__() __naked
{
__asm
long_add:
clr c
long_addc:
001$:
mov a,@r0
addc a,@r1
mov @r0,a
inc r0
inc r1
djnz r7,001$
ret
__endasm;
}

View File

@ -90,6 +90,7 @@ uint8_t multest(uint8_t a, uint8_t b);
void bcd_tolong(__idata uint8_t *bcdval, __idata uint8_t *binval, uint8_t bcdlen, uint8_t binlen) __reentrant;
void long_invert(__idata uint8_t *val, uint8_t len) __reentrant;
uint8_t long_add(__idata uint8_t *v1, __idata uint8_t *v2,uint8_t len) __reentrant;
#endif