Last active
August 29, 2015 14:16
-
-
Save osvein/c27a98aa5b480aa4b9db to your computer and use it in GitHub Desktop.
Basic arithmetic operators for Hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (MULTIPLY) | |
| (MULTIPLY.LOOP) | |
| // return if j is greater than or equals to 16 | |
| @j | |
| D=M | |
| @16 | |
| D=D-A | |
| @R0 | |
| D;JGE | |
| // add R1 to R15 if the j-th bit of R2 is 1 | |
| D=1 | |
| (MULTIPLY.SKIP) | |
| @R1 | |
| D=M | |
| @R15 | |
| M=M+D | |
| // increment j | |
| @j | |
| M=M+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment