Compare commits
No commits in common. "b24da848acbb8630af082fc4124226f23171d104" and "f1853c097c33dcd5e83d0d5303c5534a55c120a6" have entirely different histories.
b24da848ac
...
f1853c097c
4
Makefile
4
Makefile
@ -23,9 +23,7 @@ LIBSRC = uart_init_.c uart_send_chr.c uart_send_str.c \
|
|||||||
getpin.c setpin_lo.c setpin_hi.c setpin.c getport.c \
|
getpin.c setpin_lo.c setpin_hi.c setpin.c getport.c \
|
||||||
long_xadd.c long_xsub.c long_xset.c long_xrlc.c long_xdiv.c long_xcpy.c long_xtobcd.c \
|
long_xadd.c long_xsub.c long_xset.c long_xrlc.c long_xdiv.c long_xcpy.c long_xtobcd.c \
|
||||||
multest.c \
|
multest.c \
|
||||||
bcd_add.c bcd_getsig.c bcd_invert.c bcd_9cpl.c bcd_addbyte.c bcd_shr.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
|
|
||||||
|
|
||||||
LIBOBJ =$(patsubst %.c,%.rel, $(LIBSRC))
|
LIBOBJ =$(patsubst %.c,%.rel, $(LIBSRC))
|
||||||
LIBNAME=mc8051fun.lib
|
LIBNAME=mc8051fun.lib
|
||||||
|
2
bcd.h
2
bcd.h
@ -10,7 +10,5 @@ void bcd_invert(__idata uint8_t *v1, uint8_t len);
|
|||||||
void bcd_addbyte(__idata uint8_t *v1, uint8_t len, uint8_t b) __reentrant;
|
void bcd_addbyte(__idata uint8_t *v1, uint8_t len, uint8_t b) __reentrant;
|
||||||
uint8_t bcd_getsig(__idata uint8_t*v, uint8_t len);
|
uint8_t bcd_getsig(__idata uint8_t*v, uint8_t len);
|
||||||
|
|
||||||
void long_tobcd(__idata uint8_t *binval, __idata uint8_t *bcdval, uint8_t binlen, uint8_t bcdlen) __reentrant;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
33
long_add.c
33
long_add.c
@ -1,33 +0,0 @@
|
|||||||
#include "mc8051fun.h"
|
|
||||||
#include "bcd.h"
|
|
||||||
|
|
||||||
#pragma disable_warning 59 // Disable "must return a value" warning
|
|
||||||
|
|
||||||
uint8_t long_add(__idata uint8_t *v1, __idata uint8_t *v2,uint8_t len) __reentrant
|
|
||||||
{
|
|
||||||
(void)v1; (void)v2; (void)len;
|
|
||||||
__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 dpl,#0x00
|
|
||||||
jnc $002
|
|
||||||
inc dpl
|
|
||||||
$002:
|
|
||||||
mov sp,_bp
|
|
||||||
__endasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
24
long_rlc__.c
24
long_rlc__.c
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* @r0 = number
|
|
||||||
* r7 = len
|
|
||||||
*
|
|
||||||
* modyfies: r0,r7,a
|
|
||||||
*/
|
|
||||||
static void long_rlc__() __naked
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
.globl long_rlc
|
|
||||||
|
|
||||||
long_rlc:
|
|
||||||
mov a,@r0
|
|
||||||
rlc a
|
|
||||||
mov @r0,a
|
|
||||||
inc r0
|
|
||||||
djnz r7,long_rlc
|
|
||||||
ret
|
|
||||||
|
|
||||||
__endasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
29
long_rrc__.c
29
long_rrc__.c
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* @r0 = number
|
|
||||||
* r7 = len
|
|
||||||
*
|
|
||||||
* modyfies: r0,r7,a
|
|
||||||
*/
|
|
||||||
static void long_rrc__() __naked
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
.globl long_rrc
|
|
||||||
long_rrc:
|
|
||||||
push PSW
|
|
||||||
mov a,r0
|
|
||||||
add a,r7
|
|
||||||
mov r0,a
|
|
||||||
pop PSW
|
|
||||||
001$:
|
|
||||||
dec r0
|
|
||||||
mov a,@r0
|
|
||||||
rrc a
|
|
||||||
mov @r0,a
|
|
||||||
djnz r7,001$
|
|
||||||
ret
|
|
||||||
|
|
||||||
__endasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
33
long_tobcd.c
33
long_tobcd.c
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
#include "mc8051fun.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* C-Wrapper for long_tobcd
|
|
||||||
*/
|
|
||||||
|
|
||||||
void long_tobcd(__idata uint8_t *binval, __idata uint8_t *bcdval, uint8_t binlen, uint8_t bcdlen) __reentrant
|
|
||||||
{
|
|
||||||
(void)binval;
|
|
||||||
(void)bcdval;
|
|
||||||
(void)binlen;
|
|
||||||
(void)bcdlen;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
mov a,_bp
|
|
||||||
add a,#0xfd
|
|
||||||
mov r0,a
|
|
||||||
mov a,@r0
|
|
||||||
mov r1,a
|
|
||||||
dec r0
|
|
||||||
mov a,@r0
|
|
||||||
mov r7,a
|
|
||||||
dec r0
|
|
||||||
mov a,@r0
|
|
||||||
mov r6,a
|
|
||||||
mov r0,dpl
|
|
||||||
lcall long_tobcd
|
|
||||||
|
|
||||||
__endasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
r0 = bin
|
|
||||||
r1 = bcd
|
|
||||||
r7 = len of bin
|
|
||||||
r6 = len of bcd
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mc8051fun.h"
|
|
||||||
|
|
||||||
#include "usebank0.h"
|
|
||||||
|
|
||||||
// double dabble
|
|
||||||
|
|
||||||
void long_tobcd__() __naked
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
.globl long_tobcd
|
|
||||||
|
|
||||||
long_tobcd:
|
|
||||||
|
|
||||||
; fill dst with zeroes
|
|
||||||
|
|
||||||
mov r3,AR1 ; save r1 in r3
|
|
||||||
mov r4,AR6 ; use r4 as counter
|
|
||||||
; mov a,#0x00
|
|
||||||
|
|
||||||
000$:
|
|
||||||
mov @r1,#0x0
|
|
||||||
inc r1
|
|
||||||
djnz r4,000$
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mov a,r0
|
|
||||||
add a,r7
|
|
||||||
dec a
|
|
||||||
mov r0,a ; r0 points to last byte of bin
|
|
||||||
mov r2,AR0 ; save r0 in r2
|
|
||||||
|
|
||||||
006$:
|
|
||||||
mov a,@r0
|
|
||||||
mov r5,#0x08
|
|
||||||
005$:
|
|
||||||
mov r4,AR6 ; use r4 as counter
|
|
||||||
mov r1,AR3
|
|
||||||
|
|
||||||
push ACC
|
|
||||||
004$:
|
|
||||||
mov a,@r1
|
|
||||||
acall 003$
|
|
||||||
acall 003$
|
|
||||||
mov @r1,a
|
|
||||||
inc r1
|
|
||||||
djnz r4,004$
|
|
||||||
|
|
||||||
pop ACC
|
|
||||||
|
|
||||||
|
|
||||||
rlc a
|
|
||||||
push ACC
|
|
||||||
push AR0
|
|
||||||
push AR7
|
|
||||||
mov r7,AR6
|
|
||||||
mov r0,AR3
|
|
||||||
lcall long_rlc
|
|
||||||
pop AR7
|
|
||||||
pop AR0
|
|
||||||
pop ACC
|
|
||||||
djnz r5,005$
|
|
||||||
|
|
||||||
|
|
||||||
dec r0
|
|
||||||
djnz r7,006$
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
003$:
|
|
||||||
swap a
|
|
||||||
clr c
|
|
||||||
subb a,#0x50
|
|
||||||
jc 002$
|
|
||||||
add a,#0x30
|
|
||||||
002$:
|
|
||||||
add a,#0x50
|
|
||||||
ret
|
|
||||||
|
|
||||||
__endasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
usebank0.h
21
usebank0.h
@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
#undef AR0
|
|
||||||
#undef AR1
|
|
||||||
#undef AR2
|
|
||||||
#undef AR3
|
|
||||||
#undef AR4
|
|
||||||
#undef AR5
|
|
||||||
#undef AR6
|
|
||||||
#undef AR7
|
|
||||||
|
|
||||||
|
|
||||||
#define AR0 0x00
|
|
||||||
#define AR1 0x01
|
|
||||||
#define AR2 0x02
|
|
||||||
#define AR3 0x03
|
|
||||||
#define AR4 0x04
|
|
||||||
#define AR5 0x05
|
|
||||||
#define AR6 0x06
|
|
||||||
#define AR7 0x07
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user