summaryrefslogtreecommitdiff
path: root/src/arch/operands/immediate.h
blob: d66349aad3edc7f0885a1f3c74404ad7001c9be4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

/* Chrysalide - Outil d'analyse de fichiers binaires
 * immediate.h - prototypes pour les opérandes représentant des valeurs numériques
 *
 * Copyright (C) 2020-2024 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  Chrysalide is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Chrysalide is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Chrysalide.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _ARCH_OPERANDS_IMMEDIATE_H
#define _ARCH_OPERANDS_IMMEDIATE_H


#include <stdbool.h>
#include <stdint.h>


#include "../operand.h"
#include "../../analysis/content.h"
#include "../../common/datatypes.h"
#include "../../glibext/helpers.h"



#define G_TYPE_IMMEDIATE_OPERAND (g_immediate_operand_get_type())

DECLARE_GTYPE(GImmediateOperand, g_immediate_operand, G, IMMEDIATE_OPERAND);


/* Etats particuliers d'un opérande de valeur immédiate */
typedef enum _ImmOpFlag
{
    IOF_ZERO_PADDING_BY_DEFAULT = AOF_USER_FLAG(0), /* Bourrage avec 0 par défaut ?*/
    IOF_ZERO_PADDING = AOF_USER_FLAG(1),    /* Bourrage avec 0 ?           */

} ImmOpFlag;

/* Grande ligne d'un format d'affichage */
typedef enum _ImmOperandDisplay
{
    IOD_BIN,                                /* Impression en binaire       */
    IOD_OCT,                                /* Impression en octal         */
    IOD_DEC,                                /* Impression en décimal       */
    IOD_HEX,                                /* Impression en hexadécimal   */
    IOD_CHAR,                               /* Impression en base 26       */

    IOD_COUNT

} ImmOperandDisplay;


/* Crée un opérande réprésentant une valeur numérique. */
GArchOperand *g_immediate_operand_new_from_value(MemoryDataSize, uint64_t);

/* Crée un opérande réprésentant une valeur numérique. */
GArchOperand *g_immediate_operand_new_from_data(MemoryDataSize, const GBinContent *, vmpa2t *, bool *, SourceEndian);

/* Renseigne la taille de la valeur indiquée à la construction. */
MemoryDataSize g_immediate_operand_get_size(const GImmediateOperand *);

/* Fournit la valeur portée par une opérande numérique. */
bool g_immediate_operand_get_value(const GImmediateOperand *, MemoryDataSize, ...);

/* Définit la nouvelle valeur de l'opérande à une valeur. */
void g_immediate_operand_set_value(GImmediateOperand *, MemoryDataSize, uint64_t);

/* Fournit la valeur brute représentée par l'opérande. */
uint64_t g_immediate_operand_get_raw_value(const GImmediateOperand *);

/* Indique le signe d'une valeur immédiate. */
bool g_immediate_operand_is_negative(const GImmediateOperand *);

/* Définit le format textuel par défaut de la valeur. */
void g_immediate_operand_set_default_display(GImmediateOperand *, ImmOperandDisplay);

/* Indique le format textuel par défaut de la valeur. */
ImmOperandDisplay g_immediate_operand_get_default_display(const GImmediateOperand *);

/* Définit la grande ligne du format textuel de la valeur. */
void g_immediate_operand_set_display(GImmediateOperand *, ImmOperandDisplay);

/* Indique la grande ligne du format textuel de la valeur. */
ImmOperandDisplay g_immediate_operand_get_display(const GImmediateOperand *);



#endif  /* _ARCH_OPERANDS_IMMEDIATE_H */