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

Subversion Repositories marca

[/] [marca/] [trunk/] [spar/] [expand.c] - Blame information for rev 8

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 "spar.h"
19
#include "expand.h"
20
#include "code.h"
21
#include "optab.h"
22
 
23
void expand_mod(void)
24
{
25
  struct op o = get_current_seg()->code[get_current_seg()->pos];
26
 
27
  if ((o.op == MOD) || (o.op == UMOD))
28
    {
29
      if (o.args[0].val.regnum != o.args[2].val.regnum)
30
        {
31
          struct seg* seg = get_current_seg();
32
 
33
          set_op(seg, seg->pos, MOV);
34
          set_mode(seg, seg->pos, 0, 'r');
35
          set_regnum(seg, seg->pos, 0, o.args[2].val.regnum);
36
          set_mode(seg, seg->pos, 1, 'r');
37
          set_regnum(seg, seg->pos, 1, o.args[0].val.regnum);
38
          set_listing(seg, seg->pos, xsprintf("mov\tr%d, r%d",
39
                                              o.args[2].val.regnum,
40
                                              o.args[0].val.regnum));
41
 
42
          seg->pos++;
43
          adjust_segsize(seg, seg->pos+1);
44
 
45
          set_op(seg, seg->pos, o.op);
46
          set_mode(seg, seg->pos, 0, 'r');
47
          set_regnum(seg, seg->pos, 0, o.args[2].val.regnum);
48
          set_mode(seg, seg->pos, 1, 'r');
49
          set_regnum(seg, seg->pos, 1, o.args[1].val.regnum);
50
          set_mode(seg, seg->pos, 2, 'r');
51
          set_regnum(seg, seg->pos, 2, 0); /* this should never be used */
52
          set_listing(seg, seg->pos, xsprintf("%s\tr%d, r%d, r%d",
53
                                              o.op == MOD ? "mod" : "umod",
54
                                              o.args[2].val.regnum,
55
                                              o.args[1].val.regnum,
56
                                              o.args[2].val.regnum));
57
        }
58
    }
59
}

powered by: WebSVN 2.1.0

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