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

⟦782a87b52⟧ TextFile

    Length: 652 (0x28c)
    Types: TextFile
    Notes: UNIX file
    Names: »mitom.c«

Derivation

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

TextFile

#include "mprec.h"

/*
 *	Mitom sets the mint pointed to by "mp" to have a value equal
 *	to the int "n".
 */

void
mitom(n, mp)
int	n;
mint	*mp;
{
	int an;
	char mifl;	/* minus flag */
	char tev[NORSIZ];	/* temporary for converted value */
	register char *rp, *limit, *value;

	mpfree(mp->val);
	an = ((mifl = n<0) ? -n : n);
	rp = tev;
	while (an != 0) {
		*rp++ = an % BASE;
		an >>= L2BASE;
	}
	*rp++ = 0;
	limit = rp;
	if (mifl) {
		rp = tev - 1;
		while (++rp < limit)
			*rp = NEFL - *rp;
		++*tev;
	}
	value = (char *)mpalc(limit - tev);
	mp->val = value;
	mp->len = limit - tev;
	rp = tev;
	while (rp < limit)
		*value++ = *rp++;
	norm(mp);
}