home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mips
- Path: sparky!uunet!gatech!darwin.sura.net!jvnc.net!yale.edu!think.com!paperboy.osf.org!meissner
- From: meissner@osf.org (Michael Meissner)
- Subject: Re: mips cc word alignment
- In-Reply-To: nicholas@cton.cton.com's message of 2 Sep 92 21:31:10 GMT
- Message-ID: <MEISSNER.92Sep3142433@curley.osf.org>
- Sender: news@osf.org (USENET News System)
- Organization: Open Software Foundation
- References: <1992Sep2.213110.1916@cton.com>
- Date: 3 Sep 92 14:24:33
- Lines: 62
-
- In article <1992Sep2.213110.1916@cton.com> nicholas@cton.cton.com (Nick Hennenfent) writes:
-
- |
- | Is there any way to make the mips cc compiler read
- | a word (32 bit) from a non (word) aligned address?
- | It seems like the LWL/LWR instructions make this feasible.
- |
- | The #pragma pack directive seems to have no effect.
- |
- | I know such a thing is not optimal but would be
- | convenient in certain circumstances.
-
- struct s { char a[4]; };
-
- int convert (p)
- struct s *p;
- {
- union { struct s st; int i; } u;
-
- u.st = *p;
- return u.i;
- }
-
- Produces the code (GCC 2.2.2 produces the same code):
-
- .verstamp 2 10
- .text
- .align 2
- .file 2 "foo.c"
- .globl convert
- .loc 2 5
- # 1 struct s { char a[4]; };
- # 2
- # 3 int convert (p)
- # 4 struct s *p;
- # 5 {
- .ent convert 2
- convert:
- .option O2
- subu $sp, 8
- .frame $sp, 8, $31
- .loc 2 8
- # 6 union { struct s st; int i; } u;
- # 7
- # 8 u.st = *p;
- addu $14, $sp, 4
- .set noat
- ulw $1, 0($4)
- usw $1, 0($14)
- .set at
- .loc 2 9
- # 9 return u.i;
- lw $2, 4($sp)
- addu $sp, 8
- j $31
- .end convert
-
- --
- Michael Meissner email: meissner@osf.org phone: 617-621-8861
- Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
-
- You are in a twisty little passage of standards, all conflicting.
-