02881c3c8bebe1a8f5fe26716298d49bb0ff2a39
[binutils-gdb.git] / gas / doc / c-s390.texi
1 @c Copyright (C) 2009-2021 Free Software Foundation, Inc.
2 @c This is part of the GAS manual.
3 @c For copying conditions, see the file as.texinfo.
4 @ifset GENERIC
5 @page
6 @node S/390-Dependent
7 @chapter IBM S/390 Dependent Features
8 @end ifset
9 @ifclear GENERIC
10 @node Machine Dependencies
11 @chapter IBM S/390 Dependent Features
12 @end ifclear
13
14 @cindex s390 support
15
16 The s390 version of @code{@value{AS}} supports two architectures modes
17 and eleven chip levels. The architecture modes are the Enterprise System
18 Architecture (ESA) and the newer z/Architecture mode. The chip levels
19 are g5 (or arch3), g6, z900 (or arch5), z990 (or arch6), z9-109, z9-ec
20 (or arch7), z10 (or arch8), z196 (or arch9), zEC12 (or arch10), z13
21 (or arch11), z14 (or arch12), and z15 (or arch13).
22
23 @menu
24 * s390 Options:: Command-line Options.
25 * s390 Characters:: Special Characters.
26 * s390 Syntax:: Assembler Instruction syntax.
27 * s390 Directives:: Assembler Directives.
28 * s390 Floating Point:: Floating Point.
29 @end menu
30
31 @node s390 Options
32 @section Options
33 @cindex options for s390
34 @cindex s390 options
35
36 The following table lists all available s390 specific options:
37
38 @table @code
39 @cindex @samp{-m31} option, s390
40 @cindex @samp{-m64} option, s390
41 @item -m31 | -m64
42 Select 31- or 64-bit ABI implying a word size of 32- or 64-bit.
43
44 These options are only available with the ELF object file format, and
45 require that the necessary BFD support has been included (on a 31-bit
46 platform you must add --enable-64-bit-bfd on the call to the configure
47 script to enable 64-bit usage and use s390x as target platform).
48
49 @cindex @samp{-mesa} option, s390
50 @cindex @samp{-mzarch} option, s390
51 @item -mesa | -mzarch
52 Select the architecture mode, either the Enterprise System Architecture
53 (esa) mode or the z/Architecture mode (zarch).
54
55 The 64-bit instructions are only available with the z/Architecture mode.
56 The combination of @samp{-m64} and @samp{-mesa} results in a warning
57 message.
58
59 @cindex @samp{-march=} option, s390
60 @item -march=@var{CPU}
61 This option specifies the target processor. The following processor names
62 are recognized:
63 @code{g5} (or @code{arch3}),
64 @code{g6},
65 @code{z900} (or @code{arch5}),
66 @code{z990} (or @code{arch6}),
67 @code{z9-109},
68 @code{z9-ec} (or @code{arch7}),
69 @code{z10} (or @code{arch8}),
70 @code{z196} (or @code{arch9}),
71 @code{zEC12} (or @code{arch10}),
72 @code{z13} (or @code{arch11}),
73 @code{z14} (or @code{arch12}), and
74 @code{z15} (or @code{arch13}).
75
76 Assembling an instruction that is not supported on the target
77 processor results in an error message.
78
79 The processor names starting with @code{arch} refer to the edition
80 number in the Principle of Operations manual. They can be used as
81 alternate processor names and have been added for compatibility with
82 the IBM XL compiler.
83
84 @code{arch3}, @code{g5} and @code{g6} cannot be used with the
85 @samp{-mzarch} option since the z/Architecture mode is not supported
86 on these processor levels.
87
88 There is no @code{arch4} option supported. @code{arch4} matches
89 @code{-march=arch5 -mesa}.
90
91 @cindex @samp{-mregnames} option, s390
92 @item -mregnames
93 Allow symbolic names for registers.
94
95 @cindex @samp{-mno-regnames} option, s390
96 @item -mno-regnames
97 Do not allow symbolic names for registers.
98
99 @cindex @samp{-mwarn-areg-zero} option, s390
100 @item -mwarn-areg-zero
101 Warn whenever the operand for a base or index register has been specified
102 but evaluates to zero. This can indicate the misuse of general purpose
103 register 0 as an address register.
104
105 @end table
106
107 @node s390 Characters
108 @section Special Characters
109 @cindex line comment character, s390
110 @cindex s390 line comment character
111
112 @samp{#} is the line comment character.
113
114 If a @samp{#} appears as the first character of a line then the whole
115 line is treated as a comment, but in this case the line could also be
116 a logical line number directive (@pxref{Comments}) or a preprocessor
117 control command (@pxref{Preprocessing}).
118
119 @cindex line separator, s390
120 @cindex statement separator, s390
121 @cindex s390 line separator
122 The @samp{;} character can be used instead of a newline to separate
123 statements.
124
125 @node s390 Syntax
126 @section Instruction syntax
127 @cindex instruction syntax, s390
128 @cindex s390 instruction syntax
129
130 The assembler syntax closely follows the syntax outlined in
131 Enterprise Systems Architecture/390 Principles of Operation (SA22-7201)
132 and the z/Architecture Principles of Operation (SA22-7832).
133
134 Each instruction has two major parts, the instruction mnemonic
135 and the instruction operands. The instruction format varies.
136
137 @menu
138 * s390 Register:: Register Naming
139 * s390 Mnemonics:: Instruction Mnemonics
140 * s390 Operands:: Instruction Operands
141 * s390 Formats:: Instruction Formats
142 * s390 Aliases:: Instruction Aliases
143 * s390 Operand Modifier:: Instruction Operand Modifier
144 * s390 Instruction Marker:: Instruction Marker
145 * s390 Literal Pool Entries:: Literal Pool Entries
146 @end menu
147
148 @node s390 Register
149 @subsection Register naming
150 @cindex register naming, s390
151 @cindex s390 register naming
152
153 The @code{@value{AS}} recognizes a number of predefined symbols for the
154 various processor registers. A register specification in one of the
155 instruction formats is an unsigned integer between 0 and 15. The specific
156 instruction and the position of the register in the instruction format
157 denotes the type of the register. The register symbols are prefixed with
158 @samp{%}:
159
160 @display
161 @multitable {%rN} {the 16 general purpose registers, 0 <= N <= 15}
162 @item %rN @tab the 16 general purpose registers, 0 <= N <= 15
163 @item %fN @tab the 16 floating point registers, 0 <= N <= 15
164 @item %aN @tab the 16 access registers, 0 <= N <= 15
165 @item %cN @tab the 16 control registers, 0 <= N <= 15
166 @item %lit @tab an alias for the general purpose register %r13
167 @item %sp @tab an alias for the general purpose register %r15
168 @end multitable
169 @end display
170
171 @node s390 Mnemonics
172 @subsection Instruction Mnemonics
173 @cindex instruction mnemonics, s390
174 @cindex s390 instruction mnemonics
175
176 All instructions documented in the Principles of Operation are supported
177 with the mnemonic and order of operands as described.
178 The instruction mnemonic identifies the instruction format
179 (@ref{s390 Formats}) and the specific operation code for the instruction.
180 For example, the @samp{lr} mnemonic denotes the instruction format @samp{RR}
181 with the operation code @samp{0x18}.
182
183 The definition of the various mnemonics follows a scheme, where the first
184 character usually hint at the type of the instruction:
185
186 @display
187 @multitable {sla, sll} {if r is the last character the instruction operates on registers}
188 @item a @tab add instruction, for example @samp{al} for add logical 32-bit
189 @item b @tab branch instruction, for example @samp{bc} for branch on condition
190 @item c @tab compare or convert instruction, for example @samp{cr} for compare
191 register 32-bit
192 @item d @tab divide instruction, for example @samp{dlr} devide logical register
193 64-bit to 32-bit
194 @item i @tab insert instruction, for example @samp{ic} insert character
195 @item l @tab load instruction, for example @samp{ltr} load and test register
196 @item mv @tab move instruction, for example @samp{mvc} move character
197 @item m @tab multiply instruction, for example @samp{mh} multiply halfword
198 @item n @tab and instruction, for example @samp{ni} and immediate
199 @item o @tab or instruction, for example @samp{oc} or character
200 @item sla, sll @tab shift left single instruction
201 @item sra, srl @tab shift right single instruction
202 @item st @tab store instruction, for example @samp{stm} store multiple
203 @item s @tab subtract instruction, for example @samp{slr} subtract
204 logical 32-bit
205 @item t @tab test or translate instruction, of example @samp{tm} test under mask
206 @item x @tab exclusive or instruction, for example @samp{xc} exclusive or
207 character
208 @end multitable
209 @end display
210
211 Certain characters at the end of the mnemonic may describe a property
212 of the instruction:
213
214 @display
215 @multitable {c} {if r is the last character the instruction operates on registers}
216 @item c @tab the instruction uses a 8-bit character operand
217 @item f @tab the instruction extends a 32-bit operand to 64 bit
218 @item g @tab the operands are treated as 64-bit values
219 @item h @tab the operand uses a 16-bit halfword operand
220 @item i @tab the instruction uses an immediate operand
221 @item l @tab the instruction uses unsigned, logical operands
222 @item m @tab the instruction uses a mask or operates on multiple values
223 @item r @tab if r is the last character, the instruction operates on registers
224 @item y @tab the instruction uses 20-bit displacements
225 @end multitable
226 @end display
227
228 There are many exceptions to the scheme outlined in the above lists, in
229 particular for the privileged instructions. For non-privileged
230 instruction it works quite well, for example the instruction @samp{clgfr}
231 c: compare instruction, l: unsigned operands, g: 64-bit operands,
232 f: 32- to 64-bit extension, r: register operands. The instruction compares
233 an 64-bit value in a register with the zero extended 32-bit value from
234 a second register.
235 For a complete list of all mnemonics see appendix B in the Principles
236 of Operation.
237
238 @node s390 Operands
239 @subsection Instruction Operands
240 @cindex instruction operands, s390
241 @cindex s390 instruction operands
242
243 Instruction operands can be grouped into three classes, operands located
244 in registers, immediate operands, and operands in storage.
245
246 A register operand can be located in general, floating-point, access,
247 or control register. The register is identified by a four-bit field.
248 The field containing the register operand is called the R field.
249
250 Immediate operands are contained within the instruction and can have
251 8, 16 or 32 bits. The field containing the immediate operand is called
252 the I field. Dependent on the instruction the I field is either signed
253 or unsigned.
254
255 A storage operand consists of an address and a length. The address of a
256 storage operands can be specified in any of these ways:
257
258 @itemize
259 @item The content of a single general R
260 @item The sum of the content of a general register called the base
261 register B plus the content of a displacement field D
262 @item The sum of the contents of two general registers called the
263 index register X and the base register B plus the content of a
264 displacement field
265 @item The sum of the current instruction address and a 32-bit signed
266 immediate field multiplied by two.
267 @end itemize
268
269 The length of a storage operand can be:
270
271 @itemize
272 @item Implied by the instruction
273 @item Specified by a bitmask
274 @item Specified by a four-bit or eight-bit length field L
275 @item Specified by the content of a general register
276 @end itemize
277
278 The notation for storage operand addresses formed from multiple fields is
279 as follows:
280
281 @table @code
282 @item Dn(Bn)
283 the address for operand number n is formed from the content of general
284 register Bn called the base register and the displacement field Dn.
285 @item Dn(Xn,Bn)
286 the address for operand number n is formed from the content of general
287 register Xn called the index register, general register Bn called the
288 base register and the displacement field Dn.
289 @item Dn(Ln,Bn)
290 the address for operand number n is formed from the content of general
291 register Bn called the base register and the displacement field Dn.
292 The length of the operand n is specified by the field Ln.
293 @end table
294
295 The base registers Bn and the index registers Xn of a storage operand can
296 be skipped. If Bn and Xn are skipped, a zero will be stored to the operand
297 field. The notation changes as follows:
298
299 @display
300 @multitable @columnfractions 0.30 0.30
301 @headitem full notation @tab short notation
302 @item Dn(0,Bn) @tab Dn(Bn)
303 @item Dn(0,0) @tab Dn
304 @item Dn(0) @tab Dn
305 @item Dn(Ln,0) @tab Dn(Ln)
306 @end multitable
307 @end display
308
309
310 @node s390 Formats
311 @subsection Instruction Formats
312 @cindex instruction formats, s390
313 @cindex s390 instruction formats
314
315 The Principles of Operation manuals lists 35 instruction formats where
316 some of the formats have multiple variants. For the @samp{.insn}
317 pseudo directive the assembler recognizes some of the formats.
318 Typically, the most general variant of the instruction format is used
319 by the @samp{.insn} directive.
320
321 The following table lists the abbreviations used in the table of
322 instruction formats:
323
324 @display
325 @multitable {OpCode / OpCd} {Displacement lower 12 bits for operand x.}
326 @item OpCode / OpCd @tab Part of the op code.
327 @item Bx @tab Base register number for operand x.
328 @item Dx @tab Displacement for operand x.
329 @item DLx @tab Displacement lower 12 bits for operand x.
330 @item DHx @tab Displacement higher 8-bits for operand x.
331 @item Rx @tab Register number for operand x.
332 @item Xx @tab Index register number for operand x.
333 @item Ix @tab Signed immediate for operand x.
334 @item Ux @tab Unsigned immediate for operand x.
335 @end multitable
336 @end display
337
338 An instruction is two, four, or six bytes in length and must be aligned
339 on a 2 byte boundary. The first two bits of the instruction specify the
340 length of the instruction, 00 indicates a two byte instruction, 01 and 10
341 indicates a four byte instruction, and 11 indicates a six byte instruction.
342
343 The following table lists the s390 instruction formats that are available
344 with the @samp{.insn} pseudo directive:
345
346 @table @code
347 @item E format
348 @verbatim
349 +-------------+
350 | OpCode |
351 +-------------+
352 0 15
353 @end verbatim
354
355 @item RI format: <insn> R1,I2
356 @verbatim
357 +--------+----+----+------------------+
358 | OpCode | R1 |OpCd| I2 |
359 +--------+----+----+------------------+
360 0 8 12 16 31
361 @end verbatim
362
363 @item RIE format: <insn> R1,R3,I2
364 @verbatim
365 +--------+----+----+------------------+--------+--------+
366 | OpCode | R1 | R3 | I2 |////////| OpCode |
367 +--------+----+----+------------------+--------+--------+
368 0 8 12 16 32 40 47
369 @end verbatim
370
371 @item RIL format: <insn> R1,I2
372 @verbatim
373 +--------+----+----+------------------------------------+
374 | OpCode | R1 |OpCd| I2 |
375 +--------+----+----+------------------------------------+
376 0 8 12 16 47
377 @end verbatim
378
379 @item RILU format: <insn> R1,U2
380 @verbatim
381 +--------+----+----+------------------------------------+
382 | OpCode | R1 |OpCd| U2 |
383 +--------+----+----+------------------------------------+
384 0 8 12 16 47
385 @end verbatim
386
387 @item RIS format: <insn> R1,I2,M3,D4(B4)
388 @verbatim
389 +--------+----+----+----+-------------+--------+--------+
390 | OpCode | R1 | M3 | B4 | D4 | I2 | Opcode |
391 +--------+----+----+----+-------------+--------+--------+
392 0 8 12 16 20 32 36 47
393 @end verbatim
394
395 @item RR format: <insn> R1,R2
396 @verbatim
397 +--------+----+----+
398 | OpCode | R1 | R2 |
399 +--------+----+----+
400 0 8 12 15
401 @end verbatim
402
403 @item RRE format: <insn> R1,R2
404 @verbatim
405 +------------------+--------+----+----+
406 | OpCode |////////| R1 | R2 |
407 +------------------+--------+----+----+
408 0 16 24 28 31
409 @end verbatim
410
411 @item RRF format: <insn> R1,R2,R3,M4
412 @verbatim
413 +------------------+----+----+----+----+
414 | OpCode | R3 | M4 | R1 | R2 |
415 +------------------+----+----+----+----+
416 0 16 20 24 28 31
417 @end verbatim
418
419 @item RRS format: <insn> R1,R2,M3,D4(B4)
420 @verbatim
421 +--------+----+----+----+-------------+----+----+--------+
422 | OpCode | R1 | R3 | B4 | D4 | M3 |////| OpCode |
423 +--------+----+----+----+-------------+----+----+--------+
424 0 8 12 16 20 32 36 40 47
425 @end verbatim
426
427 @item RS format: <insn> R1,R3,D2(B2)
428 @verbatim
429 +--------+----+----+----+-------------+
430 | OpCode | R1 | R3 | B2 | D2 |
431 +--------+----+----+----+-------------+
432 0 8 12 16 20 31
433 @end verbatim
434
435 @item RSE format: <insn> R1,R3,D2(B2)
436 @verbatim
437 +--------+----+----+----+-------------+--------+--------+
438 | OpCode | R1 | R3 | B2 | D2 |////////| OpCode |
439 +--------+----+----+----+-------------+--------+--------+
440 0 8 12 16 20 32 40 47
441 @end verbatim
442
443 @item RSI format: <insn> R1,R3,I2
444 @verbatim
445 +--------+----+----+------------------------------------+
446 | OpCode | R1 | R3 | I2 |
447 +--------+----+----+------------------------------------+
448 0 8 12 16 47
449 @end verbatim
450
451 @item RSY format: <insn> R1,R3,D2(B2)
452 @verbatim
453 +--------+----+----+----+-------------+--------+--------+
454 | OpCode | R1 | R3 | B2 | DL2 | DH2 | OpCode |
455 +--------+----+----+----+-------------+--------+--------+
456 0 8 12 16 20 32 40 47
457 @end verbatim
458
459 @item RX format: <insn> R1,D2(X2,B2)
460 @verbatim
461 +--------+----+----+----+-------------+
462 | OpCode | R1 | X2 | B2 | D2 |
463 +--------+----+----+----+-------------+
464 0 8 12 16 20 31
465 @end verbatim
466
467 @item RXE format: <insn> R1,D2(X2,B2)
468 @verbatim
469 +--------+----+----+----+-------------+--------+--------+
470 | OpCode | R1 | X2 | B2 | D2 |////////| OpCode |
471 +--------+----+----+----+-------------+--------+--------+
472 0 8 12 16 20 32 40 47
473 @end verbatim
474
475 @item RXF format: <insn> R1,R3,D2(X2,B2)
476 @verbatim
477 +--------+----+----+----+-------------+----+---+--------+
478 | OpCode | R3 | X2 | B2 | D2 | R1 |///| OpCode |
479 +--------+----+----+----+-------------+----+---+--------+
480 0 8 12 16 20 32 36 40 47
481 @end verbatim
482
483 @item RXY format: <insn> R1,D2(X2,B2)
484 @verbatim
485 +--------+----+----+----+-------------+--------+--------+
486 | OpCode | R1 | X2 | B2 | DL2 | DH2 | OpCode |
487 +--------+----+----+----+-------------+--------+--------+
488 0 8 12 16 20 32 36 40 47
489 @end verbatim
490
491 @item S format: <insn> D2(B2)
492 @verbatim
493 +------------------+----+-------------+
494 | OpCode | B2 | D2 |
495 +------------------+----+-------------+
496 0 16 20 31
497 @end verbatim
498
499 @item SI format: <insn> D1(B1),I2
500 @verbatim
501 +--------+---------+----+-------------+
502 | OpCode | I2 | B1 | D1 |
503 +--------+---------+----+-------------+
504 0 8 16 20 31
505 @end verbatim
506
507 @item SIY format: <insn> D1(B1),U2
508 @verbatim
509 +--------+---------+----+-------------+--------+--------+
510 | OpCode | I2 | B1 | DL1 | DH1 | OpCode |
511 +--------+---------+----+-------------+--------+--------+
512 0 8 16 20 32 36 40 47
513 @end verbatim
514
515 @item SIL format: <insn> D1(B1),I2
516 @verbatim
517 +------------------+----+-------------+-----------------+
518 | OpCode | B1 | D1 | I2 |
519 +------------------+----+-------------+-----------------+
520 0 16 20 32 47
521 @end verbatim
522
523 @item SS format: <insn> D1(R1,B1),D2(B3),R3
524 @verbatim
525 +--------+----+----+----+-------------+----+------------+
526 | OpCode | R1 | R3 | B1 | D1 | B2 | D2 |
527 +--------+----+----+----+-------------+----+------------+
528 0 8 12 16 20 32 36 47
529 @end verbatim
530
531 @item SSE format: <insn> D1(B1),D2(B2)
532 @verbatim
533 +------------------+----+-------------+----+------------+
534 | OpCode | B1 | D1 | B2 | D2 |
535 +------------------+----+-------------+----+------------+
536 0 8 12 16 20 32 36 47
537 @end verbatim
538
539 @item SSF format: <insn> D1(B1),D2(B2),R3
540 @verbatim
541 +--------+----+----+----+-------------+----+------------+
542 | OpCode | R3 |OpCd| B1 | D1 | B2 | D2 |
543 +--------+----+----+----+-------------+----+------------+
544 0 8 12 16 20 32 36 47
545 @end verbatim
546
547 @item VRV format: <insn> V1,D2(V2,B2),M3
548 @verbatim
549 +--------+----+----+----+-------------+----+------------+
550 | OpCode | V1 | V2 | B2 | D2 | M3 | Opcode |
551 +--------+----+----+----+-------------+----+------------+
552 0 8 12 16 20 32 36 47
553 @end verbatim
554
555 @item VRI format: <insn> V1,V2,I3,M4,M5
556 @verbatim
557 +--------+----+----+-------------+----+----+------------+
558 | OpCode | V1 | V2 | I3 | M5 | M4 | Opcode |
559 +--------+----+----+-------------+----+----+------------+
560 0 8 12 16 28 32 36 47
561 @end verbatim
562
563 @item VRX format: <insn> V1,D2(R2,B2),M3
564 @verbatim
565 +--------+----+----+----+-------------+----+------------+
566 | OpCode | V1 | R2 | B2 | D2 | M3 | Opcode |
567 +--------+----+----+----+-------------+----+------------+
568 0 8 12 16 20 32 36 47
569 @end verbatim
570
571 @item VRS format: <insn> R1,V3,D2(B2),M4
572 @verbatim
573 +--------+----+----+----+-------------+----+------------+
574 | OpCode | R1 | V3 | B2 | D2 | M4 | Opcode |
575 +--------+----+----+----+-------------+----+------------+
576 0 8 12 16 20 32 36 47
577 @end verbatim
578
579 @item VRR format: <insn> V1,V2,V3,M4,M5,M6
580 @verbatim
581 +--------+----+----+----+---+----+----+----+------------+
582 | OpCode | V1 | V2 | V3 |///| M6 | M5 | M4 | Opcode |
583 +--------+----+----+----+---+----+----+----+------------+
584 0 8 12 16 24 28 32 36 47
585 @end verbatim
586
587 @item VSI format: <insn> V1,D2(B2),I3
588 @verbatim
589 +--------+---------+----+-------------+----+------------+
590 | OpCode | I3 | B2 | D2 | V1 | Opcode |
591 +--------+---------+----+-------------+----+------------+
592 0 8 16 20 32 36 47
593 @end verbatim
594
595 @end table
596
597 For the complete list of all instruction format variants see the
598 Principles of Operation manuals.
599
600 @node s390 Aliases
601 @subsection Instruction Aliases
602 @cindex instruction aliases, s390
603 @cindex s390 instruction aliases
604
605 A specific bit pattern can have multiple mnemonics, for example
606 the bit pattern @samp{0xa7000000} has the mnemonics @samp{tmh} and
607 @samp{tmlh}. In addition, there are a number of mnemonics recognized by
608 @code{@value{AS}} that are not present in the Principles of Operation.
609 These are the short forms of the branch instructions, where the condition
610 code mask operand is encoded in the mnemonic. This is relevant for the
611 branch instructions, the compare and branch instructions, and the
612 compare and trap instructions.
613
614 For the branch instructions there are 20 condition code strings that can
615 be used as part of the mnemonic in place of a mask operand in the instruction
616 format:
617
618 @display
619 @multitable @columnfractions .30 .30
620 @headitem instruction @tab short form
621 @item bcr M1,R2 @tab b<m>r R2
622 @item bc M1,D2(X2,B2) @tab b<m> D2(X2,B2)
623 @item brc M1,I2 @tab j<m> I2
624 @item brcl M1,I2 @tab jg<m> I2
625 @end multitable
626 @end display
627
628 In the mnemonic for a branch instruction the condition code string <m>
629 can be any of the following:
630
631 @display
632 @multitable {nle} {jump on not zero / if not zeros}
633 @item o @tab jump on overflow / if ones
634 @item h @tab jump on A high
635 @item p @tab jump on plus
636 @item nle @tab jump on not low or equal
637 @item l @tab jump on A low
638 @item m @tab jump on minus
639 @item nhe @tab jump on not high or equal
640 @item lh @tab jump on low or high
641 @item ne @tab jump on A not equal B
642 @item nz @tab jump on not zero / if not zeros
643 @item e @tab jump on A equal B
644 @item z @tab jump on zero / if zeroes
645 @item nlh @tab jump on not low or high
646 @item he @tab jump on high or equal
647 @item nl @tab jump on A not low
648 @item nm @tab jump on not minus / if not mixed
649 @item le @tab jump on low or equal
650 @item nh @tab jump on A not high
651 @item np @tab jump on not plus
652 @item no @tab jump on not overflow / if not ones
653 @end multitable
654 @end display
655
656 For the compare and branch, and compare and trap instructions there
657 are 12 condition code strings that can be used as part of the mnemonic in
658 place of a mask operand in the instruction format:
659
660 @display
661 @multitable @columnfractions .40 .40
662 @headitem instruction @tab short form
663 @item crb R1,R2,M3,D4(B4) @tab crb<m> R1,R2,D4(B4)
664 @item cgrb R1,R2,M3,D4(B4) @tab cgrb<m> R1,R2,D4(B4)
665 @item crj R1,R2,M3,I4 @tab crj<m> R1,R2,I4
666 @item cgrj R1,R2,M3,I4 @tab cgrj<m> R1,R2,I4
667 @item cib R1,I2,M3,D4(B4) @tab cib<m> R1,I2,D4(B4)
668 @item cgib R1,I2,M3,D4(B4) @tab cgib<m> R1,I2,D4(B4)
669 @item cij R1,I2,M3,I4 @tab cij<m> R1,I2,I4
670 @item cgij R1,I2,M3,I4 @tab cgij<m> R1,I2,I4
671 @item crt R1,R2,M3 @tab crt<m> R1,R2
672 @item cgrt R1,R2,M3 @tab cgrt<m> R1,R2
673 @item cit R1,I2,M3 @tab cit<m> R1,I2
674 @item cgit R1,I2,M3 @tab cgit<m> R1,I2
675 @item clrb R1,R2,M3,D4(B4) @tab clrb<m> R1,R2,D4(B4)
676 @item clgrb R1,R2,M3,D4(B4) @tab clgrb<m> R1,R2,D4(B4)
677 @item clrj R1,R2,M3,I4 @tab clrj<m> R1,R2,I4
678 @item clgrj R1,R2,M3,I4 @tab clgrj<m> R1,R2,I4
679 @item clib R1,I2,M3,D4(B4) @tab clib<m> R1,I2,D4(B4)
680 @item clgib R1,I2,M3,D4(B4) @tab clgib<m> R1,I2,D4(B4)
681 @item clij R1,I2,M3,I4 @tab clij<m> R1,I2,I4
682 @item clgij R1,I2,M3,I4 @tab clgij<m> R1,I2,I4
683 @item clrt R1,R2,M3 @tab clrt<m> R1,R2
684 @item clgrt R1,R2,M3 @tab clgrt<m> R1,R2
685 @item clfit R1,I2,M3 @tab clfit<m> R1,I2
686 @item clgit R1,I2,M3 @tab clgit<m> R1,I2
687 @end multitable
688 @end display
689
690 In the mnemonic for a compare and branch and compare and trap instruction
691 the condition code string <m> can be any of the following:
692
693 @display
694 @multitable {nle} {jump on not zero / if not zeros}
695 @item h @tab jump on A high
696 @item nle @tab jump on not low or equal
697 @item l @tab jump on A low
698 @item nhe @tab jump on not high or equal
699 @item ne @tab jump on A not equal B
700 @item lh @tab jump on low or high
701 @item e @tab jump on A equal B
702 @item nlh @tab jump on not low or high
703 @item nl @tab jump on A not low
704 @item he @tab jump on high or equal
705 @item nh @tab jump on A not high
706 @item le @tab jump on low or equal
707 @end multitable
708 @end display
709
710 @node s390 Operand Modifier
711 @subsection Instruction Operand Modifier
712 @cindex instruction operand modifier, s390
713 @cindex s390 instruction operand modifier
714
715 If a symbol modifier is attached to a symbol in an expression for an
716 instruction operand field, the symbol term is replaced with a reference
717 to an object in the global offset table (GOT) or the procedure linkage
718 table (PLT). The following expressions are allowed:
719 @samp{symbol@@modifier + constant},
720 @samp{symbol@@modifier + label + constant}, and
721 @samp{symbol@@modifier - label + constant}.
722 The term @samp{symbol} is the symbol that will be entered into the GOT or
723 PLT, @samp{label} is a local label, and @samp{constant} is an arbitrary
724 expression that the assembler can evaluate to a constant value.
725
726 The term @samp{(symbol + constant1)@@modifier +/- label + constant2}
727 is also accepted but a warning message is printed and the term is
728 converted to @samp{symbol@@modifier +/- label + constant1 + constant2}.
729
730 @table @code
731 @item @@got
732 @itemx @@got12
733 The @@got modifier can be used for displacement fields, 16-bit immediate
734 fields and 32-bit pc-relative immediate fields. The @@got12 modifier is
735 synonym to @@got. The symbol is added to the GOT. For displacement
736 fields and 16-bit immediate fields the symbol term is replaced with
737 the offset from the start of the GOT to the GOT slot for the symbol.
738 For a 32-bit pc-relative field the pc-relative offset to the GOT
739 slot from the current instruction address is used.
740 @item @@gotent
741 The @@gotent modifier can be used for 32-bit pc-relative immediate fields.
742 The symbol is added to the GOT and the symbol term is replaced with
743 the pc-relative offset from the current instruction to the GOT slot for the
744 symbol.
745 @item @@gotoff
746 The @@gotoff modifier can be used for 16-bit immediate fields. The symbol
747 term is replaced with the offset from the start of the GOT to the
748 address of the symbol.
749 @item @@gotplt
750 The @@gotplt modifier can be used for displacement fields, 16-bit immediate
751 fields, and 32-bit pc-relative immediate fields. A procedure linkage
752 table entry is generated for the symbol and a jump slot for the symbol
753 is added to the GOT. For displacement fields and 16-bit immediate
754 fields the symbol term is replaced with the offset from the start of the
755 GOT to the jump slot for the symbol. For a 32-bit pc-relative field
756 the pc-relative offset to the jump slot from the current instruction
757 address is used.
758 @item @@plt
759 The @@plt modifier can be used for 16-bit and 32-bit pc-relative immediate
760 fields. A procedure linkage table entry is generated for the symbol.
761 The symbol term is replaced with the relative offset from the current
762 instruction to the PLT entry for the symbol.
763 @item @@pltoff
764 The @@pltoff modifier can be used for 16-bit immediate fields. The symbol
765 term is replaced with the offset from the start of the PLT to the address
766 of the symbol.
767 @item @@gotntpoff
768 The @@gotntpoff modifier can be used for displacement fields. The symbol
769 is added to the static TLS block and the negated offset to the symbol
770 in the static TLS block is added to the GOT. The symbol term is replaced
771 with the offset to the GOT slot from the start of the GOT.
772 @item @@indntpoff
773 The @@indntpoff modifier can be used for 32-bit pc-relative immediate
774 fields. The symbol is added to the static TLS block and the negated offset
775 to the symbol in the static TLS block is added to the GOT. The symbol term
776 is replaced with the pc-relative offset to the GOT slot from the current
777 instruction address.
778 @end table
779
780 For more information about the thread local storage modifiers
781 @samp{gotntpoff} and @samp{indntpoff} see the ELF extension documentation
782 @samp{ELF Handling For Thread-Local Storage}.
783
784 @node s390 Instruction Marker
785 @subsection Instruction Marker
786 @cindex instruction marker, s390
787 @cindex s390 instruction marker
788
789 The thread local storage instruction markers are used by the linker to
790 perform code optimization.
791
792 @table @code
793 @item :tls_load
794 The :tls_load marker is used to flag the load instruction in the initial
795 exec TLS model that retrieves the offset from the thread pointer to a
796 thread local storage variable from the GOT.
797 @item :tls_gdcall
798 The :tls_gdcall marker is used to flag the branch-and-save instruction to
799 the __tls_get_offset function in the global dynamic TLS model.
800 @item :tls_ldcall
801 The :tls_ldcall marker is used to flag the branch-and-save instruction to
802 the __tls_get_offset function in the local dynamic TLS model.
803 @end table
804
805 For more information about the thread local storage instruction marker
806 and the linker optimizations see the ELF extension documentation
807 @samp{ELF Handling For Thread-Local Storage}.
808
809 @node s390 Literal Pool Entries
810 @subsection Literal Pool Entries
811 @cindex literal pool entries, s390
812 @cindex s390 literal pool entries
813
814 A literal pool is a collection of values. To access the values a pointer
815 to the literal pool is loaded to a register, the literal pool register.
816 Usually, register %r13 is used as the literal pool register
817 (@ref{s390 Register}). Literal pool entries are created by adding the
818 suffix :lit1, :lit2, :lit4, or :lit8 to the end of an expression for an
819 instruction operand. The expression is added to the literal pool and the
820 operand is replaced with the offset to the literal in the literal pool.
821
822 @table @code
823 @item :lit1
824 The literal pool entry is created as an 8-bit value. An operand modifier
825 must not be used for the original expression.
826 @item :lit2
827 The literal pool entry is created as a 16 bit value. The operand modifier
828 @@got may be used in the original expression. The term @samp{x@@got:lit2}
829 will put the got offset for the global symbol x to the literal pool as
830 16 bit value.
831 @item :lit4
832 The literal pool entry is created as a 32-bit value. The operand modifier
833 @@got and @@plt may be used in the original expression. The term
834 @samp{x@@got:lit4} will put the got offset for the global symbol x to the
835 literal pool as a 32-bit value. The term @samp{x@@plt:lit4} will put the
836 plt offset for the global symbol x to the literal pool as a 32-bit value.
837 @item :lit8
838 The literal pool entry is created as a 64-bit value. The operand modifier
839 @@got and @@plt may be used in the original expression. The term
840 @samp{x@@got:lit8} will put the got offset for the global symbol x to the
841 literal pool as a 64-bit value. The term @samp{x@@plt:lit8} will put the
842 plt offset for the global symbol x to the literal pool as a 64-bit value.
843 @end table
844
845 The assembler directive @samp{.ltorg} is used to emit all literal pool
846 entries to the current position.
847
848 @node s390 Directives
849 @section Assembler Directives
850
851 @code{@value{AS}} for s390 supports all of the standard ELF
852 assembler directives as outlined in the main part of this document.
853 Some directives have been extended and there are some additional
854 directives, which are only available for the s390 @code{@value{AS}}.
855
856 @table @code
857 @cindex @code{.insn} directive, s390
858 @item .insn
859 This directive permits the numeric representation of an instructions
860 and makes the assembler insert the operands according to one of the
861 instructions formats for @samp{.insn} (@ref{s390 Formats}).
862 For example, the instruction @samp{l %r1,24(%r15)} could be written as
863 @samp{.insn rx,0x58000000,%r1,24(%r15)}.
864 @cindex @code{.short} directive, s390
865 @cindex @code{.long} directive, s390
866 @cindex @code{.quad} directive, s390
867 @item .short
868 @itemx .long
869 @itemx .quad
870 This directive places one or more 16-bit (.short), 32-bit (.long), or
871 64-bit (.quad) values into the current section. If an ELF or TLS modifier
872 is used only the following expressions are allowed:
873 @samp{symbol@@modifier + constant},
874 @samp{symbol@@modifier + label + constant}, and
875 @samp{symbol@@modifier - label + constant}.
876 The following modifiers are available:
877 @table @code
878 @item @@got
879 @itemx @@got12
880 The @@got modifier can be used for .short, .long and .quad. The @@got12
881 modifier is synonym to @@got. The symbol is added to the GOT. The symbol
882 term is replaced with offset from the start of the GOT to the GOT slot for
883 the symbol.
884 @item @@gotoff
885 The @@gotoff modifier can be used for .short, .long and .quad. The symbol
886 term is replaced with the offset from the start of the GOT to the address
887 of the symbol.
888 @item @@gotplt
889 The @@gotplt modifier can be used for .long and .quad. A procedure linkage
890 table entry is generated for the symbol and a jump slot for the symbol
891 is added to the GOT. The symbol term is replaced with the offset from the
892 start of the GOT to the jump slot for the symbol.
893 @item @@plt
894 The @@plt modifier can be used for .long and .quad. A procedure linkage
895 table entry us generated for the symbol. The symbol term is replaced with
896 the address of the PLT entry for the symbol.
897 @item @@pltoff
898 The @@pltoff modifier can be used for .short, .long and .quad. The symbol
899 term is replaced with the offset from the start of the PLT to the address
900 of the symbol.
901 @item @@tlsgd
902 @itemx @@tlsldm
903 The @@tlsgd and @@tlsldm modifier can be used for .long and .quad. A
904 tls_index structure for the symbol is added to the GOT. The symbol term is
905 replaced with the offset from the start of the GOT to the tls_index structure.
906 @item @@gotntpoff
907 @itemx @@indntpoff
908 The @@gotntpoff and @@indntpoff modifier can be used for .long and .quad.
909 The symbol is added to the static TLS block and the negated offset to the
910 symbol in the static TLS block is added to the GOT. For @@gotntpoff the
911 symbol term is replaced with the offset from the start of the GOT to the
912 GOT slot, for @@indntpoff the symbol term is replaced with the address
913 of the GOT slot.
914 @item @@dtpoff
915 The @@dtpoff modifier can be used for .long and .quad. The symbol term
916 is replaced with the offset of the symbol relative to the start of the
917 TLS block it is contained in.
918 @item @@ntpoff
919 The @@ntpoff modifier can be used for .long and .quad. The symbol term
920 is replaced with the offset of the symbol relative to the TCB pointer.
921 @end table
922
923 For more information about the thread local storage modifiers see the
924 ELF extension documentation @samp{ELF Handling For Thread-Local Storage}.
925
926 @cindex @code{.ltorg} directive, s390
927 @item .ltorg
928 This directive causes the current contents of the literal pool to be
929 dumped to the current location (@ref{s390 Literal Pool Entries}).
930
931 @cindex @code{.machine} directive, s390
932 @item .machine @var{STRING}[+@var{EXTENSION}]@dots{}
933
934 This directive allows changing the machine for which code is
935 generated. @code{string} may be any of the @code{-march=}
936 selection options, or @code{push}, or @code{pop}. @code{.machine
937 push} saves the currently selected cpu, which may be restored with
938 @code{.machine pop}. Be aware that the cpu string has to be put
939 into double quotes in case it contains characters not appropriate
940 for identifiers. So you have to write @code{"z9-109"} instead of
941 just @code{z9-109}. Extensions can be specified after the cpu
942 name, separated by plus characters. Valid extensions are:
943 @code{htm},
944 @code{nohtm},
945 @code{vx},
946 @code{novx}.
947 They extend the basic instruction set with features from a higher
948 cpu level, or remove support for a feature from the given cpu
949 level.
950
951 Example: @code{z13+nohtm} allows all instructions of the z13 cpu
952 except instructions from the HTM facility.
953
954 @cindex @code{.machinemode} directive, s390
955 @item .machinemode string
956 This directive allows one to change the architecture mode for which code
957 is being generated. @code{string} may be @code{esa}, @code{zarch},
958 @code{zarch_nohighgprs}, @code{push}, or @code{pop}.
959 @code{.machinemode zarch_nohighgprs} can be used to prevent the
960 @code{highgprs} flag from being set in the ELF header of the output
961 file. This is useful in situations where the code is gated with a
962 runtime check which makes sure that the code is only executed on
963 kernels providing the @code{highgprs} feature.
964 @code{.machinemode push} saves the currently selected mode, which may
965 be restored with @code{.machinemode pop}.
966 @end table
967
968 @node s390 Floating Point
969 @section Floating Point
970 @cindex floating point, s390
971 @cindex s390 floating point
972
973 The assembler recognizes both the @sc{ieee} floating-point instruction and
974 the hexadecimal floating-point instructions. The floating-point constructors
975 @samp{.float}, @samp{.single}, and @samp{.double} always emit the
976 @sc{ieee} format. To assemble hexadecimal floating-point constants the
977 @samp{.long} and @samp{.quad} directives must be used.