Path: utzoo!attcan!uunet!iconsys!ohs!stay From: stay@ohs.UUCP (Steve Taylor) Newsgroups: comp.sys.mac.programmer Subject: string initialization in assembly from Think C Message-ID: <569@ohs.UUCP> Date: 17 Jul 90 22:02:09 GMT Organization: Orem High School, Orem, Utah Lines: 60 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", }; /* ...Actual function code... */ } Compiled by Think C, disassembled by macsbug: COMPAREP +0000 LINK a6, #$FFAA MOVEQ #$01, D0 MOVE.W D0, -$004(a6) LEA -$0056(A6), A0 +000E LEA -$2D97(A5), A1 MOVEQ #$0F, D0 +0014 MOVE.L (A1)+, (A0)+ DBF D0, COMPAREP+0014 ... 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? Notes: The address error occured on a Mac Plus and SE, but not an SE 30 or II or IIcx, naturally. Go ahead. Laugh at my initialization technique. No, they aren't all the same character sequence. I got sick of typing them. Yes, I have "Separate STRS" checked. Thanks. -- Steven H. Taylor stay@ohs.uucp trACE(tm) Development, Alpine School District. ------------------------------------------------------------------------------- "Ha Ha," said Eeyore bitterly. "Merriment and whatnot. Don't apologize. It's just what WOULD happen."