You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/emulator/vmcalls.md
+58
Original file line number
Diff line number
Diff line change
@@ -271,3 +271,61 @@ inline std::optional<Script::sgaddr_t> Script::call(gaddr_t address, Args&&... a
271
271
}
272
272
```
273
273
From `script.call(...)` as implemented in the [gamedev example](https://github.com/libriscv/libriscv/blob/master/examples/gamedev/script.hpp). `ScriptDepthMeter` measures the current call depth in order to avoid too many recursive calls back into the script, while also using the faster `vmcall()` on the first call.
274
+
275
+
## VM Calls with the C API
276
+
277
+
In the C API each argument register has to be populated manually, and the return value(s) have to be read as well.
278
+
279
+
A general rule for passing data to a function is that:
280
+
1. Each integer goes into the next free integer register
281
+
2. Each pointer goes into the next free integer register
282
+
3. Each float goes into the next free float register of that type
0 commit comments