Machine code: Difference between revisions
→{{header|Go}}: Now uses actual x64 opcodes rather than x86/x64 'glue code' .
m (Clarified the program a little bit.) |
(→{{header|Go}}: Now uses actual x64 opcodes rather than x86/x64 'glue code' .) |
||
Line 374:
This task requires the use of 'cgo' which enables Go to interface with C code by importing a pseudo-package called "C".
Although Go supports both 32-bit and 64-bit architectures, I'm writing this on a 64-bit Ubuntu
There doesn't appear to be a way to cast a pointer to a native buffer to a Go function pointer so that the machine code can be run directly. I've therefore written a C function to perform this step and embedded it in the program which 'cgo' allows us to do.
Line 399:
func main() {
code := []byte{
}
le := len(code)
|