Crates.io | m68000 |
lib.rs | m68000 |
version | 0.2.1 |
source | src |
created_at | 2022-08-29 02:41:12.367625 |
updated_at | 2023-08-28 23:04:31.176193 |
description | A Motorola 68000 interpreter, disassembler and assembler (code emitter) |
homepage | |
repository | https://github.com/Stovent/m68000 |
max_upload_size | |
id | 654134 |
size | 903,067 |
m68000 is a Motorola 68000 interpreter, disassembler and assembler (code emitter) written in Rust.
This library emulates the common user and supervisor instructions of the M68k ISA. It is configurable to behave like the given CPU type (see below), changing the instruction's execution times and exception handling.
This library has been designed to be used in two different contexts:
The CPU type is specified with a generic parameter on the main structure. The trait CpuDetails
contains all the details of the emulated CPU:
m68000 provides CPU details for the following CPUs:
m68000 requires a nightly compiler as it uses the btree_extract_if
and bigint_helper_methods
features of the std.
First, since the memory map is application-dependant, it is the user's responsibility to define it by implementing the MemoryAccess
trait on their memory structure, and passing it to the core on each instruction execution.
Second, choose the CPU behavior by specifying the instance that implements the CpuDetails
trait, whether it is your own or one of the provided ones in the crate.
The file src/bin/scc68070.rs
is a usage example that implements the SCC68070 microcontroller.
const MEM_SIZE: u32 = 65536;
struct Memory([u8; MEM_SIZE as usize]); // Define your memory management system.
impl MemoryAccess for Memory { // Implement the MemoryAccess trait.
fn get_byte(&mut self, addr: u32) -> Option<u8> {
if addr < MEM_SIZE {
Some(self.0[addr as usize])
} else {
None
}
}
// And so on...
}
fn main() {
let mut memory = Memory([0; MEM_SIZE as usize]);
// Load the program in memory here.
let mut cpu: M68000<m68000::cpu_details::Mc68000> = M68000::new();
// Execute instructions
cpu.interpreter(&mut memory);
}
See CINTERFACE.md.
m68000 is distributed under the terms of the Mozilla Public License version 2.0. Refer to the LICENSE file for more information.