Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!mephisto!ncar!boulder!uswat!uswmrg2!steve From: steve@uswmrg2.UUCP (Steve Martin) Newsgroups: comp.sys.mac.programmer Subject: Re: string initialization in assembly from Think C Message-ID: <1990Jul18.161030.15283@uswmrg2.UUCP> Date: 18 Jul 90 16:10:30 GMT References: <569@ohs.UUCP> Reply-To: steve@uswmrg2.UUCP (Steve Martin) Organization: US West Marketing Resources Group, Aurora CO. Lines: 39 In article <569@ohs.UUCP> stay@ohs.UUCP (Steve Taylor) writes: >I'm using Think C 4.01 on an SE 30. I was getting an address error >(On a Mac Plus) so I checked out the assembled code in macsbug and >here's what I found: > >C Code: > >CompareP(p1, p2) >char *p1, *p2; >{ > int i, ok = true; > long secs; > DateTimeRec theDate; > char backp[4][16] = { > "\x39\x0c\x1d\x1a\x05\x00\x00\x37\x00\x0c\x43\x3b\x0a\x01\x09\x0e", > "\x39\x0c\x1d\x1a\x05\x00\x00\x37\x00\x0c\x43\x3b\x0a\x01\x09\x0e", > "\x39\x0c\x1d\x1a\x05\x00\x00\x37\x00\x0c\x43\x3b\x0a\x01\x09\x0e", > "\x39\x0c\x1d\x1a\x05\x00\x00\x37\x00\x0c\x43\x3b\x0a\x01\x09\x0e", > }; >} > >Now, since at the time of execution A5 is 0021638E, it's obvious that >the odd address put into A1 on line 000E and accessed (by a long >operation) on line 0014 is the problem. What I want to know is (1) how >did my my string constants get put at an odd offset from A5), >and (2) if Think C put them there, shouldn't it have known >it couldn't MOVE.L them? And, (3) how am I supposed to initialize >my array of strings so that this doesn't happen? (I changed it to >a BlockMove, Thus performing my own initialization, and it worked fine.) >Am I making ridiculous assumptions about what all of this means? Yup, I ran into that same problem. I think it is a bug in Think C. To fix it declare your char array to be static. Think C then word aligns the data! Don't ask me why. -- Steve Martin | Nothing I say can be held against U S West Marketing Resources Group | Me or my employer! (...uswat.uswest.com!uswmrg2!steve)