44 lines
536 B
C
44 lines
536 B
C
|
|
#include "bcd.h"
|
|
|
|
#pragma disable_warning 59 // Disable "must return a value" warning
|
|
|
|
void bcd_addbyte(__idata uint8_t *v1, uint8_t len, uint8_t ab) __reentrant
|
|
{
|
|
(void)v1; (void)len; (void)ab;
|
|
|
|
__asm
|
|
mov a,_bp
|
|
add a,#0xfd
|
|
mov sp,a
|
|
|
|
mov r0,dpl
|
|
pop ar7
|
|
pop ACC
|
|
mov r6,a
|
|
add a,#0xb0 ; carry will be set if a>=5
|
|
jc 001$
|
|
mov b,#0x00
|
|
ajmp 004$
|
|
001$:
|
|
mov b,#0x99
|
|
004$:
|
|
mov a,@r0
|
|
add a,r6
|
|
da a
|
|
mov @r0,a
|
|
sjmp 002$
|
|
000$:
|
|
inc r0
|
|
mov a,@r0
|
|
addc a,#0x00
|
|
da a
|
|
mov @r0,a
|
|
002$:
|
|
djnz r7,000$
|
|
mov sp,_bp
|
|
__endasm;
|
|
}
|
|
|
|
|