EASy68K  
It is currently Sun Apr 05, 2020 10:50 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Mar 22, 2014 4:08 am 
Offline

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
 Profile  
 
PostPosted: Sun Mar 23, 2014 6:53 pm 
Offline
User avatar

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
 Profile  
 
PostPosted: Wed Mar 26, 2014 12:44 am 
Offline

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group