New long_* functions

This commit is contained in:
7u83 2024-07-03 06:54:47 +02:00
parent 11db18ee92
commit 6c2e631e56
7 changed files with 118 additions and 1 deletions

View File

@ -26,7 +26,9 @@ LIBSRC = uart_init_.c uart_send_chr.c uart_send_str.c \
bcd_add.c bcd_getsig.c bcd_invert.c bcd_9cpl.c bcd_addbyte.c bcd_shr.c \
long_rrc__.c long_rlc__.c \
long_tobcd__.c long_tobcd.c \
bcd_tolong__.c bcd_tolong.c
bcd_tolong__.c bcd_tolong.c \
long_addbyte__.c long_addbyte.c \
long_1cpl__.c long_invert__.c long_invert.c
LIBOBJ =$(patsubst %.c,%.rel, $(LIBSRC))

22
long_1cpl__.c Normal file
View File

@ -0,0 +1,22 @@
#include "mc8051fun.h"
static void long_1cpl__() __naked
{
__asm
.globl long_1cpl
long_1cpl:
clr c
001$:
mov a,#0xff
subb a,@r0
mov @r0,a
inc r0
djnz r7,001$
ret
__endasm;
}

26
long_addbyte.c Normal file
View File

@ -0,0 +1,26 @@
#include "mc8051fun.h"
/**
* C wrapper for long_addbyte
*/
static void long_addbyte(__idata uint8_t * val, uint8_t len, uint8_t b) __reentrant
{
(void)val;
(void)b;
__asm
mov a,_bp
add a,#0xfd
mov r0,a
mov a,@r0 ; len
mov r7,a
dec r0
mov a,@r0 ; b
mov r0,dpl
lcall long_addbyte
__endasm;
}

23
long_addbyte__.c Normal file
View File

@ -0,0 +1,23 @@
/*
* a = byte to add
* @r0 = long val
* r7 = length
*
*/
static void long_addbyte__() __naked
{
__asm
.globl long_addbyte
long_addbyte:
clr c
ajmp 002$
001$:
mov a,#0x00
002$:
addc a,@r0
mov @r0,a
inc r0
djnz r7,001$
ret
__endasm;
}

21
long_invert.c Normal file
View File

@ -0,0 +1,21 @@
#include "mc8051fun.h"
void long_invert(__idata uint8_t *val, uint8_t len) __reentrant
{
(void)val;
(void)len;
__asm
mov a,_bp
add a,#0xfd
mov r0,a
mov a,@r0 ; len
mov r7,a
mov r0,dpl
lcall long_invert
__endasm;
}

22
long_invert__.c Normal file
View File

@ -0,0 +1,22 @@
#include "mc8051fun.h"
static void long_invert__() __naked
{
__asm
.globl long_invert
long_invert:
push AR0
push AR7
lcall long_1cpl
pop AR7
pop AR0
mov a,#0x01
lcall long_addbyte
ret
__endasm;
}

View File

@ -89,6 +89,7 @@ uint8_t getport(int n);
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;
#endif