@@ 639,4 639,51 @@ mod tests {
if counter > 30 {panic!()};
}
}
+ #[test]
+ fn mem_stack() {
+ let mut memory = [0x06F0, 17, 0x0600, 5, 0x0580, 0x0000, 0x0600, 3, 0x0580, 0x0000, 0x0500, 0x0800, 0x0500, 0x1000, 0, 0, 0, 0];
+ let mut disk = [0];
+ let mut vram = [0];
+ let mut processor = new(&mut memory, &mut disk, &mut vram);
+ loop {
+ if processor.run() {break};
+ }
+ assert_eq!(processor.reg[1], 3);
+ assert_eq!(processor.reg[2], 5);
+ }
+ #[test]
+ fn mem_main() {
+ let mut memory = [0x0600, 5, 0x0608, 10, 0x0590, 0x0040, 0x0510, 0x1040, 0, 0, 0];
+ let mut disk = [0];
+ let mut vram = [0];
+ let mut processor = new(&mut memory, &mut disk, &mut vram);
+ loop {
+ if processor.run() {break};
+ }
+ assert_eq!(processor.reg[2], 5);
+ }
+ #[test]
+ fn mem_disk() {
+ let mut memory = [0x0600, 5, 0x0608, 3, 0x06E8, 1, 0x05A0, 0x0040, 0x0520, 0x1040, 0x06E8, 0, 0x0520, 0x1840, 0, 0];
+ let mut disk = [0;66000];
+ let mut vram = [0];
+ let mut processor = new(&mut memory, &mut disk, &mut vram);
+ loop {
+ if processor.run() {break};
+ }
+ assert_eq!(processor.reg[2], 5);
+ assert_eq!(processor.reg[3], 0);
+ }
+ #[test]
+ fn mem_vram() {
+ let mut memory = [0x0600, 5, 0x0608, 10, 0x05B0, 0x0040, 0x0530, 0x1040, 0, 0, 0];
+ let mut disk = [0];
+ let mut vram = [0;30];
+ let mut processor = new(&mut memory, &mut disk, &mut vram);
+ loop {
+ if processor.run() {break};
+ }
+ assert_eq!(processor.reg[2], 5);
+
+ }
}