Browse Source

initial commit!

master
Isabelle L. 6 years ago
commit
ce1d99dc37
8 changed files with 231 additions and 0 deletions
  1. +2
    -0
      .gitignore
  2. +95
    -0
      Cargo.lock
  3. +9
    -0
      Cargo.toml
  4. +7
    -0
      LICENSE
  5. +2
    -0
      README.md
  6. +106
    -0
      src/cpu.rs
  7. +7
    -0
      src/lib.rs
  8. +3
    -0
      src/main.rs

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
/target
**/*.rs.bk

+ 95
- 0
Cargo.lock View File

@@ -0,0 +1,95 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "byteorder"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "ceres"
version = "0.1.0"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"logos 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "logos"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"logos-derive 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "logos-derive"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "quote"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "regex-syntax"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "syn"
version = "0.15.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "ucd-util"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "utf8-ranges"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[metadata]
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
"checksum logos 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f494e22d293fa05db60b3fd95fb30e9409feb5672b56ce6f250f99d9fbae6b93"
"checksum logos-derive 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "13ff1b1068db09ee21d12baf55eccc0900a781a735273e0a606f6f4fbb32a322"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db"
"checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48"
"checksum syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)" = "8b4f551a91e2e3848aeef8751d0d4eec9489b6474c720fd4c55958d8d31a430c"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde"

+ 9
- 0
Cargo.toml View File

@@ -0,0 +1,9 @@
[package]
name = "ceres"
version = "0.1.0"
authors = ["Izzy <me@izzabelle.dev>"]
edition = "2018"

[dependencies]
byteorder = "1.3.2"
logos = "0.9.7"

+ 7
- 0
LICENSE View File

@@ -0,0 +1,7 @@
Copyright 2019 ilsko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 2
- 0
README.md View File

@@ -0,0 +1,2 @@
# Ceres
### a shitty fantasy console written in rust usng a proprietary asm instruction set

+ 106
- 0
src/cpu.rs View File

@@ -0,0 +1,106 @@
/// 16 register cpu only capable of holding 16 bit unsigned integers
pub struct Cpu {
// zero register
z0: u16,

// system registers
sp: u16,
ra: u16,

// argument registers
a0: u16,
a1: u16,
a2: u16,

// return registers
v0: u16,
v1: u16,

// temp registers
t0: u16,
t1: u16,
t2: u16,
t3: u16,
t4: u16,
t5: u16,
t6: u16,
t7: u16,
}

/// initializes cpu with 0x00 in all registers
impl Default for Cpu {
fn default() -> Self {
Cpu {
z0: 0,
sp: 0,
ra: 0,
a0: 0,
a1: 0,
a2: 0,
v0: 0,
v1: 0,
t0: 0,
t1: 0,
t2: 0,
t3: 0,
t4: 0,
t5: 0,
t6: 0,
t7: 0,
}
}
}

/// indexes registers by register number and returns reference to the registers
/// contents
impl std::ops::Index<usize> for Cpu {
type Output = u16;

fn index(&self, idx: usize) -> &u16 {
match idx {
0 => &self.z0,
1 => &self.sp,
2 => &self.ra,
3 => &self.a0,
4 => &self.a1,
5 => &self.a2,
6 => &self.v0,
7 => &self.v1,
8 => &self.t0,
9 => &self.t1,
10 => &self.t2,
11 => &self.t3,
12 => &self.t4,
13 => &self.t5,
14 => &self.t6,
15 => &self.t7,
_ => panic!("Invalid register number"),
}
}
}

/// indexes registers by register number and returns mutable reference to the
/// registers contents
impl std::ops::IndexMut<usize> for Cpu {
fn index_mut(&mut self, idx: usize) -> &mut u16 {
match idx {
0 => &mut self.z0,
1 => &mut self.sp,
2 => &mut self.ra,
3 => &mut self.a0,
4 => &mut self.a1,
5 => &mut self.a2,
6 => &mut self.v0,
7 => &mut self.v1,
8 => &mut self.t0,
9 => &mut self.t1,
10 => &mut self.t2,
11 => &mut self.t3,
12 => &mut self.t4,
13 => &mut self.t5,
14 => &mut self.t6,
15 => &mut self.t7,
_ => panic!("Invalid register number"),
}
}
}

+ 7
- 0
src/lib.rs View File

@@ -0,0 +1,7 @@
pub mod cpu;

use cpu::Cpu;

pub struct System {
cpu: Cpu,
}

+ 3
- 0
src/main.rs View File

@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

Loading…
Cancel
Save