assembly - Poke opcodes into memory -
hi trying understand whether possible take instruction opcodes , 'poke' them memory or smehow convert them binary program. have found abandoned lisp project here: http://common-lisp.net/viewvc/cl-x86-asm/cl-x86-asm/ takes x86 asm instructions , converts them opcodes (please see example below). project not go further complete creation of binary executable. hence need 'manually' ideas can me. thanks.
;; assemble code in (cl-x86-asm::assemble-forms '((.entry :push :eax) (:sub :eax #xfffea) (:mov :eax :ebx) (:pop :eax) (:push :eax) (.exit :ret))
processing...
;; print assembled segment (cl-x86-asm::print-segment) * segment type data-segment segment size 0000000c bytes 50 81 05 00 0f ff ea 89 03 58 50 c3
clozure common lisp example has built-in. called lap, lisp assembly program.
see defx86lapfunction
.
example:
(defx86lapfunction fast-mod ((number arg_y) (divisor arg_z)) (xorq (% imm1) (% imm1)) (mov (% number) (% imm0)) (div (% divisor)) (mov (% imm1) (% arg_z)) (single-value-return))
sbcl can similar vop (virtual operations).
Comments
Post a Comment