Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
19
Task/Machine-code/Pluto/machine-code-2.pluto
Normal file
19
Task/Machine-code/Pluto/machine-code-2.pluto
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local ffi = require "pluto:ffi"
|
||||
local lib = ffi.open("./mclib.so")
|
||||
lib:cdef[[
|
||||
unsigned char run_machine_code(const char *code, unsigned char a, unsigned char b, int len);
|
||||
]]
|
||||
|
||||
local a = 7
|
||||
local b = 12
|
||||
|
||||
-- x64 opcodes for this task
|
||||
local m = {
|
||||
0x55, 0x48, 0x89, 0xe5, 0x89, 0x7d,
|
||||
0xfc, 0x89, 0x75, 0xf8, 0x8b, 0x75,
|
||||
0xfc, 0x03, 0x75, 0xf8, 0x89, 0x75,
|
||||
0xf4, 0x8b, 0x45, 0xf4, 0x5d, 0xc3
|
||||
}
|
||||
|
||||
local code = m:mapped(|byte| -> string.char(byte)):concat("")
|
||||
print($"{a} + {b} = {lib.run_machine_code(code, a, b, #m)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue