Casting aspersions...

P. Tucker Withington ptw at vaxine.UUCP
Tue Jul 12 00:32:24 AEST 1983


Speaking of type casts, can anyone explain the following?

	char c;
	int *pi;

	main()
	{

		c = *((char *) pi);
		c = (char) *pi;

On 4.1 generates:

	movb	*_pi,_c
	cvtbl   *_pi,r0                 ; Huh?
	cvtlb	r0,_c

With MIT cc generates:

	movl	pi,a0
	movb	a0@,c
	movl	pi,a0
	movl    a0@,d0                  | Looks better
	movb	d0,c

Is that the reason for:

	/* THIS CODE IS VAX DEPENDENT IN HANDLING %l? AND %c */

	case 'c':
		b = *adx;
		for (i = 24; i >= 0; i -= 8)
			if (c = (b >> i) & 0x7f)
				putchar(c, touser);
		break;

?

				       --Tucker (ptw at vaxine.UUCP)



More information about the Comp.lang.c mailing list