Commit 7300eb69 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

        * src/vm/cpu.hh, src/vm/cpu.cc: Uniformize register accessors, 
        removing deprecated ones.
parent a42aa1f8
2003-10-11 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/cpu.hh, src/vm/cpu.cc: Uniformize register accessors,
removing deprecated ones.
2003-09-08 Benot Perrot <benoit@lrde.epita.fr>
* src/vm/memory.hh: Increase default stack size to 512 Ko.
......
......@@ -2,20 +2,20 @@
(Created-By-Prcs-Version 1 3 2)
(Project-Description "")
(Project-Version mipsy 0 55)
(Parent-Version mipsy 0 54)
(Project-Version mipsy 0 56)
(Parent-Version mipsy 0 55)
(Version-Log
"Index: ChangeLog
from Benot Perrot <benoit@lrde.epita.fr>
* src/vm/memory.hh: Increase default stack size to 512 Ko.
* src/vm/cpu.hh, src/vm/cpu.cc: Uniformize register accessors,
removing deprecated ones.
")
(New-Version-Log
"")
(Checkin-Time "Mon, 08 Sep 2003 11:29:26 +0200")
(Checkin-Time "Sat, 11 Oct 2003 15:22:01 +0200")
(Checkin-Login benoit)
(Files
......@@ -23,7 +23,7 @@ from Beno
;; ./
(AUTHORS (mipsy/0_AUTHORS 1.1 644))
(COPYING (mipsy/1_COPYING 1.1 644))
(ChangeLog (mipsy/2_ChangeLog 1.49 644))
(ChangeLog (mipsy/2_ChangeLog 1.50 644))
(Makefile.am (mipsy/3_Makefile.a 1.6 644))
(NEWS (mipsy/b/25_NEWS 1.5 644))
(README (mipsy/4_README 1.2 644))
......@@ -100,8 +100,8 @@ from Beno
;; ./src/vm/
(src/vm/Makefile.am (mipsy/b/0_Makefile.a 1.3 644))
(src/vm/cpu.hh (mipsy/b/1_cpu.hh 1.7 644))
(src/vm/cpu.cc (mipsy/b/5_virtual_ma 1.16 604))
(src/vm/cpu.hh (mipsy/b/1_cpu.hh 1.8 644))
(src/vm/cpu.cc (mipsy/b/5_virtual_ma 1.17 604))
(src/vm/memory.hh (mipsy/b/2_memory.hh 1.7 644))
(src/vm/segment.hh (mipsy/b/3_segment.hh 1.2 644))
(src/vm/table.hh (mipsy/b/4_table.hh 1.2 644))
......
......@@ -385,16 +385,16 @@ namespace vm
void
Cpu::visit(const inst::Jal& jal)
{
set_ra(get_pc());
set_pc(get_ra() + jal.get_label());
set_register(Cpu::ra, get_pc());
set_pc(get_register(Cpu::ra) + jal.get_label());
// Assume it is a call
call();
}
void
Cpu::visit(const inst::Jalr& jalr)
{
set_ra(get_pc());
set_register(Cpu::ra, get_pc());
set_pc(get_register(jalr.get_dest()));
// Assume it is a call
......@@ -432,7 +432,7 @@ namespace vm
// Assume it is a call
call();
set_ra(get_pc());
set_register(Cpu::ra, get_pc());
set_pc(get_pc() + bgezal.get_label());
}
}
......@@ -464,7 +464,7 @@ namespace vm
// Assume it is a call
call();
set_ra(get_pc());
set_register(Cpu::ra, get_pc());
set_pc(get_pc() + bltzal.get_label());
}
}
......@@ -503,16 +503,16 @@ namespace vm
void
Cpu::visit(const inst::Syscall&)
{
switch (get_v0())
switch (get_register(Cpu::v0))
{
// print_int (integer: $a0)
case 1:
ostr << get_a0();
ostr << get_register(Cpu::a0);
break;
// print_string (buffer: $a0)
case 4:
for (int i = get_a0(); true; ++i)
for (int i = get_register(Cpu::a0); true; ++i)
{
char b = memory.load_byte(i);
if (b == 0)
......@@ -526,27 +526,28 @@ namespace vm
{
int i = 0;
int c = 0;
for (; (i < get_a1() - 1) && (c != '\n') && (c != '\r') ; ++i)
for (; (i < get_register(Cpu::a1) - 1) && (c != '\n') && (c != '\r');
++i)
{
c = istr.get();
if (istr.eof())
break;
memory.store_byte(get_a0() + i, c);
memory.store_byte(get_register(Cpu::a0) + i, c);
}
memory.store_byte(get_a0() + i, 0);
memory.store_byte(get_register(Cpu::a0) + i, 0);
}
break;
// sbrk (size: $a0)
case 9:
set_v0(memory.sbrk(get_a0()));
set_register(Cpu::v0, memory.sbrk(get_register(Cpu::a0)));
break;
// exit (status : $a0)
case 10:
halt = true;
if (!exit_status)
exit_status = (exit_t) get_a0();
exit_status = (exit_t) get_register(Cpu::a0);
break;
default:
......
......@@ -85,31 +85,14 @@ namespace vm
}
public:
register_t get_at() const { return GPR[at]; }
void set_at(register_t r) { GPR[at] = r; }
register_t get_v0() const { return GPR[v0]; }
void set_v0(register_t r) { GPR[v0] = r; }
register_t get_a0() const { return GPR[a0]; }
register_t get_a1() const { return GPR[a1]; }
register_t get_sp() const { return GPR[sp]; }
void set_sp(register_t r) { GPR[sp] = r; }
register_t get_fp() const { return GPR[fp]; }
void set_fp(register_t r) { GPR[fp] = r; }
register_t get_ra() const { return GPR[ra]; }
void set_ra(register_t r) { GPR[ra] = r; }
register_t get_register(kind_t k) const
{
return GPR[k];
}
void set_register(kind_t k, register_t r)
{
GPR[k] = r;
if (k != Cpu::zero)
GPR[k] = r;
}
bool has_unlimited(int i) const
......@@ -133,8 +116,9 @@ namespace vm
precondition(has_unlimited(reg.get_index ()));
return unlimited.get(reg.get_index ());
}
precondition(reg.get_kind() == inst::Register::general);
return GPR[reg.get_index()];
precondition(reg.get_kind() == inst::Register::general &&
Cpu::zero <= reg.get_index() && reg.get_index() <= Cpu::ra);
return get_register((kind_t) reg.get_index());
}
void set_register(const inst::Register& reg, register_t r)
{
......@@ -143,12 +127,11 @@ namespace vm
unlimited.put(reg.get_index (), r);
return;
}
precondition(reg.get_kind() == inst::Register::general);
if (reg.get_index() != 0)
GPR[reg.get_index()] = r;
precondition(reg.get_kind() == inst::Register::general &&
Cpu::zero <= reg.get_index() && reg.get_index() <= Cpu::ra);
set_register((kind_t) reg.get_index(), r);
}
public:
register_t get_hi() const { return hi; }
void set_hi(register_t r) { hi = r; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment