Skip to content

CPUEmulator ignores non-conventional commands #19

@Shevvv

Description

@Shevvv

The ALU described in the book has a lot of redundant commands. The 0 alone can be coded in 6 different ways:

001000 = x & 0 = 0
100000 = 0 & y = 0
101000 = 0 & 0 = 0
101010 = 0 + 0 = 0
111000 = !0 & 0 = 0
101100 = 0 & !0 = 0

Similarly, x can be computed as:

001100 = x & !0 = x
001010 = x + 0 = x
011011 = !(!x + 0) = !!x = x

There are other operations as well that can be expressed in multiple ways. However, only one of these for each operation is properly interpreted by CPUEmulator when loading from .hack file. I'm assuming it's consulting a dictionary. It would be nice and a lot of fun, though, to be able to assemble your own .hack file manually and without consulting the table from the book since the choice of conventional commands in it for each of the listed 18 operations is arbitrary, and all of the other alternative commands should also produce viable results on the ALU we built in chapter 3 and I'm really curious to see if I really am allowed to choose any option I would like.

EDIT: It's fine if the unconventional commands are not disassembled back to mnemonics by the CPUEmulator on the left, as long as the ALU performs the expected operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions