68 lines
596 B
C
68 lines
596 B
C
|
#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;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|