3 ms·
I had to use this recently for an online course. It was super nice: def pushConstant(num: Int): String = s""" |@$num |D=A |$accessTo
by dfinninger 6y ago
I had to use this recently for an online course. It was super nice:
def pushConstant(num: Int): String =
s"""
|@$num
|D=A
|$accessTopOfStack
|M=D
|$incrementStackPointer
|""".stripMargin
accessTopOfStack and incrementStackPointer are other functions that return text. It made composing Assembly a breeze.
- rad_gruchalski 6y agoYup, and it’s super nice for json or yaml strings.