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

Subversion Repositories marca

[/] [marca/] [trunk/] [spar/] [code.c] - Blame information for rev 9

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
#include <stdio.h>
20
#include <stdlib.h>
21
#include <string.h>
22
 
23
#include "code.h"
24
#include "segtab.h"
25
 
26
void set_op(struct seg *seg, uint32_t pos, uint16_t op)
27
{
28
  seg->code[pos].op = op;
29
}
30
 
31
uint16_t get_op(struct seg *seg, uint32_t pos)
32
{
33
  return seg->code[pos].op;
34
}
35
 
36
void set_mode(struct seg *seg, uint32_t pos, uint8_t index, char mode)
37
{
38
  seg->code[pos].args[index].mode = mode;
39
}
40
 
41
char get_mode(struct seg *seg, uint32_t pos, uint8_t index)
42
{
43
  return seg->code[pos].args[index].mode;
44
}
45
 
46
void set_regnum(struct seg *seg, uint32_t pos, uint8_t index, uint16_t regnum)
47
{
48
  seg->code[pos].args[index].val.regnum = regnum;
49
}
50
 
51
uint16_t get_regnum(struct seg *seg, uint32_t pos, uint8_t index)
52
{
53
  return seg->code[pos].args[index].val.regnum;
54
}
55
 
56
void set_expr(struct seg *seg, uint32_t pos, uint8_t index, char * expr)
57
{
58
  seg->code[pos].args[index].val.expr = expr;
59
}
60
 
61
char *get_expr(struct seg *seg, uint32_t pos, uint8_t index)
62
{
63
  return seg->code[pos].args[index].val.expr;
64
}
65
 
66
void set_code(struct seg *seg, uint32_t pos, uint16_t code)
67
{
68
  seg->code[pos].code = code;
69
}
70
 
71
uint16_t get_code(struct seg *seg, uint32_t pos)
72
{
73
  return seg->code[pos].code;
74
}
75
 
76
void set_listing(struct seg *seg, uint32_t pos, const char *listing)
77
{
78
  if (listing != NULL)
79
    {
80
      strncpy(seg->code[pos].listing, listing, CODE_MAX_LISTLEN);
81
      seg->code[pos].listing[CODE_MAX_LISTLEN-1] = '\0';
82
    }
83
  else
84
    {
85
      seg->code[pos].listing[0] = '\0';
86
    }
87
}
88
 
89
void trace_listing(struct seg *seg, uint32_t pos, const char *text)
90
{
91
  if (text != NULL)
92
    {
93
      strncat(seg->code[pos].listing, text, CODE_MAX_LISTLEN);
94
      seg->code[pos].listing[CODE_MAX_LISTLEN-1] = '\0';
95
    }
96
}
97
 
98
const char *get_listing(struct seg *seg, uint32_t pos)
99
{
100
  return seg->code[pos].listing;
101
}

powered by: WebSVN 2.1.0

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