* packed bits question
@ 2005-11-16 5:21 chris
2005-11-16 6:31 ` Robert Plantz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: chris @ 2005-11-16 5:21 UTC (permalink / raw)
To: linux-assembly
Hello all,
I have an assignment that requires me to write a simple database
in assembly using Linux (GNU as, GNU ld, etc.).
I have to store IDs and their corresponding values, but the
requirement (and this is why I need help) is that the IDs are 8
bits each, followed immediately by 6 bits (six!) for the value,
then, without padding two bits, the next data entry follows (8
bits again for another ID, 6 bits for the next value, and so on).
I have initialized the DB in a C function (initialize implies the
8 bits for each ID is set to 0xFF (-1)) but now in an assembly
routine I need to search for IDs that are -1. Obviously for the
first ID it is simply the first byte, but how do I access the
second, third, fourth, etc. IDs easily?
Basically, how can I easily work with something as bastardly as a
14-bit, no-packing data pairs?
Thanks for all your help,
Chris Thielen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: packed bits question
2005-11-16 5:21 packed bits question chris
@ 2005-11-16 6:31 ` Robert Plantz
2005-11-16 8:23 ` Karthik Ravikanti
2005-11-16 16:20 ` joy merwin monteiro
2 siblings, 0 replies; 4+ messages in thread
From: Robert Plantz @ 2005-11-16 6:31 UTC (permalink / raw)
To: chris, linux-assembly
This will probably involve using the shl and shr (shift left and shift
right), and, or instructions. (Instruction names, not English words.)
I would draw a lot of diagrams showing how things are stored and what I
need to do to store them that way or unravel them. After a while, you
should see some patterns evolving. That should show you what algorithms
you need.
My recommendation comes from writing many, many thousands of lines of
assembly langauge for commercial applications over the past 30+ years, and
over 20 years experience teaching the subject. Even with my experience, I
would need to draw the diagrams before I could write any code.
Bob
On Tue, 15 Nov 2005 21:21:01 -0800, <chris@luethy.net> wrote:
> Hello all,
> I have an assignment that requires me to write a simple database
> in assembly using Linux (GNU as, GNU ld, etc.).
> I have to store IDs and their corresponding values, but the
> requirement (and this is why I need help) is that the IDs are 8
> bits each, followed immediately by 6 bits (six!) for the value,
> then, without padding two bits, the next data entry follows (8
> bits again for another ID, 6 bits for the next value, and so on).
> I have initialized the DB in a C function (initialize implies the
> 8 bits for each ID is set to 0xFF (-1)) but now in an assembly
> routine I need to search for IDs that are -1. Obviously for the
> first ID it is simply the first byte, but how do I access the
> second, third, fourth, etc. IDs easily?
> Basically, how can I easily work with something as bastardly as a
> 14-bit, no-packing data pairs?
>
> Thanks for all your help,
> Chris Thielen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: packed bits question
2005-11-16 5:21 packed bits question chris
2005-11-16 6:31 ` Robert Plantz
@ 2005-11-16 8:23 ` Karthik Ravikanti
2005-11-16 16:20 ` joy merwin monteiro
2 siblings, 0 replies; 4+ messages in thread
From: Karthik Ravikanti @ 2005-11-16 8:23 UTC (permalink / raw)
To: chris; +Cc: linux-assembly
> Basically, how can I easily work with something as bastardly as a
> 14-bit, no-packing data pairs?
Did you really mean to use *bastardly*? Or was it supposed to be
dastardly?
Just curious,
Luck,
Karthik
>
> Thanks for all your help,
> Chris Thielen
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
R.Karthik,
200330022,
B.Tech,E.C.E.,
IIIT,HYD.
-------------------------------------------------------
Let there be Sound!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: packed bits question
2005-11-16 5:21 packed bits question chris
2005-11-16 6:31 ` Robert Plantz
2005-11-16 8:23 ` Karthik Ravikanti
@ 2005-11-16 16:20 ` joy merwin monteiro
2 siblings, 0 replies; 4+ messages in thread
From: joy merwin monteiro @ 2005-11-16 16:20 UTC (permalink / raw)
To: chris@luethy.net; +Cc: linux-assembly
Hi,
as Robert said, you could do the assembly equivalent of this macro:
#define GET_BIT(ptr,bitnum) ptr[(bitnum>>3)]>>(7-(bitnum%8))
Joy
--
Girls are like slugs.... You know they are around for a reason, but
you cant imagine what.
-- Calvin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-11-16 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-16 5:21 packed bits question chris
2005-11-16 6:31 ` Robert Plantz
2005-11-16 8:23 ` Karthik Ravikanti
2005-11-16 16:20 ` joy merwin monteiro
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.