| 1 |
package asm |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
) |
| 6 |
|
| 7 |
|
| 8 |
type Register uint8 |
| 9 |
|
| 10 |
|
| 11 |
const R0 Register = 0 |
| 12 |
|
| 13 |
|
| 14 |
const ( |
| 15 |
R1 Register = R0 + 1 + iota |
| 16 |
R2 |
| 17 |
R3 |
| 18 |
R4 |
| 19 |
R5 |
| 20 |
) |
| 21 |
|
| 22 |
|
| 23 |
const ( |
| 24 |
R6 Register = R5 + 1 + iota |
| 25 |
R7 |
| 26 |
R8 |
| 27 |
R9 |
| 28 |
) |
| 29 |
|
| 30 |
|
| 31 |
const ( |
| 32 |
R10 Register = R9 + 1 |
| 33 |
RFP = R10 |
| 34 |
) |
| 35 |
|
| 36 |
|
| 37 |
const ( |
| 38 |
PseudoMapFD = R1 |
| 39 |
PseudoMapValue = R2 |
| 40 |
PseudoCall = R1 |
| 41 |
PseudoFunc = R4 |
| 42 |
PseudoKfuncCall = R2 |
| 43 |
PseudoMayGoto = R0 |
| 44 |
) |
| 45 |
|
| 46 |
func (r Register) String() string { |
| 47 |
v := uint8(r) |
| 48 |
if v == 10 { |
| 49 |
return "rfp" |
| 50 |
} |
| 51 |
return fmt.Sprintf("r%d", v) |
| 52 |
} |