I am using a TI MPS430G2553 launchpad and Code Composer Studio v6
I am trying to compare to numbers in an array. I am looping throught the array and at each number I compare that number to the next number in the array. If the next number is less than the current number, they switch positions. Otherwise, nothing happens
I am comparing them using this command:
cmp 0(array),1(array)
jl SWITCH
The problem is, some of the numbers in the array are negative and they are being treated as their twos complement, for example, when compare 55 and -9, it does not switch them because it is treating -9 as 246 (when i assign it to a register, and use debug mode, the register contains the number 246)
How do i solve this? everything I look up says the solution is to use the jl
command, but I'm already doing that.
my memory window shows for this array 10 17 55 -9 22 36 -7
37 8 -77 8