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