@@ -9,7 +9,7 @@ Use `Param()` to reference arguments by name. The `Load()` function can be used
|
||||
[embedmd]:# (asm.go go /.*TEXT.*Second/ /RET.*/)
|
||||
```go
|
||||
TEXT("Second", "func(x, y int32) int32")
|
||||
y := Load(Param("y"), GP32v())
|
||||
y := Load(Param("y"), GP32())
|
||||
Store(y, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
@@ -34,7 +34,7 @@ Strings and slices actually consist of multiple components under the hood: see [
|
||||
[embedmd]:# (asm.go go /.*TEXT.*StringLen/ /RET.*/)
|
||||
```go
|
||||
TEXT("StringLen", "func(s string) int")
|
||||
strlen := Load(Param("s").Len(), GP64v())
|
||||
strlen := Load(Param("s").Len(), GP64())
|
||||
Store(strlen, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
@@ -48,7 +48,7 @@ Arrays can be indexed with the `Index()` method. For example, the following retu
|
||||
[embedmd]:# (asm.go go /.*TEXT.*ArrayThree/ /RET.*/)
|
||||
```go
|
||||
TEXT("ArrayThree", "func(a [7]uint64) uint64")
|
||||
a3 := Load(Param("a").Index(3), GP64v())
|
||||
a3 := Load(Param("a").Index(3), GP64())
|
||||
Store(a3, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
@@ -87,7 +87,7 @@ The following function will return the `Float64` field from this struct.
|
||||
[embedmd]:# (asm.go go /.*TEXT.*FieldFloat64/ /RET.*/)
|
||||
```go
|
||||
TEXT("FieldFloat64", "func(s Struct) float64")
|
||||
f64 := Load(Param("s").Field("Float64"), Xv())
|
||||
f64 := Load(Param("s").Field("Float64"), XMM())
|
||||
Store(f64, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
@@ -99,7 +99,7 @@ Complex types `complex{64,128}` are actually just pairs of `float{32,64}` values
|
||||
[embedmd]:# (asm.go go /.*TEXT.*FieldComplex64Imag/ /RET.*/)
|
||||
```go
|
||||
TEXT("FieldComplex64Imag", "func(s Struct) float32")
|
||||
c64i := Load(Param("s").Field("Complex64").Imag(), Xv())
|
||||
c64i := Load(Param("s").Field("Complex64").Imag(), XMM())
|
||||
Store(c64i, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
@@ -111,7 +111,7 @@ The above methods may be composed to reference arbitrarily nested data structure
|
||||
[embedmd]:# (asm.go go /.*TEXT.*FieldArrayTwoBTwo/ /RET.*/)
|
||||
```go
|
||||
TEXT("FieldArrayTwoBTwo", "func(s Struct) byte")
|
||||
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8v())
|
||||
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8())
|
||||
Store(b2, ReturnIndex(0))
|
||||
RET()
|
||||
```
|
||||
|
||||
@@ -10,92 +10,92 @@ func main() {
|
||||
Package("github.com/mmcloughlin/avo/examples/args")
|
||||
|
||||
TEXT("Second", "func(x, y int32) int32")
|
||||
y := Load(Param("y"), GP32v())
|
||||
y := Load(Param("y"), GP32())
|
||||
Store(y, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("StringLen", "func(s string) int")
|
||||
strlen := Load(Param("s").Len(), GP64v())
|
||||
strlen := Load(Param("s").Len(), GP64())
|
||||
Store(strlen, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("SliceLen", "func(s []int) int")
|
||||
slicelen := Load(Param("s").Len(), GP64v())
|
||||
slicelen := Load(Param("s").Len(), GP64())
|
||||
Store(slicelen, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("SliceCap", "func(s []int) int")
|
||||
slicecap := Load(Param("s").Cap(), GP64v())
|
||||
slicecap := Load(Param("s").Cap(), GP64())
|
||||
Store(slicecap, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("ArrayThree", "func(a [7]uint64) uint64")
|
||||
a3 := Load(Param("a").Index(3), GP64v())
|
||||
a3 := Load(Param("a").Index(3), GP64())
|
||||
Store(a3, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldByte", "func(s Struct) byte")
|
||||
b := Load(Param("s").Field("Byte"), GP8v())
|
||||
b := Load(Param("s").Field("Byte"), GP8())
|
||||
Store(b, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldInt8", "func(s Struct) int8")
|
||||
i8 := Load(Param("s").Field("Int8"), GP8v())
|
||||
i8 := Load(Param("s").Field("Int8"), GP8())
|
||||
Store(i8, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldUint16", "func(s Struct) uint16")
|
||||
u16 := Load(Param("s").Field("Uint16"), GP16v())
|
||||
u16 := Load(Param("s").Field("Uint16"), GP16())
|
||||
Store(u16, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldInt32", "func(s Struct) int32")
|
||||
i32 := Load(Param("s").Field("Int32"), GP32v())
|
||||
i32 := Load(Param("s").Field("Int32"), GP32())
|
||||
Store(i32, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldUint64", "func(s Struct) uint64")
|
||||
u64 := Load(Param("s").Field("Uint64"), GP64v())
|
||||
u64 := Load(Param("s").Field("Uint64"), GP64())
|
||||
Store(u64, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldFloat32", "func(s Struct) float32")
|
||||
f32 := Load(Param("s").Field("Float32"), Xv())
|
||||
f32 := Load(Param("s").Field("Float32"), XMM())
|
||||
Store(f32, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldFloat64", "func(s Struct) float64")
|
||||
f64 := Load(Param("s").Field("Float64"), Xv())
|
||||
f64 := Load(Param("s").Field("Float64"), XMM())
|
||||
Store(f64, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldStringLen", "func(s Struct) int")
|
||||
l := Load(Param("s").Field("String").Len(), GP64v())
|
||||
l := Load(Param("s").Field("String").Len(), GP64())
|
||||
Store(l, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldSliceCap", "func(s Struct) int")
|
||||
c := Load(Param("s").Field("Slice").Cap(), GP64v())
|
||||
c := Load(Param("s").Field("Slice").Cap(), GP64())
|
||||
Store(c, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldArrayTwoBTwo", "func(s Struct) byte")
|
||||
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8v())
|
||||
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8())
|
||||
Store(b2, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldArrayOneC", "func(s Struct) uint16")
|
||||
c1 := Load(Param("s").Field("Array").Index(1).Field("C"), GP16v())
|
||||
c1 := Load(Param("s").Field("Array").Index(1).Field("C"), GP16())
|
||||
Store(c1, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldComplex64Imag", "func(s Struct) float32")
|
||||
c64i := Load(Param("s").Field("Complex64").Imag(), Xv())
|
||||
c64i := Load(Param("s").Field("Complex64").Imag(), XMM())
|
||||
Store(c64i, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
TEXT("FieldComplex128Real", "func(s Struct) float64")
|
||||
c128r := Load(Param("s").Field("Complex128").Real(), Xv())
|
||||
c128r := Load(Param("s").Field("Complex128").Real(), XMM())
|
||||
Store(c128r, ReturnIndex(0))
|
||||
RET()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user