Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

Please help with MSP430 program.

  Asked By: Mike    Date: Oct 23    Category: Assembly Language    Views: 833

I am working on a program for msp430, i have two arrays and i have to sort them in an ascending order using bubble sort and i am using code composer for this, if anyone can help that would be great.

First problem is that it won't get out of the loop and second is that it swaps the values in the register if needed but i don't know how to swap the values at the address.

Here is what i have so far...

Array1 .set 0x0200
Array1s .set 0x0206

Array2 .set 0x0212
Array2s .set 0x021C

RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer


clr R4
clr R5
clr R6

call #ArraySetup

Sort1 mov.w #Array1, R4
mov.b @R4+, R5
mov.w #Array1s, R6
call #Sort

Sort2 mov.w #Array2, R4
mov.b @R4+, R5
mov.w #Array2s, R6
call #Sort

MainLoop jmp MainLoop

Sort ;clr R7-r15
clr R7
clr R8
clr R9
clr R10
clr R11
clr R12
clr R13
clr R14
clr R14
clr R15

Start clr r10
mov.b R5, R11 ;counter
dec R11

Loop mov.b @R4+, R7
mov.b @R4, R8
cmp.b R7,R8
jz No_Swap
jge No_Swap

Swap mov.b R7, R9
mov.b R8, R7
mov.b R9, R8
inc R10
;;;;;;;;;;;;;;;;;;;mov.b r8, 0(r4)
;mov.b r7, -1(r4)

No_Swap dec R11
tst R11
jnz Loop
cmp.w #0, R10 ; swap counter
jnz Start


ArraySetup mov.b #5, &0x0200
mov.b #10,&0x0201
mov.b #9, &0x0202
mov.b #8, &0x0203
mov.b #7, &0x0204
mov.b #6, &0x0205




No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Please help with MSP430 program. Or get search suggestion and latest updates.