Skip to content

Instantly share code, notes, and snippets.

@mjbella
Last active December 16, 2015 11:18
Show Gist options
  • Save mjbella/5426367 to your computer and use it in GitHub Desktop.
Save mjbella/5426367 to your computer and use it in GitHub Desktop.
Decimal Add on the MSP430
NAME toBCD
PUBLIC toBCD
RSEG CODE
toBCD MOV #16, R15 ; Loop Counter
MOV R12, R14 ; Move the input to R14 so we can use R12 for our output
CLR R12 ; Clear our output register
L$1 RLA R14 ; Binary MSB to carry
DADD R12,R12 ; Decimal Acc into R12
DEC R15 ; Count down from 16
JNZ L$1 ; Loop again?
RET ;
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment