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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.3.0/] [cpu/] [or32/] [common-i386.h] - Blame information for rev 403

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

Line No. Rev Author Line
1 19 jeremybenn
/* common-i386.h -- Assembler routines used in rec_i386.h and op_i386.h
2
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
 
21
/* This is needed because we can't move an mmx register to a general purpose
22
 * register. */
23
static union {
24
  struct {
25
    uint32_t low32;
26
    uint32_t high32;
27
  } val3232;
28
  uint64_t val64;
29
} useless_x86;
30
 
31
/* Sets the PC with a specified value */
32
static void set_pc(oraddr_t pc)
33
{
34
  /* I could just use pc as a memory argument, but if I do that then gcc may put
35
   * the value of pc onto the stack, in which case gcc would also shift the
36
   * stack twice, which would result in two add 4, %esp instructions and a
37
   * mov %eax, *%esp, which would not only be slow but it would take up more
38
   * space. */
39
  asm("movq %%mm0, %0\n"
40
      "\tmovl %2, %1\n"
41
      "\tmovq %3, %%mm0"
42
      : "=m" (useless_x86.val64),
43
        "=m" (useless_x86.val3232.high32)
44
      : "r" (pc),
45
        "m" (useless_x86.val64));
46
}
47
 
48
/* Returns the current value of the pc */
49
static oraddr_t get_pc(void)
50
{
51
  asm("movq %%mm0, %0" : "=m" (useless_x86.val64));
52
  return useless_x86.val3232.high32;
53
}
54
 
55
/* Updates the runtime.sim.cycles counter */
56
static void upd_sim_cycles(void)
57
{
58
  asm volatile ("movq %%mm0, %0\n" : "=m" (useless_x86.val64));
59
  runtime.sim.cycles += scheduler.job_queue->time - useless_x86.val3232.low32;
60
  scheduler.job_queue->time = useless_x86.val3232.low32;
61
  cpu_state.pc = useless_x86.val3232.high32;
62
}
63
 

powered by: WebSVN 2.1.0

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