Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!hp4nl!philapd!ssp1!roelof From: roelof@idca.tds.PHILIPS.nl (R. Vuurboom) Newsgroups: comp.lang.c Subject: Re: Ambiguous C? Message-ID: <111@ssp1.idca.tds.philips.nl> Date: 26 Apr 89 13:36:41 GMT Organization: Philips Telecommunication and Data Systems, The Netherlands Lines: 52 The following piece of code got me into trouble. I needed to access a register which only allows long accesses. The intention of the code is to do an int (on the motorola a long) access and then determine the 14th bit. The compiler generated a byte access for 2 bytes further and then tested the 6th bit. For locations in memory this will deliver the same result however a byte access to the register caused a bus timeout error to occur. There are basically (at least) 2 interpretations to the code: 1. dereference the location as an int then bit and with bit 13. In which case the generated code is probably wrong. 2. Determine the status of the 14th bit at the given location in which case the generated code is probably right. Does C specify which (if any) interpretation is correct? #define SCUCMD 0 #define SCU_BDID 0x2000 /* bit 14 */ error() { if ( (*(int *)(SCUCMD)) & SCU_BDID ) ; } .text .globl _error _error jra .L40000 .L40001 btst.b #5,2 <== dereferenced as byte jeq .L13 .L13 .L12 unlk a6 rts .L40000 link.w a6,#-4 jra .L40001 .data .data