EASy68K  
It is currently Thu Nov 14, 2019 2:59 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Aug 16, 2010 5:05 pm 
Offline

Joined: Mon Aug 16, 2010 4:53 pm
Posts: 2
Code:
ORG   $400
N   EQU   5   TOTAL 5 NUMBERS
   CLR.B   D4      set D0 as largest
   MOVE.W   #N-1,D1      USE D1 AS COUNTER AND PRESET IT TO N-1
   LEA   list,A0      USE A0 as a pointer to the list
next   MOVE.B   (A0)+,D2   read a number
   CMP.B   D4,D2      is new number >largest?
   BPL   last      if it isn't go and check for end of loop
   MOVE.B   D2,D4      It is, record the largset no
Last   DBRA   D1,next      repeat until counter 0
   move.w   #9,d0
   trap   #15
   STOP    #$2700
   ORG   $1000
List   DC.B   1,2,8,5,3
   END   $400


above is the program to find the the largest no. but i don't know how to check the result on memory. Please help to locate the result on memory.

or is there any other instruction i need to add.

thank you


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2010 10:02 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1103
The program is correct except for the BPL last instruction, it should be BLE last. I always tell my students to read the CMP instruction backwards in order for the branch instruction to read correctly. In this case we are comparing D2 to D4 and branching when it is less than or equal.

BTW, Good comments.

When the program completes the largest value is contained in register D4 which is visible in Sim68K.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2010 2:44 am 
Offline

Joined: Mon Aug 16, 2010 4:53 pm
Posts: 2
Thank you sir. it helped me a lot.


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: 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:  
cron
Powered by phpBB® Forum Software © phpBB Group