Search
lxdream.org :: lxdream/src/tools/gendec.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/tools/gendec.h
changeset 359:c588dce7ebde
next420:e6f43dec3cf0
author nkeynes
date Thu Aug 23 12:33:27 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Commit decoder generator
Translator work in progress
Fix mac.l, mac.w in emu core
file annotate diff log raw
nkeynes@359
     1
/**
nkeynes@359
     2
 * $Id: gendec.h,v 1.1 2007-08-23 12:33:27 nkeynes Exp $
nkeynes@359
     3
 *
nkeynes@359
     4
 * mem is responsible for creating and maintaining the overall system memory
nkeynes@359
     5
 * map, as visible from the SH4 processor. (Note the ARM has a different map)
nkeynes@359
     6
 *
nkeynes@359
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@359
     8
 *
nkeynes@359
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@359
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@359
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@359
    12
 * (at your option) any later version.
nkeynes@359
    13
 *
nkeynes@359
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@359
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@359
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@359
    17
 * GNU General Public License for more details.
nkeynes@359
    18
 */
nkeynes@359
    19
nkeynes@359
    20
#ifndef gendec_H
nkeynes@359
    21
#define gendec_H
nkeynes@359
    22
nkeynes@359
    23
#include <stdint.h>
nkeynes@359
    24
nkeynes@359
    25
#ifdef __cplusplus
nkeynes@359
    26
extern "C" {
nkeynes@359
    27
#endif
nkeynes@359
    28
nkeynes@359
    29
#define MAX_OPERAND_NAME 8
nkeynes@359
    30
#define MAX_OPERANDS 4
nkeynes@359
    31
#define MAX_OPERATION_FORMAT 64
nkeynes@359
    32
#define MAX_RULES 512
nkeynes@359
    33
nkeynes@359
    34
#define USE_NONE 0
nkeynes@359
    35
#define USE_READ 1
nkeynes@359
    36
#define USE_WRITE 2
nkeynes@359
    37
#define USE_READWRITE 3
nkeynes@359
    38
nkeynes@359
    39
struct operand {
nkeynes@359
    40
    int bit_count;
nkeynes@359
    41
    int bit_shift;
nkeynes@359
    42
    int left_shift;
nkeynes@359
    43
    int is_signed;
nkeynes@359
    44
    int use_mode;
nkeynes@359
    45
    char name[MAX_OPERAND_NAME+1];
nkeynes@359
    46
};
nkeynes@359
    47
nkeynes@359
    48
struct rule {
nkeynes@359
    49
    uint32_t bits;
nkeynes@359
    50
    uint32_t mask;
nkeynes@359
    51
    int bit_count;
nkeynes@359
    52
    int operand_count;
nkeynes@359
    53
    int flags_use_mode;
nkeynes@359
    54
    struct operand operands[MAX_OPERANDS];
nkeynes@359
    55
    char format[MAX_OPERATION_FORMAT+1];
nkeynes@359
    56
};
nkeynes@359
    57
nkeynes@359
    58
struct ruleset {
nkeynes@359
    59
    uint32_t rule_count;
nkeynes@359
    60
    struct rule *rules[MAX_RULES];
nkeynes@359
    61
};
nkeynes@359
    62
nkeynes@359
    63
struct ruleset *parse_ruleset_file( FILE *f );
nkeynes@359
    64
    void dump_ruleset( struct ruleset *rules, FILE *f );
nkeynes@359
    65
nkeynes@359
    66
struct action {
nkeynes@359
    67
    char operand_names[MAX_OPERANDS][MAX_OPERAND_NAME+1];
nkeynes@359
    68
    char *body;
nkeynes@359
    69
};
nkeynes@359
    70
nkeynes@359
    71
struct actionset {
nkeynes@359
    72
    char *pretext;
nkeynes@359
    73
    char *posttext;
nkeynes@359
    74
    char *actions[MAX_RULES];
nkeynes@359
    75
};
nkeynes@359
    76
nkeynes@359
    77
struct actionset *parse_action_file( struct ruleset *rules, FILE *f );
nkeynes@359
    78
nkeynes@359
    79
int generate_decoder( struct ruleset *rules, struct actionset *actions, FILE *f );
nkeynes@359
    80
nkeynes@359
    81
#ifdef __cplusplus
nkeynes@359
    82
}
nkeynes@359
    83
#endif
nkeynes@359
    84
#endif
.