Skip to content

Instantly share code, notes, and snippets.

@jslvtr
Created December 23, 2013 12:26
Show Gist options
  • Save jslvtr/8096257 to your computer and use it in GitHub Desktop.
Save jslvtr/8096257 to your computer and use it in GitHub Desktop.
This is a thoroughly-commented piece of ASSEMBLY code.
; THIS PROGRAM MULTIPLIES A NUMBER BY 2
; Made by Jose Salvatierra
; For a further explanation go to
START: LDN NUM1 ; Copy variable negated into the accumulator (this is the value we are working with in the processor)
SUB NUM1 ; Subtract from the value in the accumulator the value of NUM1 (this is essentially multiplying by 2)
STO MYSUM ; Store to variable (copy the value we're working with to the variable MYSUM)
LDN MYSUM ; Get the value of the variable multiplied by -1 (negated) into the accumulator
STO MYSUM ; Store to variable (copy the value we're working with to the variable MYSUM)
STP ; Stop the processor (ends the program)
NUM1: VAR 750 ; Declare 32-bit variable with value 750
MYSUM: VAR 0 ; Declare 32-bit variable with value 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment