From deeacd917afe3fd97d90e17ddb823f3ba04d0d10 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Thu, 14 Apr 2022 21:22:05 -0400 Subject: [PATCH] Simplify register access code --- src/run.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/run.rs b/src/run.rs index 892d041..7e2a529 100644 --- a/src/run.rs +++ b/src/run.rs @@ -172,9 +172,7 @@ impl Processor { SixteenBitLoadInstruction::LDEffectiveAddress { dst, offset } => { let current_sp = self .registers - .get_16bit_register(register::SixteenBit::Single( - register::SingleSixteenBit::StackPointer, - )); + .get_single_16bit_register(register::SingleSixteenBit::StackPointer); // TODO: This is gross. I'll clean this up when I do more ALU instructions // because there's bound to be reuse @@ -220,9 +218,7 @@ impl Processor { SixteenBitLoadInstruction::Push { src } => { let current_sp = self .registers - .get_16bit_register(register::SixteenBit::Single( - register::SingleSixteenBit::StackPointer, - )); + .get_single_16bit_register(register::SingleSixteenBit::StackPointer); // we want to pop the LSB first (i.e. we write the MSB first) // https://rgbds.gbdev.io/docs/v0.5.2/gbz80.7#PUSH_r16 @@ -242,9 +238,7 @@ impl Processor { SixteenBitLoadInstruction::Pop { dst } => { let current_sp = self .registers - .get_16bit_register(register::SixteenBit::Single( - register::SingleSixteenBit::StackPointer, - )); + .get_single_16bit_register(register::SingleSixteenBit::StackPointer); let popped_bytes = [ self.memory