Crates.io | chip_8_cpu_emulator |
lib.rs | chip_8_cpu_emulator |
version | 0.1.0 |
source | src |
created_at | 2023-02-19 10:28:43.838367 |
updated_at | 2023-02-19 10:28:43.838367 |
description | chip 8 cpu emulator written rust |
homepage | |
repository | |
max_upload_size | |
id | 788751 |
size | 28,774 |
steps:
chip_8_cpu_emulator = "0.0.1"
(or)
chip_8_cpu_emulator = "*"
use chip_8_cpu_emulator::cpu::CPU
let mut cpu = CPU {
registers: [0; 16],
memory: [0; 0x1000],
pc: 0,
sp: 0,
stack: [0; 16],
i_reg: 0,
};
/* initializing the registers */
cpu.registers[0] = 5;
cpu.registers[1] = 10;
cpu.registers[2] = 10;
cpu.registers[3] = 10;
/* store the program in memory */
cpu.memory[0] = 0x81; cpu.memory[1] = 0x18; // left shift reg_x
cpu.memory[2] = 0x80; cpu.memory[3] = 0x08; // left shift reg_x
cpu.memory[4] = 0x00; cpu.memory[5] = 0x00; // end of the program
cpu.run();