From 159fd422fcabc402626bfcc826d80ef8f23dbddf Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Wed, 19 Oct 2022 12:53:55 -0700 Subject: [PATCH] store w instruction --- .../src/main/scala/com/htmlism/scratchpad/Load.scala | 9 +++++++++ .../src/main/scala/com/htmlism/scratchpad/Register.scala | 6 +++--- .../src/main/scala/com/htmlism/scratchpad/Store.scala | 2 +- .../scala/com/htmlism/scratchpad/syntax/package.scala | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala index 11205fb..99578da 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/Load.scala @@ -47,5 +47,14 @@ case class R[A]() // TODO needs evidence that it is a storable target of one thing case class StoreTo[A: Store, B]() extends Asm2[A, B]: + // TODO def xs: List[String] = Nil + +case class LoadImmediate[R: Load, A: ImmediateValue]() extends Asm1[R]: + // TODO + def xs: List[String] = + Nil + +trait ImmediateValue[A]: + def toByte(x: A): Int diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/Register.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/Register.scala index 495dfba..a12e9af 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/Register.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/Register.scala @@ -19,7 +19,7 @@ object Register: "LDA" given storeA: Store[A] with - def to: String = + def instruction: String = "STA" class A @@ -30,7 +30,7 @@ object Register: "LDX" given storeX: Store[X] with - def to: String = + def instruction: String = "STX" class X @@ -41,7 +41,7 @@ object Register: "LDY" given storeY: Store[Y] with - def to: String = + def instruction: String = "STY" class Y diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/Store.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/Store.scala index 31474cd..435c169 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/Store.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/Store.scala @@ -1,7 +1,7 @@ package com.htmlism.scratchpad trait Store[A]: - def to: String + def instruction: String object Store: def apply[A: Store]: Store[A] = diff --git a/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala b/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala index e7c03eb..d77bbf7 100644 --- a/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala +++ b/scratchpad/src/main/scala/com/htmlism/scratchpad/syntax/package.scala @@ -20,7 +20,7 @@ package object syntax: Load[R].instruction // TODO load action needs to interact with encoder val storeInstruction = - Store[R].to // TODO store action needs to interact with encoder + Store[R].instruction // TODO store action needs to interact with encoder val first = s"$loadInstruction $literal"