-- -- file : nibsBPs.jal -- author : special [k] -- date : 29-JAN-2004 -- purpose : Convert a byte into nibbles and bit-pairs -- pins : Defined below -- -- Copyright (C) 2004 special [k] -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Library General Public License for more details. -- -- You should have received a copy of the GNU Library General Public -- License along with this library; if not, write to the -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- Boston, MA 02111-1307, USA. -- procedure byteToNibs( byte in _theNibsByte, byte out _nibbleHigh, byte out _nibbleLow ) is _nibbleHigh = ( _theNibsByte >> 4 ) _nibbleLow = _theNibsByte & 0x0F end procedure procedure byteToBPs( byte in _theBPByte, byte out _bits76, byte out _bits54, byte out _bits32, byte out _bits10 ) is _bits76 = ( _theBPByte >> 6) & 0x03 _bits54 = ( _theBPByte >> 4) & 0x03 _bits32 = ( _theBPByte >> 2) & 0x03 _bits10 = _theBPByte & 0x03 end procedure -- Could use these, but it takes up more space and is slower (better to use code above): -- nibbleHigh = ( theByte >> 4 ) -- nibbleLow = ( ( theByte << 4 ) >> 4 ) -- nibbleLow = theByte & 0x0f -- asm swapf theByte, f -- nibbleHigh = theByte & 0x0f -- bits76 = ( theByte >> 6 ) -- bits54 = ( ( theByte << 2 ) >> 6 ) -- bits32 = ( ( theByte << 4 ) >> 6 ) -- bits10 = ( ( theByte << 6 ) >> 6 )