Honestly, that’s probably a bad idea. (:
My assembler isn’t meant for actual end user use and pretty much only exists to make testing and generating test programs easier. If you don’t want to assemble services like its 1964 you can just use… normal Rust.
Take a look at the guest programs in the PolkaVM repository. Those are all valid JAM programs, with the only difference being that they are packaged in a .polkavm
container (and they don’t have the hardcoded JAM dispatch table at the start, so they’re not valid JAM toplevel services, but they can be executed in an inner JAM VM). You can trivially extract the code section from a .polkavm
blob and run it on your own PVM implementation (currently this requires writing a tiny bit of Rust code to call ProgramParts::from_bytes
and extract the code_and_jump_table
field, but I suppose we could add a subcommand to the polkatool to make it possible to do it on the command line; although ideally everyone would standardize on a single program interchange format so that all of the tooling can be shared and things like debug info can be supported).
Calling JAM-specific hostcalls is also easy. Here’s a snippet with a few JAM host functions defined (calling these from Rust will trigger the appropriate ecalli
instruction):
#[polkavm_derive::polkavm_import]
extern "C" {
#[polkavm_import(index = 0)]
pub fn gas() -> i64;
#[polkavm_import(index = 1)]
pub fn lookup(service: u32, hash_ptr: *const u8, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 2)]
pub fn read(service: u32, key_ptr: *const u8, key_len: u32, out: *mut u8, out_len: u32) -> u32;
#[polkavm_import(index = 3)]
pub fn write(key_ptr: *const u8, key_len: u32, value: *const u8, value_len: u32) -> u32;
}
Anyway, this is completely off topic here. If you want to talk about this either make a new topic, or create an issue in the PolkaVM repo, or message me on Element and I can help you out to get the toolchain going.