TEMU  4.4
The Terma Emulator
Assembler.h
Go to the documentation of this file.
1 //===-- temu-c/Assembler.h - Assembler and Dissassebler----------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 /*!
9  \file
10 
11  This file contains the declarations of the assembler and disassembler.
12 */
13 
14 #ifndef TEMU_SUPPORT_ASSEMBLER
15 #define TEMU_SUPPORT_ASSEMBLER
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <stdint.h>
21 #include "temu-c/Support/Attributes.h"
22 /*! Assemble an instruction
23  * \param Cpu processor for which to assemble.
24  * \param AsmStr String with instruction in the CPUs assembler.
25  * \result Instruction bitpattern.
26  */
27 TEMU_API uint32_t temu_assemble(void *Cpu, const char *AsmStr);
28 
29 /*! Disassemble an instruction.
30  * \warning The function returns a malloced string. You have ownership
31  * and is responsible for calling free() on it.
32  * \result A pointer to a malloced instruction string
33  * or null incase of failure.
34  */
36 
37 /*! Disassemble an instruction.
38  * \warning The function returns a thread local string. It is borrowed
39  * and not allowed to escape the current thread without a copy.
40  * \result A pointer to a a thread local instruction string
41  * or null incase of failure.
42  */
43 TEMU_API const char* temu_disassembleAuto(void *Cpu, uint32_t Instr);
44 
45 /*! Assemble an instruction to memory
46  * \param Cpu processor for which to assemble.
47  * \param AsmStr String with instruction in the CPUs assembler.
48  * \param Addr Physical address of where to put the instruction.
49  */
50 TEMU_API void temu_assembleToMemory(void *Cpu, const char *AsmStr, uint64_t Addr);
51 
52 /*! Disassemble an instruction in memory
53  *
54  * The function dissasmbles an instruction and retuns a string allocated
55  * on the heap. You are responsible for its release using free().
56  *
57  * \warning The function returns a malloced string. You have ownership
58  * and are responsible for calling free() on it.
59  *
60  * \param Cpu CPU whose memory space will be used for disasembling.
61  * \param Addr Physical address of instruction to dissassemble.
62  * \result A pointer to a malloced instruction string
63  * or null incase of failure.
64  */
66 
67 // Returns a thread local string instead
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* ! TEMU_SUPPORT_ASSEMBLER */
temu_assembleToMemory
TEMU_API void temu_assembleToMemory(void *Cpu, const char *AsmStr, uint64_t Addr)
temu_disassembleAuto
const TEMU_API char * temu_disassembleAuto(void *Cpu, uint32_t Instr)
temu_disassembleMemory
TEMU_API char * temu_disassembleMemory(void *Cpu, uint64_t Addr)
temu_disassembleMemoryAuto
const TEMU_API char * temu_disassembleMemoryAuto(void *Cpu, uint64_t Addr)
temu_disassemble
TEMU_API char * temu_disassemble(void *Cpu, uint32_t Instr)