Initial commit

This commit is contained in:
7u83 2024-06-05 08:19:50 +02:00
parent 89613a8bec
commit 4eae6e7023
5 changed files with 159 additions and 0 deletions

24
long_xadd.c Normal file
View File

@ -0,0 +1,24 @@
void long_xadd() __naked
{
__asm
.globl long_xadd
.globl long_xaddc
long_xadd:
clr c
long_xaddc:
movx a,@r1
mov b,a
movx a,@r0
addc a,b
movx @r0,a
inc r0
inc r1
djnz r7,long_xaddc
ret
__endasm;
}

69
long_xdiv.c Normal file
View File

@ -0,0 +1,69 @@
#include "mc8051fun.h"
/*
* r0 = numerator
* r1 = denominator
* r2 = quotient (result)
* r3 = rest
* r7 = length in bytes
*/
void long_xdiv() __naked
{
__asm
.globl long_xdiv
long_xdiv:
mov r5,AR7 ;#0x01
push AR0
mov r0,AR3
lcall long_xset_zero
pop AR0
mov r4,AR1
clr c
mov a,r0
addc a,r5 ;#DIGITS-1
mov r0,a
003$:
movx a,@r0
mov r6,#8
002$:
rlc a
push ACC
push AR0
mov r0,AR3 ;#_rest
mov r7,AR5 ;#DIGITS
lcall long_xrlc
mov r0,AR3 ;#_rest
; mov r1,#_val1
mov r7,AR5 ;#DIGITS
push AR1
lcall long_xsub
pop AR1
jnc 001$
mov r0,AR3 ;#_rest
; mov r1,#_val1
mov r7,AR5 ;#DIGITS
push AR1
lcall long_xadd
pop AR1
setb c
001$:
cpl c
mov r0,AR2 ; #_result
mov r7,AR5 ;#DIGITS
lcall long_xrlc
pop AR0
pop ACC
djnz r6,002$
djnz r0,003$
ret
__endasm;
}

21
long_xrlc.c Normal file
View File

@ -0,0 +1,21 @@
/*
*
*/
void long_xrlc() __naked
{
__asm
.globl long_xrlc
long_xrlc:
movx a,@r0
rlc a
movx @r0,a
inc r0
djnz r7,long_xrlc
ret
__endasm;
}

17
long_xset.c Normal file
View File

@ -0,0 +1,17 @@
void long_xset() __naked
{
__asm
.globl long_xset_zero
.globl long_xset
long_xset_zero:
mov a,#0x00
long_xset:
movx @r0,a
djnz r7,long_xset
__endasm;
}

28
long_xsub.c Normal file
View File

@ -0,0 +1,28 @@
/**
* @r0=@r0-@r1
* r7=len
*/
void long_xsub() __naked
{
__asm
.globl long_xsub
.globl long_xsubb
long_xsub:
clr c
long_xsubb:
movx a,@r1
mov b,a
movx a,@r0
subb a,b
movx @r0,a
inc r0
inc r1
djnz r7,long_xsubb
ret
__endasm;
}