EASy68K  
It is currently Tue Nov 21, 2017 9:24 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon May 12, 2014 2:39 pm 
Offline

Joined: Sun Apr 20, 2014 3:20 pm
Posts: 4
The program is to read numbers from the I/O window, store them in memory, then calculate the sum and the average of the numbers read. My program runs fine except for the fact that the message for displaying sum does not appear. Please check it for me. Thanks
Code:
   ORG    $1000
START:                  ; first instruction of program

* Put program code here       
       
LOOP   
        ADD.B   #1,D2
        LEA     MSG1,A1
        MOVE.B  #14,D0
        TRAP    #15
       
        MOVE.B  #4,D0
        TRAP    #15
       
        ADD.B   D1,D3
       
        CMP.B   #0,D1         
        BNE     LOOP
       
        SUB.B   #1,D2
               
        LEA     MSG2,A1
        MOVE    D3,D1
        MOVE.B  #17,D0
        TRAP    #15

        DIVU    D2,D1
       
        LEA     MSG3,A1
        MOVE.B  #17,D0
        TRAP    #15       

        MOVE.B  #9,D0             ; halt simulator
        TRAP    #15

* Put variables and constants here
CR      EQU     $0D
LF      EQU     $0F
MSG1    DC.B    'Enter the number, enter 0 to exist: ',0
MSG2    DC.B    'The sum is: ',0
MSG3    DC.B    CR,LF,'The average is: ',0

    END    START        ; last line of source


Top
 Profile  
 
PostPosted: Mon May 12, 2014 8:47 pm 
Offline

Joined: Wed May 07, 2014 11:16 pm
Posts: 5
Perhaps move.l would be more appropriate?
Should the string MSG2 have CL,RF in order to start on a new line?

Does it display anything, either the string or the average?


Top
 Profile  
 
PostPosted: Tue May 13, 2014 1:29 pm 
Offline

Joined: Sun Apr 20, 2014 3:20 pm
Posts: 4
Only MSG2 does not appear nor the sum is.


Top
 Profile  
 
PostPosted: Tue May 13, 2014 2:01 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1049
The ASCII code for LF should be $0A.

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Wed May 14, 2014 3:40 am 
Offline

Joined: Sun Apr 20, 2014 3:20 pm
Posts: 4
Thank you very much. The problem is solved :D


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 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