Debian Codegraph @

tests/alloc/gp8/asm.go

raw symbols SCIP
1 //go:build ignore
2
3 package main
4
5 import (
6 "strconv"
7
8 . "github.com/mmcloughlin/avo/build"
9 . "github.com/mmcloughlin/avo/operand"
10 . "github.com/mmcloughlin/avo/reg"
11 )
12
13 func main() {
14 // n is the number of 8-bit registers to use.
15 // 15 low-byte registers (excluding SP)
16 // 4 high-byte registers AH,BH,CH,DH
17 const n = 19
18
19 TEXT("GP8", NOSPLIT, "func() uint8")
20 Doc("GP8 returns the sum 1+2+...+" + strconv.Itoa(n) + " using " + strconv.Itoa(n) + " distinct 8-bit registers.")
21
22 // Allocate registers and initialize.
23 x := make([]Register, n)
24 i := 0
25
26 // Low byte registers.
27 for ; i < 15; i++ {
28 x[i] = GP8L()
29 MOVB(U8(i+1), x[i])
30 }
31
32 // High byte registers.
33 for ; i < n; i++ {
34 x[i] = GP8H()
35 MOVB(U8(i+1), x[i])
36 }
37
38 // Sum them up.
39 for i := 1; i < n; i++ {
40 ADDB(x[i], x[0])
41 }
42
43 // Return.
44 Store(x[0], ReturnIndex(0))
45 RET()
46
47 Generate()
48 }