DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦7a85cafe9⟧ TextFile

    Length: 727 (0x2d7)
    Types: TextFile
    Notes: UNIX file
    Names: »mneg.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libmp/mneg.c« 

TextFile

#include "mprec.h"
#include <assert.h>


/*
 *	Mneg sets the mint pointed to by "b" to negative 1 times the
 *	mint pointed to by "a".  Note that "a" == "b" is permissable.
 */

void
mneg(a, b)
mint *a, *b;
{
	register char *ap, *rp;
	register unsigned count;
	mint res;
	int mifl;

	/* allocate result space */
	mifl = ispos(a);
	res.len = a->len;
	if (mifl)
		++res.len;
	res.val = (char *)mpalc(res.len);

	/* negate and copy */
	ap = a->val;
	rp = res.val;
	count = a->len;
	while (count-- > 0)
		*rp++ = NEFL - *ap++;
	if (mifl)
		*rp = NEFL;
	++*res.val;
	assert(ap == a->val + a->len);
	assert(rp == res.val + res.len - (mifl ? 1 : 0));
	norm(&res);

	/* replace old value of b with res */
	mpfree(b->val);
	*b = res;
}