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

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [spar/] [segtab.c] - Blame information for rev 3

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 <stdlib.h>
21
#include <stdio.h>
22
 
23
#include "spar.h"
24
#include "segtab.h"
25
 
26
static struct seg segtab[4];
27
static uint8_t current_segnum;
28
 
29
void init_seg(uint8_t segnum, uint32_t size)
30
{
31
  int i;
32
 
33
  segtab[segnum].max = size;
34
  segtab[segnum].code = xmalloc(segtab[segnum].max*sizeof(struct op));
35
 
36
  for (i = 0; i < segtab[segnum].max; i++)
37
    set_listing(&segtab[segnum], i, "");
38
}
39
 
40
void set_current_segnum(uint8_t segnum)
41
{
42
  current_segnum = segnum;
43
}
44
 
45
uint8_t get_current_segnum(void)
46
{
47
  return current_segnum;
48
}
49
 
50
struct seg *get_current_seg(void)
51
{
52
  return &segtab[current_segnum];
53
}
54
 
55
struct seg *get_seg(uint8_t segnum)
56
{
57
  return &segtab[segnum];
58
}
59
 
60
void adjust_segsize(struct seg *seg, uint32_t size)
61
{
62
  if (size >= seg->max-1)
63
    {
64
      uint32_t i;
65
 
66
      seg->code = xrealloc(seg->code, 2*seg->max*sizeof(struct op));
67
      for (i = seg->max; i < 2*seg->max; i++)
68
        {
69
          set_listing(seg, i, "");
70
        }
71
      seg->max *= 2;
72
    }
73
}
74
 

powered by: WebSVN 2.1.0

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