Coverage Report

Created: 2026-11-21 09:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/s390-dis.c
Line
Count
Source
1
/* s390-dis.c -- Disassemble S390 instructions
2
   Copyright (C) 2000-2026 Free Software Foundation, Inc.
3
   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4
5
   This file is part of the GNU opcodes library.
6
7
   This library is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this file; see the file COPYING.  If not, write to the
19
   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include <stdio.h>
24
#include "ansidecl.h"
25
#include "disassemble.h"
26
#include "opintl.h"
27
#include "opcode/s390.h"
28
#include "libiberty.h"
29
#include "dis-asm.h"
30
31
static int opc_index[256];
32
static int current_arch_mask = 0;
33
static int option_use_insn_len_bits_p = 0;
34
static int option_print_insn_desc = 0;
35
36
typedef struct
37
{
38
  const char *name;
39
  const char *description;
40
} s390_options_t;
41
42
static const s390_options_t options[] =
43
{
44
  { "esa" ,       N_("Disassemble in ESA architecture mode") },
45
  /* TRANSLATORS: Please do not translate 'z/Architecture' as this is a technical name.  */
46
  { "zarch",      N_("Disassemble in z/Architecture mode") },
47
  { "insnlength", N_("Print unknown instructions according to "
48
         "length from first two bits") },
49
  { "insndesc",   N_("Print instruction description as comment") },
50
};
51
52
/* Set up index table for first opcode byte.  */
53
54
void
55
disassemble_init_s390 (struct disassemble_info *info)
56
261
{
57
261
  int i;
58
261
  const char *p;
59
60
261
  memset (opc_index, 0, sizeof (opc_index));
61
62
  /* Reverse order, such that each opc_index ends up pointing to the
63
     first matching entry instead of the last.  */
64
718k
  for (i = s390_num_opcodes; i--; )
65
717k
    opc_index[s390_opcodes[i].opcode[0]] = i;
66
67
261
  current_arch_mask = 1 << S390_OPCODE_ZARCH;
68
261
  option_use_insn_len_bits_p = 0;
69
261
  option_print_insn_desc = 0;
70
71
261
  for (p = info->disassembler_options; p != NULL; )
72
0
    {
73
0
      if (startswith (p, "esa"))
74
0
  current_arch_mask = 1 << S390_OPCODE_ESA;
75
0
      else if (startswith (p, "zarch"))
76
0
  current_arch_mask = 1 << S390_OPCODE_ZARCH;
77
0
      else if (startswith (p, "insnlength"))
78
0
  option_use_insn_len_bits_p = 1;
79
0
      else if (startswith (p, "insndesc"))
80
0
  option_print_insn_desc = 1;
81
0
      else
82
  /* xgettext:c-format */
83
0
  opcodes_error_handler (_("unknown S/390 disassembler option: %s"), p);
84
85
0
      p = strchr (p, ',');
86
0
      if (p != NULL)
87
0
  p++;
88
0
    }
89
261
}
90
91
/* Derive the length of an instruction from its first byte.  */
92
93
static inline int
94
s390_insn_length (const bfd_byte *buffer)
95
180k
{
96
  /* 00xxxxxx -> 2, 01xxxxxx/10xxxxxx -> 4, 11xxxxxx -> 6.  */
97
180k
  return ((buffer[0] >> 6) + 3) & ~1U;
98
180k
}
99
100
/* Match the instruction in BUFFER against the given OPCODE, excluding
101
   the first byte.  */
102
103
static inline int
104
s390_insn_matches_opcode (const bfd_byte *buffer,
105
        const struct s390_opcode *opcode)
106
1.49M
{
107
1.49M
  return (buffer[1] & opcode->mask[1]) == opcode->opcode[1]
108
1.00M
    && (buffer[2] & opcode->mask[2]) == opcode->opcode[2]
109
489k
    && (buffer[3] & opcode->mask[3]) == opcode->opcode[3]
110
413k
    && (buffer[4] & opcode->mask[4]) == opcode->opcode[4]
111
273k
    && (buffer[5] & opcode->mask[5]) == opcode->opcode[5];
112
1.49M
}
113
114
union operand_value
115
{
116
  int i;
117
  unsigned int u;
118
};
119
120
/* Extracts an operand value from an instruction.  */
121
/* We do not perform the shift operation for larl-type address
122
   operands here since that would lead to an overflow of the 32 bit
123
   integer value.  Instead the shift operation is done when printing
124
   the operand.  */
125
126
static inline union operand_value
127
s390_extract_operand (const bfd_byte *insn,
128
          const struct s390_operand *operand)
129
282k
{
130
282k
  union operand_value ret;
131
282k
  unsigned int val;
132
282k
  int bits;
133
282k
  const bfd_byte *orig_insn = insn;
134
135
  /* Extract fragments of the operand byte for byte.  */
136
282k
  insn += operand->shift / 8;
137
282k
  bits = (operand->shift & 7) + operand->bits;
138
282k
  val = 0;
139
282k
  do
140
352k
    {
141
352k
      val <<= 8;
142
352k
      val |= (unsigned int) *insn++;
143
352k
      bits -= 8;
144
352k
    }
145
352k
  while (bits > 0);
146
282k
  val >>= -bits;
147
282k
  val &= ((1U << (operand->bits - 1)) << 1) - 1;
148
149
  /* Check for special long displacement case.  */
150
282k
  if (operand->bits == 20 && operand->shift == 20)
151
371
    val = (val & 0xff) << 12 | (val & 0xfff00) >> 8;
152
153
  /* Sign extend value if the operand is signed or pc relative.  Avoid
154
     integer overflows.  */
155
282k
  if (operand->flags & (S390_OPERAND_SIGNED | S390_OPERAND_PCREL))
156
5.85k
    {
157
5.85k
      unsigned int m = 1U << (operand->bits - 1);
158
159
5.85k
      if (val >= m)
160
2.59k
  ret.i = (int) (val - m) - 1 - (int) (m - 1U);
161
3.25k
      else
162
3.25k
  ret.i = (int) val;
163
5.85k
    }
164
277k
  else if (operand->flags & S390_OPERAND_LENGTH)
165
    /* Length x in an instruction has real length x + 1.  */
166
13.3k
    ret.u = val + 1;
167
168
263k
  else if (operand->flags & S390_OPERAND_VR)
169
800
    {
170
      /* Extract the extra bits for a vector register operand stored
171
   in the RXB field.  */
172
800
      unsigned vr = operand->shift == 32 ? 3
173
800
  : (unsigned) operand->shift / 4 - 2;
174
175
800
      ret.u = val | ((orig_insn[4] & (1 << (3 - vr))) << (vr + 1));
176
800
    }
177
262k
  else
178
262k
    ret.u = val;
179
180
282k
  return ret;
181
282k
}
182
183
/* Extract an operand value from an instruction.  Additionally mask any
184
   constant operand bits set in the instruction template of unsigned
185
   integer operands.  Constant operand bits do not make sense for registers,
186
   displacements, PC-relative offsets, lengths, and signed values.  */
187
188
static inline union operand_value
189
s390_extract_operand_masked (const bfd_byte *insn,
190
           const struct s390_opcode *opcode,
191
           const struct s390_operand *operand)
192
275k
{
193
275k
  union operand_value val = s390_extract_operand (insn, operand);
194
195
275k
  if (!(operand->flags & (S390_OPERAND_GPR
196
275k
        | S390_OPERAND_FPR
197
275k
        | S390_OPERAND_VR
198
275k
        | S390_OPERAND_AR
199
275k
        | S390_OPERAND_CR
200
275k
        | S390_OPERAND_DISP
201
275k
        | S390_OPERAND_PCREL
202
275k
        | S390_OPERAND_LENGTH
203
275k
        | S390_OPERAND_SIGNED)))
204
7.38k
    {
205
7.38k
      union operand_value insn_opval
206
7.38k
  = s390_extract_operand (opcode->opcode, operand);
207
208
7.38k
      val.u &= ~insn_opval.u;
209
7.38k
    }
210
211
275k
  return val;
212
275k
}
213
214
/* Return remaining operand count.  */
215
216
static unsigned int
217
operand_count (const unsigned char *opindex_ptr)
218
2.44k
{
219
2.44k
  unsigned int count = 0;
220
221
8.10k
  for (; *opindex_ptr != 0; opindex_ptr++)
222
5.66k
    {
223
      /* Count D(X,B), D(B), and D(L,B) as one operand.  Assuming correct
224
   instruction operand definitions simply do not count D, X, and L.  */
225
5.66k
      if (!(s390_operands[*opindex_ptr].flags & (S390_OPERAND_DISP
226
5.66k
            | S390_OPERAND_INDEX
227
5.66k
            | S390_OPERAND_LENGTH)))
228
4.35k
  count++;
229
5.66k
    }
230
231
2.44k
  return count;
232
2.44k
}
233
234
/* Return true if all remaining instruction operands are optional.  */
235
236
static bool
237
skip_optargs_p (unsigned int opcode_flags, const unsigned char *opindex_ptr)
238
179k
{
239
179k
  unsigned int optparm = opcode_flags & S390_INSTR_FLAG_OPTPARM_MASK;
240
179k
  unsigned int opcount;
241
242
179k
  return (optparm > 0
243
2.44k
    && (opcount = operand_count (opindex_ptr)) > 0
244
2.44k
    && opcount <= optparm);
245
179k
}
246
247
/* Return true if all remaining instruction operands are optional
248
   and their values are zero.  */
249
250
static bool
251
skip_optargs_zero_p (const bfd_byte *buffer, const struct s390_opcode *opcode,
252
         const unsigned char *opindex_ptr)
253
179k
{
254
  /* Test if remaining operands are optional.  */
255
179k
  if (!skip_optargs_p (opcode->flags, opindex_ptr))
256
177k
    return false;
257
258
  /* Test if remaining operand values are zero, ignoring any constant
259
     operand bits set in the insn template.  */
260
3.21k
  for (; *opindex_ptr != 0; opindex_ptr++)
261
2.47k
    {
262
2.47k
      const struct s390_operand *operand = &s390_operands[*opindex_ptr];
263
2.47k
      union operand_value value
264
2.47k
  = s390_extract_operand_masked (buffer, opcode, operand);
265
266
2.47k
      if (value.u != 0)
267
985
  return false;
268
2.47k
    }
269
270
736
  return true;
271
1.72k
}
272
273
/* Print the S390 instruction in BUFFER, assuming that it matches the
274
   given OPCODE.  */
275
276
static void
277
s390_print_insn_with_opcode (bfd_vma memaddr,
278
           struct disassemble_info *info,
279
           const bfd_byte *buffer,
280
           const struct s390_opcode *opcode)
281
87.3k
{
282
87.3k
  const unsigned char *opindex;
283
87.3k
  char separator;
284
285
  /* Mnemonic.  */
286
87.3k
  info->fprintf_styled_func (info->stream, dis_style_mnemonic,
287
87.3k
           "%s", opcode->name);
288
289
  /* Operands.  */
290
87.3k
  separator = '\t';
291
359k
  for (opindex = opcode->operands; *opindex != 0; opindex++)
292
273k
    {
293
273k
      const struct s390_operand *operand = s390_operands + *opindex;
294
273k
      union operand_value val
295
273k
  = s390_extract_operand_masked (buffer, opcode, operand);
296
273k
      unsigned long flags = operand->flags;
297
298
      /* Omit index register 0, except for vector index register 0.  */
299
273k
      if ((flags & S390_OPERAND_INDEX) && !(flags & S390_OPERAND_VR)
300
23.8k
    && val.u == 0)
301
3.57k
  continue;
302
      /* Omit base register 0, if no or omitted index register 0.  */
303
269k
      if ((flags & S390_OPERAND_BASE) && val.u == 0 && separator == '(')
304
5.08k
  {
305
5.08k
    separator = ',';
306
5.08k
    continue;
307
5.08k
  }
308
309
      /* Omit optional last operands with a value of zero, except if
310
   within an addressing operand sequence D(X,B), D(B), and D(L,B).
311
   Index and base register operands with a value of zero are
312
   handled separately, as they may not be omitted unconditionally.  */
313
264k
      if (!(operand->flags & (S390_OPERAND_BASE
314
264k
            | S390_OPERAND_INDEX
315
264k
            | S390_OPERAND_LENGTH))
316
179k
    && skip_optargs_zero_p (buffer, opcode, opindex))
317
736
  break;
318
319
263k
      if (flags & S390_OPERAND_GPR)
320
126k
  {
321
126k
    info->fprintf_styled_func (info->stream, dis_style_text,
322
126k
             "%c", separator);
323
126k
    if ((flags & (S390_OPERAND_BASE | S390_OPERAND_INDEX))
324
71.4k
        && val.u == 0)
325
6.03k
      info->fprintf_styled_func (info->stream, dis_style_register,
326
6.03k
               "%u", val.u);
327
120k
    else
328
120k
      info->fprintf_styled_func (info->stream, dis_style_register,
329
120k
               "%%r%u", val.u);
330
126k
  }
331
136k
      else if (flags & S390_OPERAND_FPR)
332
51.5k
  {
333
51.5k
    info->fprintf_styled_func (info->stream, dis_style_text,
334
51.5k
             "%c", separator);
335
51.5k
    info->fprintf_styled_func (info->stream, dis_style_register,
336
51.5k
             "%%f%u", val.u);
337
51.5k
  }
338
85.2k
      else if (flags & S390_OPERAND_VR)
339
800
  {
340
800
    info->fprintf_styled_func (info->stream, dis_style_text,
341
800
             "%c", separator);
342
800
    info->fprintf_styled_func (info->stream, dis_style_register,
343
800
             "%%v%u", val.u);
344
800
  }
345
84.4k
      else if (flags & S390_OPERAND_AR)
346
1.20k
  {
347
1.20k
    info->fprintf_styled_func (info->stream, dis_style_text,
348
1.20k
             "%c", separator);
349
1.20k
    info->fprintf_styled_func (info->stream, dis_style_register,
350
1.20k
             "%%a%u", val.u);
351
1.20k
  }
352
83.2k
      else if (flags & S390_OPERAND_CR)
353
1.50k
  {
354
1.50k
    info->fprintf_styled_func (info->stream, dis_style_text,
355
1.50k
             "%c", separator);
356
1.50k
    info->fprintf_styled_func (info->stream, dis_style_register,
357
1.50k
             "%%c%u", val.u);
358
1.50k
  }
359
81.7k
      else if (flags & S390_OPERAND_PCREL)
360
5.20k
  {
361
5.20k
    bfd_vma target = memaddr + val.i + val.i;
362
363
    /* Provide info for jump visualization.  May be evaluated by p_a_f().  */
364
5.20k
    info->target = target;
365
366
5.20k
    info->fprintf_styled_func (info->stream, dis_style_text,
367
5.20k
             "%c", separator);
368
5.20k
    info->print_address_func (target, info);
369
5.20k
  }
370
76.5k
      else if (flags & S390_OPERAND_SIGNED)
371
651
  {
372
651
    enum disassembler_style style;
373
374
651
    info->fprintf_styled_func (info->stream, dis_style_text,
375
651
             "%c", separator);
376
651
    style = ((flags & S390_OPERAND_DISP)
377
651
       ? dis_style_address_offset : dis_style_immediate);
378
651
    info->fprintf_styled_func (info->stream, style, "%i", val.i);
379
651
  }
380
75.9k
      else
381
75.9k
  {
382
75.9k
    enum disassembler_style style;
383
384
75.9k
    info->fprintf_styled_func (info->stream, dis_style_text,
385
75.9k
             "%c", separator);
386
75.9k
    style = ((flags & S390_OPERAND_DISP)
387
75.9k
       ? dis_style_address_offset : dis_style_immediate);
388
75.9k
    info->fprintf_styled_func (info->stream, style, "%u", val.u);
389
75.9k
  }
390
391
263k
      if (flags & S390_OPERAND_DISP)
392
56.2k
  separator = '(';
393
207k
      else if (flags & S390_OPERAND_BASE)
394
51.1k
  {
395
51.1k
    info->fprintf_styled_func (info->stream, dis_style_text, ")");
396
51.1k
    separator = ',';
397
51.1k
  }
398
156k
      else
399
156k
  separator = ',';
400
263k
    }
401
402
  /* Optional: instruction name.  */
403
87.3k
  if (option_print_insn_desc && opcode->description
404
0
      && opcode->description[0] != '\0')
405
0
    info->fprintf_styled_func (info->stream, dis_style_comment_start, "\t# %s",
406
0
             opcode->description);
407
87.3k
}
408
409
/* Check whether opcode A's mask is more specific than that of B.  */
410
411
static int
412
opcode_mask_more_specific (const struct s390_opcode *a,
413
         const struct s390_opcode *b)
414
7.59k
{
415
7.59k
  return (((int) a->mask[0] + a->mask[1] + a->mask[2]
416
7.59k
     + a->mask[3] + a->mask[4] + a->mask[5])
417
7.59k
    > ((int) b->mask[0] + b->mask[1] + b->mask[2]
418
7.59k
       + b->mask[3] + b->mask[4] + b->mask[5]));
419
7.59k
}
420
421
/* Print a S390 instruction.  */
422
423
int
424
print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info)
425
180k
{
426
180k
  bfd_byte buffer[6];
427
180k
  const struct s390_opcode *opcode = NULL;
428
180k
  unsigned int value;
429
180k
  int status, opsize, bufsize, bytes_to_dump, i;
430
431
  /* The output looks better if we put 6 bytes on a line.  */
432
180k
  info->bytes_per_line = 6;
433
434
  /* Set some defaults for the insn info.  */
435
180k
  info->insn_info_valid    = 0;
436
180k
  info->branch_delay_insns = 0;
437
180k
  info->data_size          = 0;
438
180k
  info->insn_type          = dis_nonbranch;
439
180k
  info->target             = 0;
440
180k
  info->target2            = 0;
441
442
  /* Every S390 instruction is max 6 bytes long.  */
443
180k
  memset (buffer, 0, 6);
444
180k
  status = info->read_memory_func (memaddr, buffer, 6, info);
445
180k
  if (status != 0)
446
501
    {
447
1.95k
      for (bufsize = 0; bufsize < 6; bufsize++)
448
1.95k
  if (info->read_memory_func (memaddr, buffer, bufsize + 1, info) != 0)
449
501
    break;
450
501
      if (bufsize <= 0)
451
1
  {
452
1
    info->memory_error_func (status, memaddr, info);
453
1
    return -1;
454
1
  }
455
500
      opsize = s390_insn_length (buffer);
456
500
      status = opsize > bufsize;
457
500
    }
458
180k
  else
459
180k
    {
460
180k
      bufsize = 6;
461
180k
      opsize = s390_insn_length (buffer);
462
180k
    }
463
464
180k
  if (status == 0)
465
180k
    {
466
180k
      const struct s390_opcode *op;
467
468
      /* Find the "best match" in the opcode table.  */
469
180k
      for (op = s390_opcodes + opc_index[buffer[0]];
470
1.67M
     op != s390_opcodes + s390_num_opcodes
471
1.67M
       && op->opcode[0] == buffer[0];
472
1.49M
     op++)
473
1.49M
  {
474
1.49M
    if ((op->modes & current_arch_mask)
475
1.49M
        && s390_insn_matches_opcode (buffer, op)
476
94.9k
        && (opcode == NULL
477
7.59k
      || opcode_mask_more_specific (op, opcode)))
478
88.6k
      opcode = op;
479
1.49M
  }
480
481
180k
      if (opcode != NULL)
482
87.3k
  {
483
    /* Provide info for jump visualization.  Must be done before print.  */
484
87.3k
    switch (opcode->flags & S390_INSTR_FLAG_CLASS_MASK)
485
87.3k
      {
486
163
      case S390_INSTR_FLAGS_CLASS_JUMP:
487
163
        info->insn_type = dis_branch;
488
163
        break;
489
2.00k
      case S390_INSTR_FLAGS_CLASS_CONDJUMP:
490
2.00k
        info->insn_type = dis_condbranch;
491
2.00k
        break;
492
421
      case S390_INSTR_FLAGS_CLASS_JUMPSR:
493
421
        info->insn_type = dis_jsr;
494
421
        break;
495
84.8k
      default:
496
84.8k
        info->insn_type = dis_nonbranch;
497
87.3k
      }
498
87.3k
    info->insn_info_valid = 1;
499
500
    /* The instruction is valid.  Print it and return its size.  */
501
87.3k
    s390_print_insn_with_opcode (memaddr, info, buffer, opcode);
502
87.3k
    return opsize;
503
87.3k
  }
504
180k
    }
505
506
  /* For code sections it makes sense to skip unknown instructions
507
     according to their length bits.  */
508
93.5k
  if (status == 0
509
93.3k
      && option_use_insn_len_bits_p
510
0
      && info->section != NULL
511
0
      && (info->section->flags & SEC_CODE))
512
0
    bytes_to_dump = opsize;
513
93.5k
  else
514
    /* By default unknown instructions are printed as .long's/.short'
515
       depending on how many bytes are available.  */
516
93.5k
    bytes_to_dump = bufsize >= 4 ? 4 : bufsize;
517
518
93.5k
  if (bytes_to_dump == 0)
519
0
    return 0;
520
521
93.5k
  info->insn_type = dis_noninsn;
522
93.5k
  info->insn_info_valid = 1;
523
524
  /* Fall back to hex print.  */
525
93.5k
  switch (bytes_to_dump)
526
93.5k
    {
527
93.3k
    case 4:
528
93.3k
      value = (unsigned int) buffer[0];
529
93.3k
      value = (value << 8) + (unsigned int) buffer[1];
530
93.3k
      value = (value << 8) + (unsigned int) buffer[2];
531
93.3k
      value = (value << 8) + (unsigned int) buffer[3];
532
93.3k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
533
93.3k
         ".long");
534
93.3k
      info->fprintf_styled_func (info->stream, dis_style_text,
535
93.3k
         "\t");
536
93.3k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
537
93.3k
         "0x%08x", value);
538
93.3k
      return 4;
539
152
    case 2:
540
152
      value = (unsigned int) buffer[0];
541
152
      value = (value << 8) + (unsigned int) buffer[1];
542
152
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
543
152
         ".short");
544
152
      info->fprintf_styled_func (info->stream, dis_style_text,
545
152
         "\t");
546
152
      info->fprintf_styled_func (info->stream, dis_style_immediate,
547
152
         "0x%04x", value);
548
152
      return 2;
549
123
    default:
550
123
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
551
123
         ".byte");
552
123
      info->fprintf_styled_func (info->stream, dis_style_text,
553
123
         "\t");
554
123
      info->fprintf_styled_func (info->stream, dis_style_immediate,
555
123
         "0x%02x", (unsigned int) buffer[0]);
556
231
      for (i = 1; i < bytes_to_dump; i++)
557
108
  info->fprintf_styled_func (info->stream, dis_style_immediate,
558
108
           "0x%02x", (unsigned int) buffer[i]);
559
123
      return bytes_to_dump;
560
93.5k
    }
561
0
  return 0;
562
93.5k
}
563
564
const disasm_options_and_args_t *
565
disassembler_options_s390 (void)
566
0
{
567
0
  static disasm_options_and_args_t *opts_and_args;
568
569
0
  if (opts_and_args == NULL)
570
0
    {
571
0
      size_t i, num_options = ARRAY_SIZE (options);
572
0
      disasm_options_t *opts;
573
574
0
      opts_and_args = XNEW (disasm_options_and_args_t);
575
0
      opts_and_args->args = NULL;
576
577
0
      opts = &opts_and_args->options;
578
0
      opts->name = XNEWVEC (const char *, num_options + 1);
579
0
      opts->description = XNEWVEC (const char *, num_options + 1);
580
0
      opts->arg = NULL;
581
0
      for (i = 0; i < num_options; i++)
582
0
  {
583
0
    opts->name[i] = options[i].name;
584
0
    opts->description[i] = _(options[i].description);
585
0
  }
586
      /* The array we return must be NULL terminated.  */
587
0
      opts->name[i] = NULL;
588
0
      opts->description[i] = NULL;
589
0
    }
590
591
0
  return opts_and_args;
592
0
}
593
594
void
595
print_s390_disassembler_options (FILE *stream)
596
0
{
597
0
  unsigned int i, max_len = 0;
598
0
  fprintf (stream, _("\n\
599
0
The following S/390 specific disassembler options are supported for use\n\
600
0
with the -M switch (multiple options should be separated by commas):\n"));
601
602
0
  for (i = 0; i < ARRAY_SIZE (options); i++)
603
0
    {
604
0
      unsigned int len = strlen (options[i].name);
605
0
      if (max_len < len)
606
0
  max_len = len;
607
0
    }
608
609
0
  for (i = 0, max_len++; i < ARRAY_SIZE (options); i++)
610
0
    fprintf (stream, "  %s%*c %s\n",
611
0
       options[i].name,
612
0
       (int)(max_len - strlen (options[i].name)), ' ',
613
       _(options[i].description));
614
0
}