|
Harry, 1. Step 1 would be to copy the next 12 bits in your source string, right adjusted, to 2 char fld. Use CPYBTL to do this. CPYBTL NextBitsRightAdjusted, From, StartBitOfs, 12. Only problem is that StartBitOfs cannot be a variable. So you need 12 CPYBTL instructions, one for each variable offset location. This results in the next 12 bits in your source string, right adjusted, in a 2 char fld. Step 2. Use CPYBTLLS to shift everybody over 4 bits, so that your 12 bits now start in bit 0 of a 2 char fld: CPYBTLLS NextBits, NextBitsRightAdjusted, 4 Step 3. Isolate the 1st 2 bits ( the 2 in from 2 to 12 bits ) right adjusted in a 1 char idx fld. CPYBTL Idx, NextBits, 0, 2 Use this Idx into the 2Bit decode table. ( 4 entries ). Each entry is 2 bytes wide. A resulting table entry value of > 999 means "not a valid bit pattern". Any other value is your decode result. Step 4. Repeat step 3, this time for 3 bits. Use the 3Bit decode table ( 8 entries ). Step 5. Repeat the decode scheme, each time for the next nbr of bits, using a decode table with the max nbr of entries needed. What are you using this for Harry ? I have seen something similar in fax compression schemes. Regards, Steve Richter ----- Original Message ----- From: "Harry Williams" <planesmart@teleteam.com> To: <MI400@midrange.com> Sent: Thursday, December 20, 2001 8:02 AM Subject: [MI400] Is there an easy way to scan for bits? > I need to change a data into variable length bits, then translate these > bits to a number. As an example. I start reading the bits, and if I > read 00110101 then I translate it to the number 0. If I read 000111 I > translate it to 1, 0111 translates to 2, 1000 goes to 3, 10011 is 8, > ..... 0100111 translates to 18. There is about 100 of these codes. My > concern is speed, since I have to translate up to 30k of these 100 > codes, if I take too many steps doing this, or if I am not efficient > then it can easily eat up the CPU. The table needs to be from 2 bits to > 12 bits. I currently see no easy way of doing this, efficiently. But > I know there are a lot smarter people than me on this list. Any > suggestions? > > Example. 00110101000111011110001011000000000001 would translate to > 0,1,2,3,4,999. > > Next, > I need to take the translated number and turn on bits. If I get > 1,2,3,4, then I would create > 1111111111. Which the 1 produces 1 bit, 2 would produce 11, 3 would > produce 111, and 4 would produce 1111. With these number I could turn > bits on or off. 1,-2,3,-4 would be 1001110000. > > > _______________________________________________ > This is the MI Programming on the AS400 / iSeries (MI400) mailing list > To post a message email: MI400@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/mi400 > or email: MI400-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/mi400. > >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.