Skip to content

Instantly share code, notes, and snippets.

@osvein
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save osvein/c27a98aa5b480aa4b9db to your computer and use it in GitHub Desktop.

Select an option

Save osvein/c27a98aa5b480aa4b9db to your computer and use it in GitHub Desktop.
Basic arithmetic operators for Hack
(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