-
Notifications
You must be signed in to change notification settings - Fork 127
Calling Assembly #139
Comments
@SpaceboyRoss01 Might be easier to create an ArrayBuffer with x86-64 instructions in js (I think i've seen npm module for this), then pass it to a native function that'll run it. Just curious, what are you trying to do with it? 😃 |
I'm going to make some things work better for some drivers. |
I would not go that way... forget about assembler at all, you can do the same in plain C if you need some performance. So far only needed things to write the drivers in Javascript are bindings for memory access, catch interruptions and read & write on ports, everything else can be done in high-level Javascript. |
How many instructions are in assembly |
I'm trying to get to usermode in javascript |
It depends of the CPU, but about 200-300 is a rought estimation.
Are you trying to move from ring 0 to ring 3? Why? The purposse of runtime.js is just to have everything in ring 0 for performance and apply a language-based security system... |
I'm also doing this to work on executing binary files |
If it's mainly for performance reasons, you could write the drivers in C or C++ and compile them to WebAssembly via Binaryen. After that you load them by requiring the produced JavaScript file and wrapping the necessary functions so you can call them later. You should know that you're going to be left in a mess if you try to do this. It's much cleaner to translate the programs to JavaScript, and also it's much more foolproof (compiling and running binaries on top of runtime.js is going to be very error prone). By the way, if all you plan on doing is being able to execute assembly and just loading in programs on top of that, you're going to end up compiling the whole Linux kernel as well, because all programs depend on kernel instructions somewhere. |
I'm trying to execute assembly and I'm having a problem figuring out how to impliment this system call in the
NativesObject
class. Does anyone know the best way? I think that if I have an enum that has all of the assembly opcodes that I could store them inside of a map so when someone executes the function it would read the map and execute the opcode.Current Code:
The text was updated successfully, but these errors were encountered: