It is currently Sat Apr 04, 2020 9:17 am

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Posted: Sat Mar 22, 2014 4:08 am

Joined: Sat Mar 15, 2014 2:56 pm
Posts: 4
ok I'm new to assembly programming and using the 68k I'm still getting the hang of this I had to create a program to sort the numbers so lets say ive sorted it already i just need to know if there is an easier way to move the contents of A0 to A1

I have an array
Code:
ARRAY DC.B  10,9,8,7,6,5,4,3,2,1    ;array sorted already

ARRAYSORTED  DS.B 10          ;memory reserved for the sorted array to be placed in

LEA ARRAY,A0                              ;lets say ARRAY starts at location 1000 so A0 is now 1000
LEA ARRAYSORTED,A1                   ;ARROYSORTEd starts at location 1040

;ok so I read somewhere where you cant just move from address to address so this is how i did it        by moving the contents of A0 to a data register then transfer whatever is in that data register to the corresponding location of A1 so the first item in the array of A0 is moved to data register then that value is then transfered to first location spot of the array in A1

MOVE.B (A0)+,D0
MOVE.B D0,(A1)+
MOVE.B (A0)+,D1
MOVE.B D1,(A1)+
MOVE.B (A0)+,D2
MOVE.B D2,(A1)+
MOVE.B (A0)+,D3
MOVE.B D3,(A1)+
MOVE.B (A0)+,D4
MOVE.B D4,(A1)+
MOVE.B (A0)+,D5
MOVE.B D5,(A1)+
MOVE.B (A0)+,D6
MOVE.B D6,(A1)+
MOVE.B (A0)+,D7
MOVE.B D7,(A1)+
MOVE.B (A0)+,D0
MOVE.B D0,(A1)+
MOVE.B (A0)+,D1
MOVE.B D1,(A1)+

LEA     ARRAYSORTED,A1              ;checking here to make sure it moved items correctly and it did but i feel this is inefficient is there an easier way?

MOVE.B (A1)+,D0
MOVE.B (A1)+,D1
MOVE.B (A1)+,D2
MOVE.B (A1)+,D3
MOVE.B (A1)+,D4
MOVE.B (A1)+,D5
MOVE.B (A1)+,D6
MOVE.B (A1)+,D7
MOVE.B (A1)+,D0
MOVE.B (A1)+,D1

is there an easier way like how do i get ARRAYSORTED to point at where ARRAY is pointing to so they are both pointing to \$1000

I tried

Code:
LEA ARRAYSORTED,A0

but I just looked at it and it just moves A0 to where ARRAYSORTED is located
sorry if I might not have explained clearly I'm a total noob at this

Top

 Posted: Sun Mar 23, 2014 6:53 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Something like this:
Code:
*-----------------------------------------------------------
* Title      : Move array1 to array2
* Written by : Charles Kelly
* Date       : March 23rd, 2014
* Description: Copy array1 to array2.
*-----------------------------------------------------------
ORG    \$1000
START:                  ; first instruction of program

* Put program code here
LEA     array1,A0
LEA     array2,A1
MOVE.L  #SIZE-1,D0    ; loop counter
loop:
MOVE.B  (A0)+,(A1)+
DBRA    D0,loop
SIMHALT             ; halt simulator

* Put variables and constants here
SIZE    EQU     15
array1  DS.B    SIZE
array2  DS.B    SIZE

END    START        ; last line of source

_________________
Prof. Kelly

Top

 Posted: Wed Mar 26, 2014 12:44 am

Joined: Sat Mar 15, 2014 2:56 pm
Posts: 4
thank you so much i forgot about using loops

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 5 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects