anchor.diff:  	    {{Mantissa, Base, Exp}, Buffer4, RemBytes2+RemBytes3}
       end.
   
  -
  -%%============================================================================
  -%% Bitstring value, ITU_T X.690 Chapter 8.6
  -%%
  -%% encode bitstring value
  -%%
  -%% bitstring NamedBitList
  -%% Val can be  of:
  -%% - [identifiers] where only named identifers are set to one,
  -%%   the Constraint must then have some information of the
  -%%   bitlength.
  -%% - [list of ones and zeroes] all bits
  -%% - integer value representing the bitlist
  -%% C is constrint Len, only valid when identifiers
  -%%============================================================================
  -
  -encode_bit_string(C,Bin={Unused,BinBits},NamedBitList,DoTag) when is_integer(Unused), is_binary(BinBits) ->
  -    encode_bin_bit_string(C,Bin,NamedBitList,DoTag);
  -encode_bit_string(C, [FirstVal | RestVal], NamedBitList, DoTag) when is_atom(FirstVal) ->
  -    encode_bit_string_named(C, [FirstVal | RestVal], NamedBitList, DoTag);
  -
  -encode_bit_string(C, [{bit,X} | RestVal], NamedBitList, DoTag) ->
  -    encode_bit_string_named(C, [{bit,X} | RestVal], NamedBitList, DoTag);
  -
  -encode_bit_string(C, [FirstVal| RestVal], NamedBitList, DoTag) when is_integer(FirstVal) ->
  -    encode_bit_string_bits(C, [FirstVal | RestVal], NamedBitList, DoTag);
  -
  -encode_bit_string(_, 0, _, []) ->
  -    {[?N_BIT_STRING,1,0],3};
  -
  -encode_bit_string(_, 0, _, DoTag) ->
  -    dotag(DoTag, ?N_BIT_STRING, {<<0>>,1});
  -
  -encode_bit_string(_, [], _, []) ->
  -    {[?N_BIT_STRING,1,0],3};
  -
  -encode_bit_string(_, [], _, DoTag) ->
  -    dotag(DoTag, ?N_BIT_STRING, {<<0>>,1});
  -
  -encode_bit_string(C, IntegerVal, NamedBitList, DoTag) when is_integer(IntegerVal) ->
  -    BitListVal = int_to_bitlist(IntegerVal),
  -    encode_bit_string_bits(C, BitListVal, NamedBitList, DoTag);
  -
  -encode_bit_string(C, {Name,BitList}, NamedBitList, DoTag) when is_atom(Name) ->
  -    encode_bit_string(C, BitList, NamedBitList, DoTag).
  -
  -
  -
  -int_to_bitlist(0) ->
  -    [];
  -int_to_bitlist(Int) when is_integer(Int), Int >= 0 ->
  -    [Int band 1 | int_to_bitlist(Int bsr 1)].
  -
  -
  -%%=================================================================
  -%% Encode BIT STRING of the form {Unused,BinBits}.
  -%% Unused is the number of unused bits in the last byte in BinBits
  -%% and BinBits is a binary representing the BIT STRING.
  -%%=================================================================
  -encode_bin_bit_string(C,{Unused,BinBits},_NamedBitList,DoTag)->
  -    case get_constraint(C,'SizeConstraint') of
  -	no ->
  -	    remove_unused_then_dotag(DoTag,?N_BIT_STRING,Unused,BinBits);
  -	{_Min,Max} ->
  -	    BBLen = (size(BinBits)*8)-Unused,
  -	    if
  -		BBLen > Max ->
  -		    exit({error,{asn1,
  -				 {bitstring_length,
  -				  {{was,BBLen},{maximum,Max}}}}});
  -		true ->
  -		    remove_unused_then_dotag(DoTag,?N_BIT_STRING,
  -					     Unused,BinBits)
  -	    end;
  -	Size ->
  -	    case ((size(BinBits)*8)-Unused) of
  -		BBSize when BBSize =< Size ->
  -		    remove_unused_then_dotag(DoTag,?N_BIT_STRING,
  -					     Unused,BinBits);
  -		BBSize  ->
  -		    exit({error,{asn1,
  -				 {bitstring_length,
  -				  {{was,BBSize},{should_be,Size}}}}})
  -	    end
  -    end.
  -
  -remove_unused_then_dotag(DoTag,StringType,Unused,BinBits) ->
  -    case Unused of
  -	0 when (byte_size(BinBits) =:= 0), DoTag =:= [] ->
  -	    %% time optimization of next case
  -	   {[StringType,1,0],3};
  -	0 when (byte_size(BinBits) =:= 0) ->
  -	    dotag(DoTag,StringType,{<<0>>,1});
  -	0 when DoTag =:= [] -> % time optimization of next case
  -	    dotag_universal(StringType,[Unused|[BinBits]],size(BinBits)+1);
  -% 	    {LenEnc,Len} = encode_legth(size(BinBits)+1),
  -% 	    {[StringType,LenEnc,[Unused|BinBits]],size(BinBits)+1+Len+1};
  -	0 ->
  -	    dotag(DoTag,StringType,<<Unused,BinBits/binary>>);
  -	Num when DoTag =:= [] -> % time optimization of next case
  -	    N = byte_size(BinBits) - 1,
  -	    <<BBits:N/binary,LastByte>> = BinBits,
  -	    dotag_universal(StringType,
  -			    [Unused,BBits,(LastByte bsr Num) bsl Num],
  -			    byte_size(BinBits) + 1);
  -% 	    {LenEnc,Len} = encode_legth(size(BinBits)+1),
  -% 	    {[StringType,LenEnc,[Unused,BBits,(LastByte bsr Num) bsl Num],
  -% 	      1+Len+size(BinBits)+1};
  -	Num ->
  -	    N = byte_size(BinBits) - 1,
  -	    <<BBits:N/binary,LastByte>> = BinBits,
  -	    dotag(DoTag,StringType,{[Unused,binary_to_list(BBits) ++
  -				     [(LastByte bsr Num) bsl Num]],
  -				    byte_size(BinBits) + 1})
  -    end.
  -
  -
  -%%=================================================================
  -%% Encode named bits
  -%%=================================================================
  -
  -encode_bit_string_named(C, [FirstVal | RestVal], NamedBitList, DoTag) ->
  -    {Len,Unused,OctetList} =
  -	case get_constraint(C,'SizeConstraint') of
  -	    no ->
  -		ToSetPos = get_all_bitposes([FirstVal | RestVal],
  -					    NamedBitList, []),
  -		BitList = make_and_set_list(lists:max(ToSetPos)+1,
  -					    ToSetPos, 0),
  -		encode_bitstring(BitList);
  -	    {_Min,Max} ->
  -		ToSetPos = get_all_bitposes([FirstVal | RestVal],
  -					    NamedBitList, []),
  -		BitList = make_and_set_list(Max, ToSetPos, 0),
  -		encode_bitstring(BitList);
  -	    Size ->
  -		ToSetPos = get_all_bitposes([FirstVal | RestVal],
  -					    NamedBitList, []),
  -		BitList = make_and_set_list(Size, ToSetPos, 0),
  -		encode_bitstring(BitList)
  -	end,
  -    case DoTag of
  -	[] ->
  -	    dotag_universal(?N_BIT_STRING,[Unused|OctetList],Len+1);
  -% 	    {EncLen,LenLen} = encode_length(Len+1),
  -% 	    {[?N_BIT_STRING,EncLen,Unused,OctetList],1+LenLen+Len+1};
  -	_ ->
  -	    dotag(DoTag, ?N_BIT_STRING, {[Unused|OctetList],Len+1})
  -    end.
  -
  -
  -%%----------------------------------------
  -%% get_all_bitposes([list of named bits to set], named_bit_db, []) ->
  -%%   [sorted_list_of_bitpositions_to_set]
  -%%----------------------------------------
  -
  -get_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->
  -    get_all_bitposes(Rest, NamedBitList, [ValPos | Ack ]);
  -get_all_bitposes([Val | Rest], NamedBitList, Ack) when is_atom(Val) ->
  -    case lists:keyfind(Val, 1, NamedBitList) of
  -	{_ValName, ValPos} ->
  -	    get_all_bitposes(Rest, NamedBitList, [ValPos | Ack]);
  -	_ ->
  -	    exit({error,{asn1, {bitstring_namedbit, Val}}})
  -    end;
  -get_all_bitposes([], _NamedBitList, Ack) ->
  -    lists:sort(Ack).
  -
  -
  -%%----------------------------------------
  -%% make_and_set_list(Len of list to return, [list of positions to set to 1])->
  -%% returns list of Len length, with all in SetPos set.
  -%% in positioning in list the first element is 0, the second 1 etc.., but
  -%% Len will make a list of length Len, not Len + 1.
  -%%    BitList = make_and_set_list(C, ToSetPos, 0),
  -%%----------------------------------------
  -
  -make_and_set_list(0, [], _) -> [];
  -make_and_set_list(0, _, _) ->
  -    exit({error,{asn1,bitstring_sizeconstraint}});
  -make_and_set_list(Len, [XPos|SetPos], XPos) ->
  -    [1 | make_and_set_list(Len - 1, SetPos, XPos + 1)];
  -make_and_set_list(Len, [Pos|SetPos], XPos) ->
  -    [0 | make_and_set_list(Len - 1, [Pos | SetPos], XPos + 1)];
  -make_and_set_list(Len, [], XPos) ->
  -    [0 | make_and_set_list(Len - 1, [], XPos + 1)].
  -
  -
  -%%=================================================================
  -%% Encode bit string for lists of ones and zeroes
  -%%=================================================================
  -encode_bit_string_bits(C, BitListVal, _NamedBitList, DoTag) when is_list(BitListVal) ->
  -    {Len,Unused,OctetList} =
  -	case get_constraint(C,'SizeConstraint') of
  -	    no ->
  -		encode_bitstring(BitListVal);
  -	    Constr={Min,_Max} when is_integer(Min) ->
  -		encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
  -	    {Constr={_,_},[]} ->
  -		%% constraint with extension mark
  -		encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
  -	    Constr={{_,_},{_,_}} ->%{{Min1,Max1},{Min2,Max2}}
  -		%% constraint with extension mark
  -		encode_constr_bit_str_bits(Constr,BitListVal,DoTag);
  -	    Size ->
  -		case length(BitListVal) of
  -		    BitSize when BitSize =:= Size ->
  -			encode_bitstring(BitListVal);
  -		    BitSize when BitSize < Size ->
  -			PaddedList =
  -			    pad_bit_list(Size-BitSize,BitListVal),
  -			encode_bitstring(PaddedList);
  -		    BitSize ->
  -			exit({error,
  -			      {asn1,
  -			       {bitstring_length,
  -				{{was,BitSize},
  -				 {should_be,Size}}}}})
  -		end
  -	end,
  -    %%add unused byte to the Len
  -    case DoTag of
  -	[] ->
  -	    dotag_universal(?N_BIT_STRING,[Unused|OctetList],Len+1);
  -% 	    {EncLen,LenLen}=encode_length(Len+1),
  -% 	    {[?N_BIT_STRING,EncLen,Unused|OctetList],1+LenLen+Len+1};
  -	_ ->
  -	    dotag(DoTag, ?N_BIT_STRING,
  -		  {[Unused | OctetList],Len+1})
  -    end.
  -
  -
  -encode_constr_bit_str_bits({{_Min1,Max1},{Min2,Max2}},BitListVal,_DoTag) ->
  -    BitLen = length(BitListVal),
  -    case BitLen of
  -	Len when Len > Max2 ->
  -	    exit({error,{asn1,{bitstring_length,{{was,BitLen},
  -						 {maximum,Max2}}}}});
  -	Len when Len > Max1, Len < Min2  ->
  -	    exit({error,{asn1,{bitstring_length,{{was,BitLen},
  -						 {not_allowed_interval,
  -						  Max1,Min2}}}}});
  -	_ ->
  -	    encode_bitstring(BitListVal)
  -    end;
  -encode_constr_bit_str_bits({Min,Max},BitListVal,_DoTag) ->
  -    BitLen = length(BitListVal),
  -    if
  -	BitLen > Max ->
  -	    exit({error,{asn1,{bitstring_length,{{was,BitLen},
  -						 {maximum,Max}}}}});
  -	BitLen < Min ->
  -	    exit({error,{asn1,{bitstring_length,{{was,BitLen},
  -						 {minimum,Min}}}}});
  -	true ->
  -	    encode_bitstring(BitListVal)
  -    end.
  -
  -
  -%% returns a list of length Size + length(BitListVal), with BitListVal
  -%% as the most significant elements followed by padded zero elements
  -pad_bit_list(Size,BitListVal) ->
  -    Tail = lists:duplicate(Size,0),
  -    BitListVal ++ Tail.
  -
  -%%=================================================================
  -%% Do the actual encoding
  -%%     ([bitlist]) -> {ListLen, UnusedBits, OctetList}
  -%%=================================================================
  -
  -encode_bitstring([B8, B7, B6, B5, B4, B3, B2, B1 | Rest]) ->
  -    Val = (B8 bsl 7) bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) bor
  -	(B4 bsl 3) bor (B3 bsl 2) bor (B2 bsl 1) bor B1,
  -    encode_bitstring(Rest, [Val], 1);
  -encode_bitstring(Val) ->
  -    {Unused, Octet} = unused_bitlist(Val, 7, 0),
  -    {1, Unused, [Octet]}.
  -
  -encode_bitstring([B8, B7, B6, B5, B4, B3, B2, B1 | Rest], Ack, Len) ->
  -    Val = (B8 bsl 7) bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4) bor
  -	(B4 bsl 3) bor (B3 bsl 2) bor (B2 bsl 1) bor B1,
  -    encode_bitstring(Rest, [Ack | [Val]], Len + 1);
  -%%even multiple of 8 bits..
  -encode_bitstring([], Ack, Len) ->
  -    {Len, 0, Ack};
  -%% unused bits in last octet
  -encode_bitstring(Rest, Ack, Len) ->
  -%    io:format("uneven ~w ~w ~w~n",[Rest, Ack, Len]),
  -    {Unused, Val} = unused_bitlist(Rest, 7, 0),
  -    {Len + 1, Unused, [Ack | [Val]]}.
  -
  -%%%%%%%%%%%%%%%%%%
  -%% unused_bitlist([list of ones and zeros <= 7], 7, []) ->
  -%%  {Unused bits, Last octet with bits moved to right}
  -unused_bitlist([], Trail, Ack) ->
  -    {Trail + 1, Ack};
  -unused_bitlist([Bit | Rest], Trail, Ack) ->
  -%%    io:format("trail Bit: ~w Rest: ~w Trail: ~w Ack:~w~n",[Bit, Rest, Trail, Ack]),
  -    unused_bitlist(Rest, Trail - 1, (Bit bsl Trail) bor Ack).
  -
  -
  -%%============================================================================
  -%% decode bitstring value
  -%%    (Buffer, Range, NamedNumberList, HasTag, TotalLen) -> {Integer, Remain, RemovedBytes}
  -%%============================================================================
  -
  -decode_compact_bit_string(Buffer, Range, NamedNumberList, Tags, LenIn, OptOrMand) ->
  -%    NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_BIT_STRING}),
  -     decode_restricted_string(Buffer, Range, ?N_BIT_STRING, Tags, LenIn,
  -			     NamedNumberList, OptOrMand,bin).
  -
  -decode_bit_string(Buffer, Range, NamedNumberList, Tags, LenIn, OptOrMand) ->
  -%    NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_BIT_STRING}),
  -    decode_restricted_string(Buffer, Range, ?N_BIT_STRING, Tags, LenIn,
  -			     NamedNumberList, OptOrMand,old).
  -
  -
  -decode_bit_string2(1,<<0 ,Buffer/binary>>,_NamedNumberList,RemovedBytes,BinOrOld) ->
  -    case BinOrOld of
  -	bin ->
  -	    {{0,<<>>},Buffer,RemovedBytes};
  -	_ ->
  -	    {[], Buffer, RemovedBytes}
  -    end;
  -decode_bit_string2(Len,<<Unused,Buffer/binary>>,NamedNumberList,
  -		   RemovedBytes,BinOrOld) ->
  -    L = Len - 1,
  -    <<Bits:L/binary,BufferTail/binary>> = Buffer,
  -    case NamedNumberList of
  -	[] ->
  -	    case BinOrOld of
  -		bin ->
  -		    {{Unused,Bits},BufferTail,RemovedBytes};
  -		_ ->
  -		    BitString = decode_bitstring2(L, Unused, Buffer),
  -		    {BitString,BufferTail, RemovedBytes}
  -	    end;
  -	_ ->
  -	    BitString = decode_bitstring2(L, Unused, Buffer),
  -	    {decode_bitstring_NNL(BitString,NamedNumberList),
  -	     BufferTail,
  -	     RemovedBytes}
  -    end.
  -
  -%%----------------------------------------
  -%% Decode the in buffer to bits
  -%%----------------------------------------
  -decode_bitstring2(1,Unused,<<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,_/binary>>) ->
  -    lists:sublist([B7,B6,B5,B4,B3,B2,B1,B0],8-Unused);
  -decode_bitstring2(Len, Unused,
  -		  <<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,Buffer/binary>>) ->
  -    [B7, B6, B5, B4, B3, B2, B1, B0 |
  -     decode_bitstring2(Len - 1, Unused, Buffer)].
  -
  -%%decode_bitstring2(1, Unused, Buffer) ->
  -%%    make_bits_of_int(hd(Buffer), 128, 8-Unused);
  -%%decode_bitstring2(Len, Unused, [BitVal | Buffer]) ->
  -%%    [B7, B6, B5, B4, B3, B2, B1, B0] = make_bits_of_int(BitVal, 128, 8),
  -%%    [B7, B6, B5, B4, B3, B2, B1, B0 |
  -%%     decode_bitstring2(Len - 1, Unused, Buffer)].
  -
  -
  -%%make_bits_of_int(_, _, 0) ->
  -%%    [];
  -%%make_bits_of_int(BitVal, MaskVal, Unused) when Unused > 0 ->
  -%%    X = case MaskVal band BitVal of
  -%%	    0 -> 0 ;
  -%%	    _ -> 1
  -%%	end,
  -%%    [X | make_bits_of_int(BitVal, MaskVal bsr 1, Unused - 1)].
  -
  -
  -
  -%%----------------------------------------
  -%% Decode the bitlist to names
  -%%----------------------------------------
  -
  -decode_bitstring_NNL(BitList,NamedNumberList) ->
  -    decode_bitstring_NNL(BitList,NamedNumberList,0,[]).
  -
  -
  -decode_bitstring_NNL([],_,_No,Result) ->
  -    lists:reverse(Result);
  -
  -decode_bitstring_NNL([B|BitList],[{Name,No}|NamedNumberList],No,Result) ->
  -    if
  -	B =:= 0 ->
  -	    decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result);
  -	true ->
  -	    decode_bitstring_NNL(BitList,NamedNumberList,No+1,[Name|Result])
  -    end;
  -decode_bitstring_NNL([1|BitList],NamedNumberList,No,Result) ->
  -    decode_bitstring_NNL(BitList,NamedNumberList,No+1,[{bit,No}|Result]);
  -decode_bitstring_NNL([0|BitList],NamedNumberList,No,Result) ->
  -    decode_bitstring_NNL(BitList,NamedNumberList,No+1,Result).
  -
  -
  -%%============================================================================
  -%% Octet string, ITU_T X.690 Chapter 8.7
  -%%
  -%% encode octet string
  -%% The OctetList must be a flat list of integers in the range 0..255
  -%% the function does not check this because it takes to much time
  -%%============================================================================
  -encode_octet_string(_C, OctetList, []) when is_binary(OctetList) ->
  -    dotag_universal(?N_OCTET_STRING,OctetList,byte_size(OctetList));
  -encode_octet_string(_C, OctetList, DoTag) when is_binary(OctetList) ->
  -    dotag(DoTag, ?N_OCTET_STRING, {OctetList,byte_size(OctetList)});
  -encode_octet_string(_C, OctetList, DoTag) when is_list(OctetList) ->
  -    case length(OctetList) of
  -	Len when DoTag =:= [] ->
  -	    dotag_universal(?N_OCTET_STRING,OctetList,Len);
  -	Len ->
  -	    dotag(DoTag, ?N_OCTET_STRING, {OctetList,Len})
  -    end;
  -%% encode_octet_string(C, OctetList, DoTag) when is_list(OctetList) ->
  -%%     dotag(DoTag, ?N_OCTET_STRING, {OctetList,length(OctetList)});
  -encode_octet_string(C, {Name,OctetList}, DoTag) when is_atom(Name) ->
  -    encode_octet_string(C, OctetList, DoTag).
  -
  -
  -%%============================================================================
  -%% decode octet string
  -%%    (Buffer, Range, HasTag, TotalLen) -> {String, Remain, RemovedBytes}
  -%%
  -%% Octet string is decoded as a restricted string
  -%%============================================================================
  -decode_octet_string(Buffer, Range, Tags, TotalLen, OptOrMand) ->
  -%%  NewTags = new_tags(HasTag,#tag{class=?UNIVERSAL,number=?N_OCTET_STRING}),
  -    decode_restricted_string(Buffer, Range, ?N_OCTET_STRING,
  -			     Tags, TotalLen, [], OptOrMand,old).
  -
  -%%============================================================================
  -%% Null value, ITU_T X.690 Chapter 8.8
  -%%
  -%% encode NULL value
  -%%============================================================================
  -
  -encode_null(_, []) ->
  -    {[?N_NULL,0],2};
  -encode_null(_, DoTag) ->
  -    dotag(DoTag, ?N_NULL, {[],0}).
  -
  -%%============================================================================
  -%% decode NULL value
  -%%    (Buffer, HasTag, TotalLen) -> {NULL, Remain, RemovedBytes}
  -%%============================================================================
  -decode_null(Buffer, Tags, OptOrMand) ->
  -    NewTags = new_tags(Tags,#tag{class=?UNIVERSAL,number=?N_NULL}),
  -    decode_null_notag(Buffer, NewTags, OptOrMand).
  -
  -decode_null_notag(Buffer, Tags, OptOrMand) ->
  -    {RestTags, {FormLen, Buffer0, Rb0}} =
  -	check_tags_i(Tags, Buffer, OptOrMand),
  -
  -    case FormLen of
  -	{?CONSTRUCTED,Len} ->
  -	    {_Buffer00,RestBytes} = split_list(Buffer0,Len),
  -	    {Val01, Buffer01, Rb01} = decode_null_notag(Buffer0, RestTags,
  -							OptOrMand),
  -	    {Buffer02, Rb02} = restbytes2(RestBytes,Buffer01,noext),
  -	    {Val01, Buffer02, Rb0+Rb01+Rb02};
  -	{_,0} ->
  -	    {'NULL', Buffer0, Rb0};
  -	{_,Len} ->
  -	    exit({error,{asn1,{invalid_length,'NULL',Len}}})
  -    end.
  -
  -
  -%%============================================================================
  -%% Object identifier, ITU_T X.690 Chapter 8.19
  -%%
  -%% encode Object Identifier value
  -%%============================================================================
  -
  -encode_object_identifier({Name,Val}, DoTag) when is_atom(Name) ->
  -    encode_object_identifier(Val, DoTag);
  -encode_object_identifier(Val, []) ->
  -    {EncVal,Len} = e_object_identifier(Val),
  -    dotag_universal(?N_OBJECT_IDENTIFIER,EncVal,Len);
  -encode_object_identifier(Val, DoTag) ->
  -    dotag(DoTag, ?N_OBJECT_IDENTIFIER, e_object_identifier(Val)).
  -
  -e_object_identifier({'OBJECT IDENTIFIER', V}) ->
  -    e_object_identifier(V);
  -e_object_identifier({Cname, V}) when is_atom(Cname), is_tuple(V) ->
  -    e_object_identifier(tuple_to_list(V));
  -e_object_identifier({Cname, V}) when is_atom(Cname), is_list(V) ->
  -    e_object_identifier(V);
  -e_object_identifier(V) when is_tuple(V) ->
  -    e_object_identifier(tuple_to_list(V));
  -
  -%%%%%%%%%%%%%%%
  -%% e_object_identifier([List of Obect Identifiers]) ->
  -%% {[Encoded Octetlist of ObjIds], IntLength}
  -%%
  -e_object_identifier([E1, E2 | Tail]) ->
  -    Head = 40*E1 + E2,  % wow!
  -    {H,Lh} = mk_object_val(Head),
  -    {R,Lr} = enc_obj_id_tail(Tail, [], 0),
  -    {[H|R], Lh+Lr}.
  -
  -enc_obj_id_tail([], Ack, Len) ->
  -    {lists:reverse(Ack), Len};
  -enc_obj_id_tail([H|T], Ack, Len) ->
  -    {B, L} = mk_object_val(H),
  -    enc_obj_id_tail(T, [B|Ack], Len+L).
  +encode_integer_pos(0, L=[B|_Acc]) when B < 128 ->
  +    L;
  +encode_integer_pos(N, Acc) ->
  +    encode_integer_pos((N bsr 8), [N band 16#ff| Acc]).
  +
  +encode_integer_neg(-1, L=[B1|_T]) when B1 > 127 ->
  +    L;
  +encode_integer_neg(N, Acc) ->
  +    encode_integer_neg(N bsr 8, [N band 16#ff|Acc]).
   
   
   %%%%%%%%%%%
  
positive.code:     <<N:Len/unit:8,Buffer2/binary>> = <<B2,Bs/binary>>,
      Int = N - (1 bsl (8 * Len - 1)),
      {Int,Buffer2,RemovedBytes}.
  
  %%decode_integer2(Len,Buffer,Acc,RemovedBytes) when (hd(Buffer) band 16#FF) =< 16#7F ->
  %%    {decode_integer_pos(Buffer, 8 * (Len - 1)),skip(Buffer,Len),RemovedBytes};
  %%decode_integer2(Len,Buffer,Acc,RemovedBytes)  ->
  %%    {decode_integer_neg(Buffer, 8 * (Len - 1)),skip(Buffer,Len),RemovedBytes}.
  
  %%decode_integer_pos([Byte|Tail], Shift) ->
  %%    (Byte bsl Shift) bor decode_integer_pos(Tail, Shift-8);
  %%decode_integer_pos([], _) -> 0.
  
  
  %%decode_integer_neg([Byte|Tail], Shift) ->
  %%    (-128 + (Byte band 127) bsl Shift) bor decode_integer_pos(Tail, Shift-8).
  
  
  concat_bit_binaries([],Bin={_,_}) ->
      Bin;
  concat_bit_binaries({0,B1},{U2,B2}) ->
      {U2,<<B1/binary,B2/binary>>};
  concat_bit_binaries({U1,B1},{U2,B2}) ->
      S1 = (size(B1) * 8) - U1,
      S2 = (size(B2) * 8) - U2,
      PadBits = 8 - ((S1+S2) rem 8),
      {PadBits, <<B1:S1/binary-unit:1,B2:S2/binary-unit:1,0:PadBits>>};
  concat_bit_binaries(L1,L2) when is_list(L1), is_list(L2) ->
      %% this case occur when decoding with NNL
      L1 ++ L2.
  
  
  get_constraint(C,Key) ->
      case lists:keyfind(Key,1,C) of
  	false ->
  	     no;
  	{_, V} ->
  	    V
      end.
  
  %%skip(Buffer, 0) ->
  %%    Buffer;
  %%skip([H | T], Len) ->
  %%    skip(T, Len-1).
  
  new_tags([],LastTag) ->
      [LastTag];
  
negative.code: 		_ ->
  		    check_tags_i(TagRest, Buffer2, Rb + Rb1, mandatory)
  	    end
      end.
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% This function is called from generated code
  
  check_one_tag(Tag=#tag{class=ExpectedClass,number=ExpectedNumber}, Buffer, OptOrMand) ->
      case catch decode_tag(Buffer) of
  