Learning MSP430 Launchpad assembly language in class. The current assignment is to do stepwise multiplication and division (i.e. simulating them with recursive addition and subtraction).
I went over how to declare variables in assembly language with the professor, but the attempt threw errors when I tried to compile.
; Initialization Operations
Init:
mov.b m, R4 ;store m in R4
mov.b M, R5 ;store M in R5
mov.w #0, R6 ;store 0 in R6
for:
add.w R4, R6 ;add contents of R4 to P
dec.w R5 ;decrement R5
jnz for ;jump to R4 until R5 is zero
exitFor:
mov.w R6, P ;store R6 in P
jmp exitFor ;infinite loop
nop ; end program
; Variables for multiplication
.data
m: .byte #40 ; multiplicand
M: .byte #5 ; multiplier
P: .short ; product
The errors are all below the .data directive. The m and M lines threw [E0200] Bad term in expression and [E0000] Commas must separate directive elements, and the P line threw [E0005] Operand missing. I'm having similar problems with the division version of the program.
From comment by Fuz:
Well, that did it.
Also I didn't originally initialize P because the lab instructions said to define but not initialize it. I didn't understand I needed to use
.spaceor.bssto handle that, so strictly speaking the "correct" solution should be: