.\" Copyright 2024 Andrew V.Kosteltsev (kx@radix-linux.su)
.\"
.\"
.TH iadc 3 "December 27, 2024" "libmpu" "LibMPU Programmer's Manual"
.SH NAME
\fBiadc\fP \- signed and unsigned addition with carryover
.SH SYNOPSIS
.nf
.B #include <libmpu.h>
.PP
.BI "void iadс( mpu_int *" c ", mpu_int *" a ", mpu_int *" b ", int " nb " );
.fi
.SH DESCRIPTION
The \fBiadc()\fP function performs the operation of adding integers located at addresses \fBa\fP and \fBb\fP,
adds the value of the carry flag \fBC\fP to the obtained sum and places the result at address \fBc\fP. The
operands can be numbers with or without a sign. The memory contents at addresses \fBa\fP, \fBb\fP are not
changed, the previous memory contents at address \fBc\fP are lost. The \fBnb\fP parameter defines the size,
in bytes, of the operands located at addresses \fBc\fP, \fBa\fP, \fBb\fP. Since the \fBiadc()\fP function
uses the \fBC\fP carry flag, it can be used to add numbers whose length exceeds the maximum allowed size
of integers.
.PP
The function affects the flags \fBA\fP, \fBC\fP, \fBO\fP, \fBP\fP, \fBS\fP, \fBZ\fP, and \fBV\fP.
.PP
Flags \fBА\fP and \fBP\fP are set only when the size of operands \fBa\fP, \fBb\fP is one or
two bytes (\fBnb\fP == 1 || \fBnb\fP == 2).
.sp
.SH EXAMPLES
.nf
.sp
#include <libmpu.h>
#include <stdio.h>
int main( void )
{
int rc = 0;
__mpu_init();
__mpu_extra_warnings = 1;
{
mpu_int128_t c, a, b;
int nb = NB_I128;
__mpu_char8_t s[256];
iatoi( a, "237", nb ); /* evaluate the A variable */
iatoi( b, "37", nb ); /* evaluate the B variable */
__mpu_stc(); /* Set Carry Flag */
iadc( c, a, b, nb );
iitoa( s, c, RADIX_DEC, LOWERCASE, nb ); /* convert C value to ASCII string S */
printf( "c = %s;\\n", s ); /* c = 275; */
}
__mpu_free_context();
return( rc );
}
.fi
.SH SEE ALSO
.BR iadd(3),
.BR isub(3),
.BR isbb(3),
.BR ishl(3),
.BR ishr(3),
.BR isal(3),
.BR isar(3),
.BR irol(3),
.BR iror(3),
.BR ircl(3),
.BR ircr(3),
.BR ishln(3),
.BR ishrn(3),
.BR isaln(3),
.BR isarn(3),
.BR iroln(3),
.BR irorn(3),
.BR ircln(3),
.BR ircrn(3),
.BR ineg(3),
.BR inot(3),
.BR iand(3),
.BR itest(3),
.BR icmp(3),
.BR ior(3),
.BR ixor(3),
.BR iinc(3),
.BR idec(3),
.BR ixchg(3),
.BR icpy(3),
.BR icvt(3),
.BR imul(3),
.BR ismul(3),
.BR idiv(3),
.BR isdiv(3),
.BR iatoi(3),
.BR iatoui(3),
.BR iitoa(3),
.BR iuitoa(3).