| 1 |
// Code generated by command: go run asm.go -out issue122.s -stubs stub.go. DO NOT EDIT. |
| 2 |
|
| 3 |
#include "textflag.h" |
| 4 |
|
| 5 |
// func Triangle(n uint64) uint64 |
| 6 |
TEXT ·Triangle(SB), NOSPLIT, $0-16 |
| 7 |
MOVQ n+0(FP), AX |
| 8 |
|
| 9 |
// Initialize sum register to zero. |
| 10 |
XORQ CX, CX |
| 11 |
|
| 12 |
loop_even: |
| 13 |
loop_odd: |
| 14 |
// Loop until n is zero. |
| 15 |
CMPQ AX, $0x00 |
| 16 |
JE done |
| 17 |
|
| 18 |
// Add n to sum. |
| 19 |
ADDQ AX, CX |
| 20 |
|
| 21 |
// Decrement n. |
| 22 |
DECQ AX |
| 23 |
|
| 24 |
// Jump to one of the loop labels depending on parity. |
| 25 |
TESTQ $0x00000001, AX |
| 26 |
JZ loop_even |
| 27 |
JMP loop_odd |
| 28 |
|
| 29 |
done: |
| 30 |
// Store sum to return value. |
| 31 |
MOVQ CX, ret+8(FP) |
| 32 |
RET |