Text file src/cmd/asm/internal/asm/testdata/amd64.s

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This input was created by taking the instruction productions in
     6  // the old assembler's (6a's) grammar and hand-writing complete
     7  // instructions for each rule, to guarantee we cover the same space.
     8  
     9  #include "../../../../../runtime/textflag.h"
    10  
    11  TEXT	foo(SB), DUPOK|NOSPLIT, $0
    12  
    13  // LTYPE1 nonrem	{ outcode($1, &$2); }
    14  	NEGQ	R11
    15  	NEGQ	4(R11)
    16  	NEGQ	foo+4(SB)
    17  
    18  // LTYPE2 rimnon	{ outcode($1, &$2); }
    19  	INT	$4
    20  	DIVB	R11
    21  	DIVB	4(R11)
    22  	DIVB	foo+4(SB)
    23  
    24  // LTYPE3 rimrem	{ outcode($1, &$2); }
    25  	SUBQ $4, DI
    26  	SUBQ R11, DI
    27  	SUBQ 4(R11), DI
    28  	SUBQ foo+4(SB), DI
    29  	SUBQ $4, 8(R12)
    30  	SUBQ R11, 8(R12)
    31  	SUBQ R11, foo+4(SB)
    32  
    33  // LTYPE4 remrim	{ outcode($1, &$2); }
    34  	CMPB	CX, $4
    35  
    36  // LTYPER nonrel	{ outcode($1, &$2); }
    37  label:
    38  	JB	-4(PC) // JCS -4(PC)
    39  	JB	label // JCS 17
    40  
    41  // LTYPEC spec3	{ outcode($1, &$2); }
    42  	JCS	2(PC)
    43  	JMP	-4(PC)
    44  	JCS	2(PC)
    45  	JMP	label // JMP 17
    46  	JCS	2(PC)
    47  	JMP	foo+4(SB)
    48  	JCS	2(PC)
    49  	JMP	bar<>+4(SB)
    50  	JCS	2(PC)
    51  	JMP	bar<>+4(SB)(R11*4)
    52  	JCS	2(PC)
    53  	JMP	*4(SP) // JMP 4(SP)
    54  	JCS	2(PC)
    55  	JMP	*(R12) // JMP (R12)
    56  	JCS	2(PC)
    57  //	JMP	*(R12*4) // TODO: This line is silently dropped on the floor!
    58  	JCS	2(PC)
    59  	JMP	*(R12)(R13*4) // JMP (R12)(R13*4)
    60  	JCS	2(PC)
    61  	JMP	*(AX) // JMP (AX)
    62  	JCS	2(PC)
    63  	JMP	*(SP) // JMP (SP)
    64  	JCS	2(PC)
    65  //	JMP	*(AX*4) // TODO: This line is silently dropped on the floor!
    66  	JCS	2(PC)
    67  	JMP	*(AX)(AX*4) // JMP (AX)(AX*4)
    68  	JCS	2(PC)
    69  	JMP	4(SP)
    70  	JCS	2(PC)
    71  	JMP	(R12)
    72  	JCS	2(PC)
    73  //	JMP	(R12*4) // TODO: This line is silently dropped on the floor!
    74  	JCS	2(PC)
    75  	JMP	(R12)(R13*4)
    76  	JCS	2(PC)
    77  	JMP	(AX)
    78  	JCS	2(PC)
    79  	JMP	(SP)
    80  	JCS	2(PC)
    81  //	JMP	(AX*4) // TODO: This line is silently dropped on the floor!
    82  	JCS	2(PC)
    83  	JMP	(AX)(AX*4)
    84  	JCS	2(PC)
    85  	JMP	R13
    86  
    87  // LTYPEN spec4	{ outcode($1, &$2); }
    88  	NOP
    89  	NOP	AX
    90  	NOP	foo+4(SB)
    91  
    92  // LTYPES spec5	{ outcode($1, &$2); }
    93  	SHLL	CX, R12
    94  	SHLL	CX, foo+4(SB)
    95  	// Old syntax, still accepted:
    96  	SHLL	CX, R11:AX // SHLL CX, AX, R11
    97  
    98  // LTYPEM spec6	{ outcode($1, &$2); }
    99  	MOVL	AX, R11
   100  	MOVL	$4, R11
   101  //	MOVL	AX, 0(AX):DS // no longer works - did it ever?
   102  
   103  // LTYPEI spec7	{ outcode($1, &$2); }
   104  	IMULB	DX
   105  	IMULW	DX, BX
   106  	IMULL	R11, R12
   107  	IMULQ	foo+4(SB), R11
   108  
   109  // LTYPEXC spec8	{ outcode($1, &$2); }
   110  	CMPPD	X1, X2, 4
   111  	CMPPD	foo+4(SB), X2, 4
   112  
   113  // LTYPEX spec9	{ outcode($1, &$2); }
   114  	PINSRW	$4, AX, X2
   115  	PINSRW	$4, foo+4(SB), X2
   116  
   117  // LTYPERT spec10	{ outcode($1, &$2); }
   118  	JCS	2(PC)
   119  	RETFL	$4
   120  
   121  // Was bug: LOOP is a branch instruction.
   122  	JCS	2(PC)
   123  loop:
   124  	LOOP	loop // LOOP
   125  
   126  	// Intel pseudonyms for our own renamings.
   127  	PADDD	M2, M1 // PADDL M2, M1
   128  	MOVDQ2Q	X1, M1 // MOVQ X1, M1
   129  	MOVNTDQ	X1, (AX)	// MOVNTO X1, (AX)
   130  	MOVOA	(AX), X1	// MOVO (AX), X1
   131  
   132  // Tests for SP indexed addresses.
   133  	MOVQ	foo(SP)(AX*1), BX		// 488b1c04
   134  	MOVQ	foo+32(SP)(CX*2), DX		// 488b544c20
   135  	MOVQ	foo+32323(SP)(R8*4), R9		// 4e8b8c84437e0000
   136  	MOVL	foo(SP)(SI*8), DI		// 8b3cf4
   137  	MOVL	foo+32(SP)(R10*1), R11		// 468b5c1420
   138  	MOVL	foo+32323(SP)(R12*2), R13	// 468bac64437e0000
   139  	MOVW	foo(SP)(AX*4), R8		// 66448b0484
   140  	MOVW	foo+32(SP)(R9*8), CX		// 66428b4ccc20
   141  	MOVW	foo+32323(SP)(AX*1), DX		// 668b9404437e0000
   142  	MOVB	foo(SP)(AX*2), AL		// 8a0444
   143  	MOVB	foo+32(SP)(CX*4), AH		// 8a648c20
   144  	MOVB	foo+32323(SP)(CX*8), R9		// 448a8ccc437e0000
   145  
   146  // Tests for TLS reference.
   147  	MOVQ	(TLS), AX
   148  	MOVQ	8(TLS), DX
   149  
   150  // LTYPE0 nonnon	{ outcode($1, &$2); }
   151  	RET // c3
   152  	RET	foo(SB)
   153  

View as plain text