EASy68K  
It is currently Sat Apr 04, 2020 9:46 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Dec 10, 2012 10:33 am 
Offline

Joined: Mon Dec 10, 2012 2:50 am
Posts: 1
I'm trying to display [3 * 6 + 9 = 27],

Code:
   ORG   $1000
START:   move   #3,d0
   move   #3,d1
   trap   #15
   move   #14,d0
   lea   textD1,a1
   trap   #15
textD1   dc   ' * '
   move   #6,d1
   move   #3,d0
   trap   #15
   move   #14,d0
   lea   textD2,a1
   trap   #15
textD2   dc   ' + '
   move   #9,d1
   move   #3,d0
   trap   #15
   move   #14,d0
   lea   textD3,a1
   trap   #15
textD3   dc   ' = '
   move   #27,d1
   move   #3,d0
   trap   #15
   END   START


but I found it can't display 27 after displaying =,
and it told me that illegal instruction found.

So, I use task number 17 instead of 14 in the last text,
Code:
   ORG   $1000
START:   move   #3,d0
   move   #3,d1
   trap   #15
   move   #14,d0
   lea   textD1,a1
   trap   #15
textD1   dc   ' * '
   move   #6,d1
   move   #3,d0
   trap   #15
   move   #14,d0
   lea   textD2,a1
   trap   #15
textD2   dc   ' + '
   move   #9,d1
   move   #3,d0
   trap   #15
   move   #17,d0
   lea   textD3,a1
   move   #27,d1
   trap   #15
textD3   dc   ' = '   
   END   START


I can successfully display [3 * 6 + 9 = 27] but it still shows illegal instruction found. What happened??


Top
 Profile  
 
PostPosted: Mon Dec 10, 2012 1:24 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Quote:
I can successfully display [3 * 6 + 9 = 27] but it still shows illegal instruction found. What happened??
After the TRAP #15 call there is nothing to tell the simulator to jump over the
Code:
textD1   dc   ' * '
so, just like a real CPU would do, the simulator tries to execute it.

Sometimes you will get away with this as the data will be equivalent to harmless, from your porgram's point of view, instructions. Other times it will cause catastrophic errors.

What you want to do is arrange your source so that the code and data aren't mixed, something like this ..

Code:
* equates for values go here

CR    EQU   $0D                           * [CR] character
LF    EQU   $0A                           * [LF] character

* now set the start address of your code

      ORG         $1000

* now all the code

start
      LEA         string(pc),a1           * point to the string
      MOVEQ       #13,d0                  * display a string with [CR][LF]
      TRAP        #15

      MOVEQ       #9,d0                   * halt the simulator
      TRAP        #15

* now the data

string
      dc.b  '$'
      dc.b  CR,LF
      dc.b  $09,'Test line 1'
      dc.b  CR,LF
      dc.b  0

      END         start

Lee.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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