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

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: ADD not work!
PostPosted: Fri Aug 09, 2013 11:25 am 
Offline

Joined: Fri Aug 09, 2013 11:21 am
Posts: 2
Hi, i'm new to 68000 programming. I wrote this code

Code:
CODE EQU 0
DATA EQU 1

   SECTION DATA
   ORG $1000
MULTIPLO DS.L 1
NUMERO DS.L 1
SOGLIA DS.L 1
   
   SECTION CODE
   ORG $1100
START:
   MOVE.L #0,D0
   MOVE.L D0,MULTIPLO
   MOVE.L #3,D1
   MOVE.L D1,NUMERO
   MOVE.L #7,D2
   MOVE.L D2,SOGLIA
DO:
   ADD D1,DO
   MOVE.L D0,MULTIPLO
   CMP.L D2,D0
   BLT DO
PR_END:
   MOVE.L #9,D0
   TRAP #15
   END START


When i simulate it, the add after the "do" label does not work, that means, the D0 register still contains its value (0) instead of the correct one (3), in other words, the D0 register is not updated. Why?


Top
 Profile  
 
 Post subject: Re: ADD not work!
PostPosted: Fri Aug 09, 2013 2:56 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Code:
DO:
   ADD D1,DO

You have a letter 'O' instead of a number '0' in ADD D1,D0.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: ADD not work!
PostPosted: Sat Aug 10, 2013 9:04 am 
Offline

Joined: Fri Aug 09, 2013 11:21 am
Posts: 2
thanks. isn't the compiler supposed to issue a warning?


Top
 Profile  
 
 Post subject: Re: ADD not work!
PostPosted: Sat Aug 10, 2013 4:08 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
It is not an illegal instruction. The code is adding the contents of D1 to memory location DO.

I like using a font that puts a slash through zero to prevent confusing them with the letter 'o'.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: ADD not work!
PostPosted: Thu Sep 05, 2013 3:02 pm 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
profkelly wrote:
It is not an illegal instruction. The code is adding the contents of D1 to memory location DO.


... which just happens to be the opcode at the label "DO" ... which, when I try, crashes the program on the next iteration with an illegal instruction error. Didn't this happen to the original poster?


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

All times are UTC


Who is online

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