It is currently Sat Apr 04, 2020 9:23 am

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Trouble with compute sum and averagePosted: Mon May 12, 2014 2:39 pm

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
LEA     MSG1,A1
MOVE.B  #14,D0
TRAP    #15

MOVE.B  #4,D0
TRAP    #15

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

 Post subject: Re: Trouble with compute sum and averagePosted: Mon May 12, 2014 8:47 pm

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

 Post subject: Re: Trouble with compute sum and averagePosted: Tue May 13, 2014 1:29 pm

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

Top

 Post subject: Re: Trouble with compute sum and averagePosted: Tue May 13, 2014 2:01 pm

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

_________________
Prof. Kelly

Top

 Post subject: Re: Trouble with compute sum and averagePosted: Wed May 14, 2014 3:40 am

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

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects