<div dir="ltr"><div style>Hi Cafe,</div>I am trying to embed x86 assembly in Haskell. I&#39;d like the EDSL to not allow invalid movements into registers - for example, should not allow moving into RIP. I was not able to get it to work. I ended up using DataTypeContexts - which is considered misfeature anyway. I was wondering if I could get some suggestions.<div>
<br></div><div><div>{-# LANGUAGE DatatypeContexts #-}</div><div><br></div><div>data SREG = RIP</div><div>data DREG = RBX</div><div>data SNDREG = RAX</div><div><br></div><div><br></div><div>data (Source s, Destination d) =&gt; Instruction s d = MOV s d </div>
<div><br></div><div><br></div><div>class Source a</div><div>class Destination a</div><div><br></div><div>instance Source SREG</div><div>instance Source SNDREG</div><div><br></div><div>instance Destination DREG</div><div>instance Destination SNDREG</div>
<div><br></div><div><br></div><div>move :: (Source s, Destination d) =&gt; s -&gt; d -&gt; Instruction s d</div><div>move s d = MOV s d</div><div><br></div><div>hello = [move RAX RAX, move RAX RAX]</div><div><br></div><div>
hello = [move RAX RAX, move RAX RBX] -- this is still not allowed.</div></div><div><br></div><div style>Regards,</div><div style>Kashyap</div><div><br></div></div>