kasm

所属分类:嵌入式/单片机/硬件编程
开发工具:kotlin
文件大小:0KB
下载次数:0
上传日期:2019-10-23 17:07:16
上 传 者sh-1993
说明:  Kotlin的汇编程序库,
(Assembler library for Kotlin,)

文件列表:
.idea/ (0, 2019-10-23)
.idea/codeStyles/ (0, 2019-10-23)
.idea/codeStyles/Project.xml (683, 2019-10-23)
.idea/codeStyles/codeStyleConfig.xml (209, 2019-10-23)
.idea/encodings.xml (135, 2019-10-23)
.idea/kotlinc.xml (324, 2019-10-23)
.idea/libraries/ (0, 2019-10-23)
.idea/libraries/KotlinJavaRuntime.xml (1063, 2019-10-23)
.idea/libraries/lib.xml (213, 2019-10-23)
.idea/misc.xml (451, 2019-10-23)
.idea/modules.xml (642, 2019-10-23)
.idea/uiDesigner.xml (8792, 2019-10-23)
.idea/vcs.xml (180, 2019-10-23)
LICENSE.txt (16725, 2019-10-23)
kasm-core/ (0, 2019-10-23)
kasm-core/kasm-core.iml (475, 2019-10-23)
kasm-core/src/ (0, 2019-10-23)
kasm-core/src/kasm/ (0, 2019-10-23)
kasm-core/src/kasm/Address.kt (856, 2019-10-23)
kasm-core/src/kasm/ext/ (0, 2019-10-23)
kasm-core/src/kasm/ext/Ext.kt (3171, 2019-10-23)
kasm-core/src/kasm/x64/ (0, 2019-10-23)
kasm-core/src/kasm/x64/Misc.kt (6508, 2019-10-23)
kasm-core/src/kasm/x64/Registers.kt (30425, 2019-10-23)
kasm-gen/ (0, 2019-10-23)
kasm-gen/kasm-gen.iml (532, 2019-10-23)
kasm-gen/src/ (0, 2019-10-23)
kasm-gen/src/kasm/ (0, 2019-10-23)
kasm-gen/src/kasm/gen/ (0, 2019-10-23)
kasm-gen/src/kasm/gen/x64/ (0, 2019-10-23)
kasm-gen/src/kasm/gen/x64/CodeWriter.kt (6763, 2019-10-23)
kasm-gen/src/kasm/gen/x64/Generator.kt (7673, 2019-10-23)
kasm-gen/src/kasm/gen/x64/InstructionParsing.kt (32975, 2019-10-23)
kasm-gen/src/kasm/gen/x64/OperandParsing.kt (24900, 2019-10-23)
kasm-gen/src/kasm/gen/x64/Operands.kt (8131, 2019-10-23)
kasm-gen/src/kasm/gen/x64/x64.csv (345761, 2019-10-23)
kasm-native/ (0, 2019-10-23)
kasm-native/kasm-native.iml (2552, 2019-10-23)
... ...

# Kasm *Kasm* is a runtime assembler library for *Kotlin*. It allows to assemble and execute machine code at runtime. ## Features * x86-64 up to AVX2 * Allows *save* code execution, handling segmentation faults and zero divisions etc. * Support for automatic CPU feature detection (see `CpuId`) * Contains a Kotlin DSL (see `Assembler`) * Supports disassembling (through [Capstone](http://www.capstone-engine.org/)) * Full control over encoding (see `EncodingOptions`): - Encode with or without *SIB* (if possible) - Force *REX* prefix - Use long or short *VEX* prefix - Set *unused* bits in *Mod.RM*/*REX*/*VEX* - Legacy prefix order ## Installation $ git clone --recursive https://github.com/evoasm/kasm The project does currently come without any build files. It is recommended that you import the project into [IntelliJ IDEA](https://www.jetbrains.com/idea/). #### Requirements * Kotlin/JVM * [Capstone](http://www.capstone-engine.org/) for disassembling (*optional*). * POSIX-compliant OS (Linux and Mac OS X should both work). * CMake (see below, *optional*) If you want support for code execution and disassembling (through [Capstone](http://www.capstone-engine.org/)) you must build the corresponding native modules $ cd kasm-native/lib $ mkdir build $ cd build $ cmake .. Shared libraries are output to `kasm-native/lib`. If you get a `UnsatisfiedLinkError` exception add `-Djava.library.path=../kasm-native/lib` to your VM options. ## Examples ### `Assembler` ```kotlin val buffer = NativeBuffer(1024) Assembler(buffer).emitStackFrame { mov(RBX, 0) mov(RAX, 0) divRdxRax(RBX) } buffer.execute() // will throw kasm.ZeroDivisionException ``` ```kotlin Assembler(buffer).emitStackFrame { mov(RBX, AddressExpression(0x0)) } buffer.execute() // will throw kasm.SegmentationFaultException ``` ### `Instruction` ```kotlin val buffer = NativeBuffer(1024) // add eax, [ebx] AddR32Rm32.encode(buffer, EAX, AddressExpression32(EBX)) // add [ebx], eax AddRmR32.encode(buffer, AddressExpression32(EBX), EAX) ``` ### `CpuId` ```kotlin println(CpuId.features) // [SEP, CLFSH, DS, ACPI, SSE, SSE2, SS, ... ``` ### `EncodingOptions` ```kotlin AddRm32Imm32.encode(buffer, EAX, 0x10, options = EncodingOptions(rexX = 0x0, forceRex = true)) println(buffer.toByteString()) //40 81 C0 10 00 00 00 AddRm32Imm32.encode(buffer, EAX, 0x10, options = EncodingOptions(rexX = 0x1, forceRex = true)) println(buffer.toByteString()) //42 81 C0 10 00 00 00 ``` ## License [MPL-2.0][license] [license]: https://github.com/evoasm/kasm/blob/master/LICENSE.txt

近期下载者

相关文件


收藏者