OpenCores
URL https://opencores.org/ocsvn/marca/marca/trunk

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [spar/] [fixes.c] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jeunes2
/* This file is part of the assembler "spar" for marca.
2
   Copyright (C) 2007 Wolfgang Puffitsch
3
 
4
   This program is free software; you can redistribute it and/or modify it
5
   under the terms of the GNU Library General Public License as published
6
   by the Free Software Foundation; either version 2, or (at your option)
7
   any later version.
8
 
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Library General Public License for more details.
13
 
14
   You should have received a copy of the GNU Library General Public
15
   License along with this program; if not, write to the Free Software
16
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
17
 
18
#include <stdint.h>
19
 
20
#include <stdio.h>
21
 
22
#include "spar.h"
23
#include "ui.h"
24
#include "code.h"
25
#include "exprs.h"
26
#include "fixes.h"
27
#include "optab.h"
28
#include "segtab.h"
29
#include "symtab.h"
30
 
31
int fix_operands(struct seg *seg, uint32_t pos)
32
{
33
  uint8_t count = get_arg_count(seg, pos);
34
  uint8_t index;
35
  int retval = 0;
36
 
37
  for (index = 0; index < count; index++)
38
    {
39
      if (get_arg_type(seg, pos, index) == 'a')
40
        {
41
          set_expr(seg, pos, index,
42
                   xsprintf("(%s)-%d", get_expr(seg, pos, index), pos));
43
        }
44
    }
45
 
46
  return retval;
47
}
48
 
49
int fix_code(struct seg *seg, uint32_t pos)
50
{
51
  uint8_t count = get_arg_count(seg, pos);
52
  uint8_t index;
53
  uint16_t data;
54
 
55
  data = get_op_code(seg, pos);
56
  for (index = 0; index < count; index++)
57
    {
58
      switch (get_arg_type(seg, pos, index))
59
        {
60
        case 'r':
61
          data |= (get_regnum(seg, pos, index)
62
                   & ((uint16_t)0xFFFF >> (16-get_arg_width(seg, pos, index))))
63
                                       << get_arg_offset(seg, pos, index);
64
          break;
65
        case 'n':
66
        case 'a':
67
          data |= (expr_evaluate(get_expr(seg, pos, index))
68
                   & ((uint16_t)0xFFFF >> (16-get_arg_width(seg, pos, index))))
69
                                       << get_arg_offset(seg, pos, index);
70
          break;
71
        }
72
    }
73
  set_code(seg, pos, data);
74
 
75
  return 0;
76
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.