Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!gatech!prism!vsserv!loligo!pepke
From: pepke@loligo (Eric Pepke)
Newsgroups: comp.sys.mac.programmer
Subject: Re: How do you use the THINK C assembler?
Keywords: asm, THINK C, C, assembler
Message-ID: <214@vsserv.scri.fsu.edu>
Date: 25 Sep 89 22:03:11 GMT
References: <4841@tekig5.PEN.TEK.COM>
Sender: news@vsserv.scri.fsu.edu
Reply-To: pepke@loligo.UUCP (Eric Pepke)
Organization: Supercomputer Computations Research Institute
Lines: 20

In article <4841@tekig5.PEN.TEK.COM> philj@tekig5.PEN.TEK.COM (Phil Jansen) writes:
>/* ASM CODE HERE */
>#define asmADDTONE(val, buf, bp, inc)	asm { /* BROKEN */ \
>	move.l	bp, d0\
>	swap	d0\
>	andi.l	#0x0000ffff,d0		/* bp>>16 */\
>	add.l	buf,d0\
>	move.l	d0,a0			/* a0 = buf + (bp>>16) */\
>	move.b	(a0),d0			/* d0 = buf[bp>>16] */\
>	add.w	d0,val			/* val += (a0) */\

There's one problem right there.  C knows when something is a pointer to an
integer or another type that is larger than a character and scales up the
arithmetic accordingly.  Your "add.l buf,d0" line only increases buf by d0
character positions, not d0 integer positions.

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu