EASy68K  
It is currently Tue Dec 11, 2018 11:30 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Apr 17, 2011 2:11 pm 
Offline

Joined: Sun Apr 17, 2011 10:16 am
Posts: 4
Location: Madrid - Spain
Hello, first of all, sorry if this topic is repeated or very simple, I am new and I haven't find any related topic in the whole forum.

I programmed next code to invert a vector in memory. It works properly except in end of the program:
After first NOP (returning of INVERT subroutine) I get next error: "Line 1111 Emulator exception occurred at location 201e. Execution halted".

I tried in several places with STOP #$2000
or also with:
MOVE.B #9,D0
TRAP #15
but it doesn't works.

Also I tried several values of ORG in START and INVERT with the same wrong result.

Image

I would appreciate quick advise because I have to send the project to university in two days.

I attached the code as picture because I don't know how to use TAB in the text, sorry.

Thank you very much.

_________________
Microcontrollers


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 17, 2011 9:25 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Define your origin BEFORE defining labels.

Code:
        ORG     $2000

start   move.l  #$0A0B0C0D,$3000
        move.l  #$0E1A1B1C,$3004

        move.l  #$3000,a0
        move.l  #5,d0
        bsr     invert

        move.b  #9,d0
        trap    #15

invert  move.l  a0,a1
        move.l  a0,a2
        add.l   d0,a2
        subq.l  #1,a2
loop    cmp.l   a1,a2
        blt     loop_end
        move.b  (a1),d1
        move.b  (a2),(a1)
        move.b  d1,(a2)
        subq.l  #1,a2
        addq.l   #1,a1
        bra     loop
loop_end
        rts

        nop

        END   start


Or somewhat more slickly with some readily apparent optimizations.
Code:
        ORG     $2000

start   move.l  #$0A0B0C0D,$3000
        move.l  #$0E1A1B1C,$3004

        move.l  #$3000,a0
        move.l  #5,d0
        bsr     invert

        move.b  #9,d0
        trap    #15

invert  move.l  a0,a1
        lea     -1(a0,d0.w),a2
loop    cmp.l   a1,a2
        ble     loop_end
        move.b  (a1),d1
        move.b  (a2),(a1)+
        move.b  d1,(a2)
        subq.l  #1,a2
        bra     loop
loop_end
        rts

        nop

        END   start


or
Code:
        ORG     $2000

start   move.l  #$0A0B0C0D,$3000
        move.l  #$0E1A1B1C,$3004

        move.l  #$3000,a0
        move.l  #5,d0
        bsr     invert

        move.b  #9,d0
        trap    #15

invert  move.l  a0,a1
        lea     -1(a0,d0.w),a2
        cmp.l   a1,a2
        ble     loop_end
loop    move.b  (a1),d1
        move.b  (a2),(a1)+
        move.b  d1,(a2)
        subq.l  #1,a2
        cmp.l   a1,a2
        bgt     loop
loop_end
        rts

        END   start


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 19, 2011 1:38 pm 
Offline

Joined: Sun Apr 17, 2011 10:16 am
Posts: 4
Location: Madrid - Spain
Thank you very much.

I've just read this, but I've already sent the work. Maybe it is not slickly like yours, but it is working. Finally I fixed the error by writing MOVE.B #9,D0 TRAP #15 in the correct place.

Thank you again and best regards.

_________________
Microcontrollers


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: Majestic-12 [Bot] and 3 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:  
cron
Powered by phpBB® Forum Software © phpBB Group