Ben Shaines
Ben Shaines

Reputation: 11

Assembly MSP430, Error: a Word access on odd address - How to fix it?

In the code below, there are 2 loops, which I have to run 8 times.
The first time, I run it pretty well, numbers as it should be, very happy.
The second time when it reaches the second LOOP_1 ( AFter first loop, it goes to RESET2 and then returns there ).
I get the error I wrote above.

#include <msp430.h>     ; define controlled include file

               ORG 1100h
ID_F           DW      3,8,9,1,8,4,9,0
ID_S           DW      5,9,2,3,9,3,9,1
Ones_Amount1   DS16    8
Ones_Amount2   DS16    8


               RSEG   CODE                        ; ORG   0x3100 - place program in 'CODE' segment in to Flash memory
               
Main           CLR R5                    ; Index
               MOV #8, R6                ; Decreasing Counter
               MOV #Ones_Amount1, R11    
               SUB #2, R11
               MOV #Ones_Amount2, R12    
               SUB #2, R12
               
LOOP_1         MOV ID_F(R5), R8
               CLR R15
               MOV #1, R10               ; Counter for loop number 2
               
NUM_LOOP       RRA R8                    ; Divide by two
               JC ADD_ONE                ; Increase counter
               JZ RST_CHOOSE                  ; Reset
               JMP NUM_LOOP              ; Not Zero, Not Carry - Return to loop
               
LOOP_2         MOV ID_S(R5), R8              ; Loop for second arr
               CLR R15
               JMP NUM_LOOP
               
ADD_ONE        INC R15
               JMP NUM_LOOP
               
RST_CHOOSE     RRA R10
               JC RESET1
               JMP RESET2
               
RESET1         MOV R15, 2(R11)
               ADD #2, R11
               JMP LOOP_2

RESET2         MOV R15, 2(R12)
               ADD #2, R12
               DEC R6
               JZ Finish
               INCD R5
               JMP LOOP_1
               

Finish          NOP
               
           
           
             
             
             
             
L              JMP   L                            ; infinite loop
               NOP                                ; to remove warnings
;-------------------------------------------------------------------------------
               COMMON  INTVEC                  ; Interrupt Vectors
;-------------------------------------------------------------------------------
               ORG     RESET_VECTOR            ; POR, ext. Reset
               DW      Main
               END

While when I check on my registers, I see:
R5 is 2 R6 is 7 R8 is 0 R11 is 1120 R12 is 1130
Which is as it should be,
The problematic code: LOOP_1 MOV ID_F(R5), R8 ( again, at the second time )
After this when I try to debug, suddenly all the registers go crazy and they change numbers for some reason. How do I fix this and why is this happening?

EDIT: Just to make you clear about my problem, I know I should not use odd addresses ( Its the basic of basics ). I am using only Even ( as you can see in my code, R5 is 0x0002 now )

EDIT: Managed to solve the problem, appearntly, the problem is in my computer. I copied the code to my friend, to him it works, I changed it a bit, but on my computer it wont, on my friend it works perfect, was stuck 4 hours for nothing... Thanks guys!

Upvotes: 0

Views: 101

Answers (0)

Related Questions