mc8051fun/bcd_tolong__.c

68 lines
596 B
C
Raw Permalink Normal View History

2024-07-01 22:31:49 +02:00
#include "usebank0.h"
/*
r0 = bcd
r1 = bin
r7 = len of bcd
r6 = len of bin
reverse double dabble
*/
static void bcd_tolong__() __naked
{
__asm
.globl bcd_tolong
bcd_tolong:
mov a,AR6 ; use r4 as counter
mov b,#0x08
mul ab
mov r4,a
000$:
push AR0
push AR7
clr c
lcall long_rrc
mov r0,AR1
mov r7,AR6
lcall long_rrc
pop AR7
pop AR0
push AR0
push AR7
001$:
mov a,@r0
acall 003$
acall 003$
mov @r0,a
inc r0
djnz r7,001$
pop AR7
pop AR0
djnz r4,000$
ret
003$:
swap a
clr c
subb a,#0x80
jc 002$
subb a,#0x30
002$:
add a,#0x80
ret
__endasm;
}