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:
28
doc/docs.md
28
doc/docs.md
@ -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.
|
||||
|
Reference in New Issue
Block a user