anchor.diff:  	return str;
       }
   
  +    @JRubyMethod(name = "append_bersize_ber!")
  +    public static IRubyObject append_bersize_ber_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one)
  +    {
  +        <%- prepare_one_one.() -%>
  +	RubyString empty = RubyString.newEmptyString(context.runtime);
  +        append_ber_int(empty, argv, 0, argv.length);
  +	return append_bersize_string_bang(context, self, str, empty);
  +    }
  +
       @JRubyMethod(name = "append_bersize_ber!", rest = true)
       public static IRubyObject append_bersize_ber_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
       {
  -        AppendArgs args = checkAppendArgs(context, argv, 1);
  +	RubyString str = argv[0].isNil() ? RubyString.newEmptyString(context.runtime) : argv[0].convertToString();
   	RubyString empty = RubyString.newEmptyString(context.runtime);
  -        append_ber_int(empty, args.argv, args.begin, args.argv.length - args.begin);
  -	return append_bersize_string_bang(context, self, args.str, empty);
  -    }
  -
  -% append_intsize_ber = lambda do |bitsize, bits, dir|
  -%   bytesize = bitsize / 8
  -%   bytelist = (0...bytesize).to_a ; bytelist.reverse!  if dir == '_be'
  -    @JRubyMethod(name = "append_int<%= bitsize %>size_ber<%= dir %>!", rest = true)
  -public static IRubyObject append_int<%= bitsize %>size_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
  -    {
  -        AppendArgs args = checkAppendArgs(context, argv, 1);
  -	int size_pos = args.str.getByteList().getRealSize();
  -	byte[] nulls = { <%= ['0'] * bytesize * ", " %> };
  -	args.str.cat(nulls);
  -	append_ber_int(args.str, args.argv, args.begin, args.argv.length - args.begin);
  -	if (args.argv.length > args.begin) {
  -	    ByteList bl = args.str.getByteList();
  +        append_ber_int(empty, argv, 1, argv.length - 1);
  +	return append_bersize_string_bang(context, self, str, empty);
  +    }
  +
  +% set_intsize = lambda do |bytelist, begpos|
  +	int size_pos = str.getByteList().getRealSize();
  +	byte[] nulls = { <%= ['0'] * bytelist.size * ", " %> };
  +	str.cat(nulls);
  +	append_ber_int(str, argv, <%= begpos %>, argv.length - <%= begpos %>);
  +	if (argv.length > <%= begpos %>) {
  +	    ByteList bl = str.getByteList();
   	    byte[] bytes = bl.getUnsafeBytes();
   	    int begin = bl.begin() + size_pos;
   	    int length = bl.getRealSize() - size_pos - 4;
  
positive.code: 
  % append_bersize_int = lambda do |bits, dir|
  %   byte = bits / 8
      @JRubyMethod(name = "append_bersize_int<%= bits %><%= dir %>!", rest = true)
      public static IRubyObject append_bersize_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
      {
          AppendArgs args = checkAppendArgs(context, argv, <%= bits %>);
  	IRubyObject[] sz = { RubyFixnum.newFixnum(context.runtime, (long)(args.argv.length - args.begin) * <%= byte %>) };
          append_ber_int(args.str, sz, 0, 1);
          append_int<%= bits %><%= dir %>_int(args.str, args.argv, args.begin, args.argv.length - args.begin);
          return args.str;
      }
  % end
  
  
negative.code:     <% append_two[32, 24, '_be'] %>
  
  % append_ber_int = lambda do |bits, dir|
      @JRubyMethod(name = "append_ber_int<%= bits %><%= dir %>!")
      public static IRubyObject append_ber_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one, IRubyObject two)
      {
          <%- prepare_two_1.() -%>
          append_ber_int(str, argv, 0, 1);
          <%- prepare_two_2.() -%>
          append_int<%= bits %><%= bits == 8 ? '' : dir %>_int(str, argv, 0, argv.length);
          return str;
      }
  
      @JRubyMethod(name = "append_ber_int<%= bits %><%= dir %>!", rest = true)
      public static IRubyObject append_ber_int<%= bits %><%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
      {
  	RubyString str = argv[0].isNil() ? RubyString.newEmptyString(context.runtime) : argv[0].convertToString();
          append_ber_int(str, argv, 1, 1);
          append_int<%= bits %><%= dir %>_int(str, argv, 2, argv.length - 2);
          return str;
      }
  
      @JRubyMethod(name = "append_int<%= bits %>_ber<%= dir %>!")
      public static IRubyObject append_int<%= bits %>_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject rstr, IRubyObject one, IRubyObject two)
      {
          <%- prepare_two_1.() -%>
          append_int<%= bits %><%= bits == 8 ? '' : dir %>_int(str, argv, 0, 1);
          <%- prepare_two_2.() -%>
          append_ber_int(str, argv, 0, argv.length);
          return str;
      }
  
      @JRubyMethod(name = "append_int<%= bits %>_ber<%= dir %>!", rest = true)
      public static IRubyObject append_int<%= bits %>_ber<%= dir %>_bang(ThreadContext context, IRubyObject self, IRubyObject[] argv)
      {
  	RubyString str = argv[0].isNil() ? RubyString.newEmptyString(context.runtime) : argv[0].convertToString();
          append_int<%= bits %><%= dir %>_int(str, argv, 1, 1);
          append_ber_int(str, argv, 2, argv.length - 2);
          return str;
      }
  % end
  
  