From kpopple@imp.sim.es.com Mon Dec 7 10:35:52 1992 Received: from calvin.sfasu.edu by umaxc.weeg.uiowa.edu (5.61.jnf/920629) on Mon, 7 Dec 92 10:35:47 -0600 id AA28337 with SMTP Received: from orca.es.com (ES.COM) by calvin.sfasu.EDU with SMTP (5.59/25-eef) id AA05370; Mon, 7 Dec 92 10:29:10 CST Return-Path: Received: from imp ([130.187.201.17]) by orca.es.com (4.1/SMI-4.1) id AA05181; Mon, 7 Dec 92 09:25:42 MST Received: by imp (4.1/E&S_client-ver1.5/SMI-4.1) id AA13989; Mon, 7 Dec 92 09:26:28 MST Date: Mon, 7 Dec 92 09:26:28 MST From: kpopple@imp.sim.es.com (Ken Poppleton) Message-Id: <9212071626.AA13989@imp> To: hyperc-l@calvin.sfasu.edu Subject: Re:C quiz Status: R from Basil Johnson > The problem lies between the 2nd and 3rd jsr 4, printf. When I > changed the #define OA_KEY 0xc061 to the explicit declaration unsigned > OA_KEY = 0xc061; the program worked OK. So the problem is not with > the macro. Here's the code that that version generated and a > comparison with the first. . . . > I'm not familiar enough with the opcodes to decipher what's happening. > However, since one can't do '#define unsigned OA_KEY 0xc061', my guess > is that either #define does not accept an unsigned integer (what do > the gurus say) or HyperC is generating incorrect code in this > instance. Looks like I am getting 0x7f61 instead of 0xc061. > > So, is this a bug? I do not use Hyper-C (YET) but from my use of Unix C I would consider the following... As I believe that Hyper-C is a 16 bit system, then the integer 0xc061 is actually a negative integer, if assigned to an unsigned variable the sign bit may be lost. The define #define OA_KEY 0xc061 defines OA_KEY to the integer (default type) 0xc061 which is -16287. If you want it to be an unsigned integer, try the define #define OA_KEY ((unsigned int)0xc061) In the second section above, the define attempt of #define unsigned OA_KEY 0xc061 does not fit the definition of define from K&R which states #define identifer token where all subsequent instances of the identifier are replaced with the token. Or the alternate form of #define identifer(param,param,...param) token performs the substitution of identifer with token and each occurance of param in token is replaced with the corrisponding param. I hope this is of some help. Ken Poppleton kpopple@imp.sim.es.com