Implement llabs and imaxabs functions.

These give the absolute value of 64-bit numbers.
This commit is contained in:
Stephen Heumann 2021-02-06 00:11:44 -06:00
parent b072f5d042
commit 6635346ae8
1 changed files with 41 additions and 0 deletions

View File

@ -496,6 +496,47 @@ labs start
lb1 creturn 4:i
end
****************************************************************
*
* long long llabs(long long i)
*
* Return the absolute value of i.
*
* Inputs:
* i - argument
*
* Outputs:
* Returns abs(i).
*
****************************************************************
*
llabs start
imaxabs entry
retptr equ 1
csubroutine (8:i),4
stx retptr
stz retptr+2
ph8 i
jsl ~ABS8
pla
sta [retptr]
ldy #2
pla
sta [retptr],y
iny
iny
pla
sta [retptr],y
iny
iny
pla
sta [retptr],y
creturn
end
****************************************************************
*
* ldiv_t ldiv(n,d)