Article View: comp.arch
Article #22341Re: RISC Machine Data Structure Word Alignment Problems?
From: Peter da Silva
Date: Sun, 11 Feb 1990 15:37
Date: Sun, 11 Feb 1990 15:37
40 lines
1503 bytes
1503 bytes
Use structs internally.
Provide functions to read and write each structure, that do the needed
conversions. Never touch the external format internally.
For example:
Analog accumulator:
| flags | val.lo val.hi |
+--------+--------+--------+
| BYTE 0 | BYTE 1 | BYTE 2 |
struct accumulator {
char flags;
int value;
};
read_accumulator(addr, info)
char *addr;
struct accumulator *info;
{
info->flags = addr[0];
info->value = addr[2];
info->value = (info->value << 8) | addr[1];
}
write_accumulator(addr, info)
char *addr;
struct accumulator *info;
{
*addr++ = info->flags;
*addr++ = info & 0xFF;
*addr = (inf >> 8) & 0xFF;
}
--
_--_|\ Peter da Silva. +1 713 274 5180. <peter@ficc.uu.net>.
/ \
\_.--._/ Xenix Support -- it's not just a job, it's an adventure!
v "Have you hugged your wolf today?" `-_-'
Technical Details
Message-ID:
<S_O1_F6xds13@ficc.uu.net>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!sugar!ficc!peterReferences:
<111@melpar.UUCP> <1990Jan21.224826.1699@esegue.segue.boston.ma.us> <328@ctycal.UUCP> <17906@rpp386.cactus.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.arch,comp.lang.c Subject: Re: RISC Machine Data Structure Word Alignment Problems? Keywords: risc sun Message-ID: <S_O1_F6xds13@ficc.uu.net> Date: 11 Feb 90 15:37:37 GMT References: <111@melpar.UUCP> <1990Jan21.224826.1699@esegue.segue.boston.ma.us> <328@ctycal.UUCP> <17906@rpp386.cactus.org> Reply-To: peter@ficc.uu.net (Peter da Silva) Organization: Xenix Support, FICC Lines: 35