1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: reimplement inline assembly (#8645)

This commit is contained in:
crthpl
2021-03-16 17:43:17 -07:00
committed by GitHub
parent dd9f9c2718
commit fafb035fb5
29 changed files with 2089 additions and 335 deletions

View File

@ -3848,20 +3848,26 @@ To improve safety and maintainability, operator overloading is limited:
are auto generated when the operators are defined though they must return the same type.
## Inline assembly
TODO: not implemented yet
```v failcompile
fn main() {
a := 10
asm x64 {
mov eax, [a]
add eax, 10
mov [a], eax
}
<!-- ignore because it doesn't pass fmt test (why?) -->
```v ignore
a := 100
b := 20
mut c := 0
asm amd64 {
mov eax, a
add eax, b
mov c, eax
; =r (c) as c // output
; r (a) as a // input
r (b) as b
}
println('a: $a') // 100
println('b: $b') // 20
println('c: $c') // 120
```
For more examples, see [github.com/vlang/v/tree/master/vlib/v/tests/assembly/asm_test.amd64.v](https://github.com/vlang/v/tree/master/vlib/v/tests/assembly/asm_test.amd64.v)
## Translating C to V
TODO: translating C to V will be available in V 0.3.