07a2b481 (kx 2024-12-28 08:20:38 +0300 1) .\" Copyright 2024 Andrew V.Kosteltsev (kx@radix-linux.su)
07a2b481 (kx 2024-12-28 08:20:38 +0300 2) .\"
07a2b481 (kx 2024-12-28 08:20:38 +0300 3) .\"
07a2b481 (kx 2024-12-28 08:20:38 +0300 4) .TH iadc 3 "December 27, 2024" "libmpu" "LibMPU Programmer's Manual"
07a2b481 (kx 2024-12-28 08:20:38 +0300 5) .SH NAME
07a2b481 (kx 2024-12-28 08:20:38 +0300 6) \fBiadc\fP \- signed and unsigned addition with carryover
07a2b481 (kx 2024-12-28 08:20:38 +0300 7) .SH SYNOPSIS
07a2b481 (kx 2024-12-28 08:20:38 +0300 8) .nf
07a2b481 (kx 2024-12-28 08:20:38 +0300 9) .B #include <libmpu.h>
07a2b481 (kx 2024-12-28 08:20:38 +0300 10) .PP
07a2b481 (kx 2024-12-28 08:20:38 +0300 11) .BI "void iadс( mpu_int *" c ", mpu_int *" a ", mpu_int *" b ", int " nb " );
07a2b481 (kx 2024-12-28 08:20:38 +0300 12) .fi
07a2b481 (kx 2024-12-28 08:20:38 +0300 13) .SH DESCRIPTION
07a2b481 (kx 2024-12-28 08:20:38 +0300 14) The \fBiadc()\fP function performs the operation of adding integers located at addresses \fBa\fP and \fBb\fP,
07a2b481 (kx 2024-12-28 08:20:38 +0300 15) adds the value of the carry flag \fBC\fP to the obtained sum and places the result at address \fBc\fP. The
07a2b481 (kx 2024-12-28 08:20:38 +0300 16) operands can be numbers with or without a sign. The memory contents at addresses \fBa\fP, \fBb\fP are not
07a2b481 (kx 2024-12-28 08:20:38 +0300 17) changed, the previous memory contents at address \fBc\fP are lost. The \fBnb\fP parameter defines the size,
07a2b481 (kx 2024-12-28 08:20:38 +0300 18) in bytes, of the operands located at addresses \fBc\fP, \fBa\fP, \fBb\fP. Since the \fBiadc()\fP function
07a2b481 (kx 2024-12-28 08:20:38 +0300 19) uses the \fBC\fP carry flag, it can be used to add numbers whose length exceeds the maximum allowed size
07a2b481 (kx 2024-12-28 08:20:38 +0300 20) of integers.
07a2b481 (kx 2024-12-28 08:20:38 +0300 21) .PP
07a2b481 (kx 2024-12-28 08:20:38 +0300 22) The function affects the flags \fBA\fP, \fBC\fP, \fBO\fP, \fBP\fP, \fBS\fP, \fBZ\fP, and \fBV\fP.
07a2b481 (kx 2024-12-28 08:20:38 +0300 23) .PP
07a2b481 (kx 2024-12-28 08:20:38 +0300 24) Flags \fBА\fP and \fBP\fP are set only when the size of operands \fBa\fP, \fBb\fP is one or
07a2b481 (kx 2024-12-28 08:20:38 +0300 25) two bytes (\fBnb\fP == 1 || \fBnb\fP == 2).
07a2b481 (kx 2024-12-28 08:20:38 +0300 26) .sp
07a2b481 (kx 2024-12-28 08:20:38 +0300 27) .SH EXAMPLES
07a2b481 (kx 2024-12-28 08:20:38 +0300 28) .nf
07a2b481 (kx 2024-12-28 08:20:38 +0300 29) .sp
07a2b481 (kx 2024-12-28 08:20:38 +0300 30) #include <libmpu.h>
07a2b481 (kx 2024-12-28 08:20:38 +0300 31) #include <stdio.h>
07a2b481 (kx 2024-12-28 08:20:38 +0300 32)
07a2b481 (kx 2024-12-28 08:20:38 +0300 33) int main( void )
07a2b481 (kx 2024-12-28 08:20:38 +0300 34) {
07a2b481 (kx 2024-12-28 08:20:38 +0300 35) int rc = 0;
07a2b481 (kx 2024-12-28 08:20:38 +0300 36)
07a2b481 (kx 2024-12-28 08:20:38 +0300 37) __mpu_init();
07a2b481 (kx 2024-12-28 08:20:38 +0300 38) __mpu_extra_warnings = 1;
07a2b481 (kx 2024-12-28 08:20:38 +0300 39)
07a2b481 (kx 2024-12-28 08:20:38 +0300 40) {
07a2b481 (kx 2024-12-28 08:20:38 +0300 41) mpu_int128_t c, a, b;
07a2b481 (kx 2024-12-28 08:20:38 +0300 42) int nb = NB_I128;
07a2b481 (kx 2024-12-28 08:20:38 +0300 43) __mpu_char8_t s[256];
07a2b481 (kx 2024-12-28 08:20:38 +0300 44)
07a2b481 (kx 2024-12-28 08:20:38 +0300 45) iatoi( a, "237", nb ); /* evaluate the A variable */
07a2b481 (kx 2024-12-28 08:20:38 +0300 46) iatoi( b, "37", nb ); /* evaluate the B variable */
07a2b481 (kx 2024-12-28 08:20:38 +0300 47)
07a2b481 (kx 2024-12-28 08:20:38 +0300 48) __mpu_stc(); /* Set Carry Flag */
07a2b481 (kx 2024-12-28 08:20:38 +0300 49)
07a2b481 (kx 2024-12-28 08:20:38 +0300 50) iadc( c, a, b, nb );
07a2b481 (kx 2024-12-28 08:20:38 +0300 51) iitoa( s, c, RADIX_DEC, LOWERCASE, nb ); /* convert C value to ASCII string S */
e3f8685d (kx 2024-12-30 18:22:24 +0300 52) printf( "c = %s;\\n", s ); /* c = 275; */
07a2b481 (kx 2024-12-28 08:20:38 +0300 53) }
07a2b481 (kx 2024-12-28 08:20:38 +0300 54)
07a2b481 (kx 2024-12-28 08:20:38 +0300 55) __mpu_free_context();
07a2b481 (kx 2024-12-28 08:20:38 +0300 56)
07a2b481 (kx 2024-12-28 08:20:38 +0300 57) return( rc );
07a2b481 (kx 2024-12-28 08:20:38 +0300 58) }
07a2b481 (kx 2024-12-28 08:20:38 +0300 59) .fi
07a2b481 (kx 2024-12-28 08:20:38 +0300 60) .SH SEE ALSO
07a2b481 (kx 2024-12-28 08:20:38 +0300 61) .BR iadd(3),
07a2b481 (kx 2024-12-28 08:20:38 +0300 62) .BR isub(3),
41c271da (kx 2025-01-05 15:42:39 +0300 63) .BR isbb(3),
41c271da (kx 2025-01-05 15:42:39 +0300 64) .BR ishl(3),
41c271da (kx 2025-01-05 15:42:39 +0300 65) .BR ishr(3),
41c271da (kx 2025-01-05 15:42:39 +0300 66) .BR isal(3),
41c271da (kx 2025-01-05 15:42:39 +0300 67) .BR isar(3),
41c271da (kx 2025-01-05 15:42:39 +0300 68) .BR irol(3),
41c271da (kx 2025-01-05 15:42:39 +0300 69) .BR iror(3),
41c271da (kx 2025-01-05 15:42:39 +0300 70) .BR ircl(3),
41c271da (kx 2025-01-05 15:42:39 +0300 71) .BR ircr(3),
41c271da (kx 2025-01-05 15:42:39 +0300 72) .BR ishln(3),
41c271da (kx 2025-01-05 15:42:39 +0300 73) .BR ishrn(3),
41c271da (kx 2025-01-05 15:42:39 +0300 74) .BR isaln(3),
41c271da (kx 2025-01-05 15:42:39 +0300 75) .BR isarn(3),
41c271da (kx 2025-01-05 15:42:39 +0300 76) .BR iroln(3),
41c271da (kx 2025-01-05 15:42:39 +0300 77) .BR irorn(3),
41c271da (kx 2025-01-05 15:42:39 +0300 78) .BR ircln(3),
41c271da (kx 2025-01-05 15:42:39 +0300 79) .BR ircrn(3),
41c271da (kx 2025-01-05 15:42:39 +0300 80) .BR ineg(3),
41c271da (kx 2025-01-05 15:42:39 +0300 81) .BR inot(3),
41c271da (kx 2025-01-05 15:42:39 +0300 82) .BR iand(3),
41c271da (kx 2025-01-05 15:42:39 +0300 83) .BR itest(3),
41c271da (kx 2025-01-05 15:42:39 +0300 84) .BR icmp(3),
41c271da (kx 2025-01-05 15:42:39 +0300 85) .BR ior(3),
41c271da (kx 2025-01-05 15:42:39 +0300 86) .BR ixor(3),
41c271da (kx 2025-01-05 15:42:39 +0300 87) .BR iinc(3),
41c271da (kx 2025-01-05 15:42:39 +0300 88) .BR idec(3),
41c271da (kx 2025-01-05 15:42:39 +0300 89) .BR ixchg(3),
41c271da (kx 2025-01-05 15:42:39 +0300 90) .BR icpy(3),
41c271da (kx 2025-01-05 15:42:39 +0300 91) .BR icvt(3),
41c271da (kx 2025-01-05 15:42:39 +0300 92) .BR imul(3),
41c271da (kx 2025-01-05 15:42:39 +0300 93) .BR ismul(3),
41c271da (kx 2025-01-05 15:42:39 +0300 94) .BR idiv(3),
41c271da (kx 2025-01-05 15:42:39 +0300 95) .BR isdiv(3),
41c271da (kx 2025-01-05 15:42:39 +0300 96) .BR iatoi(3),
41c271da (kx 2025-01-05 15:42:39 +0300 97) .BR iatoui(3),
41c271da (kx 2025-01-05 15:42:39 +0300 98) .BR iitoa(3),
41c271da (kx 2025-01-05 15:42:39 +0300 99) .BR iuitoa(3).