EASy68K  
It is currently Wed Oct 17, 2018 1:47 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Storing integers
PostPosted: Tue May 24, 2011 11:10 am 
Offline

Joined: Sat Apr 30, 2011 9:47 am
Posts: 3
Alright.. so I have to get a list of sequences from user (seperated by spaces), then store them as decimal number at address $2000 (1byte per number. Then get the position of the smallest number.

eg. If 45 6 544 was entered

45 would be stored as '45' at $2000 - $2003
6 would be stored as '6' at $2004-$2007
544 would be stored as '544' at $2008-$2011

then print : " Position of smallest element is 2 "

I've only been able to store the characters as ASCII.. :|

Code:

START:   move.l   #$7ffe,sp   
           move.l   #$2000,a3       ;Pointer to first location in memory.
           move.b   0,d1      ;turn off automatic echo
           move.b   #12,d0
           trap   #15
   
          movea.l   #message,a1   ;print prompt
          move.b   #1,d0

next          move.b    #5,d0      ;INCH
          trap          #15   

               cmp.b          #space,d1
          beq          next
   
          cmp.b    #cr,d1
          beq           print
          move.b     d1,(a3)+   ;store char
          bra            next

print          movea.l   #lowestint,a1
          move.b   #1,d0
          move.l   #(100-lowestint),d1
          trap   #15

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

message   dc.b          'Enter sequence: '
lowestint   dc.b          cr,'The position of the smallest element is '

space   equ          $20


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2011 11:10 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Perhaps "Trap#15,Task#4 Read Number in D1.L" would be more effective than reading characters


Top
 Profile  
 
 Post subject: hi
PostPosted: Thu May 26, 2011 1:43 pm 
Offline

Joined: Thu May 26, 2011 9:00 am
Posts: 10
hi guys
are u doing ass3 of co?? and if u do ... how is going so far


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2011 5:01 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Task #4 will only return the first number from a space separated list.


Top
 Profile  
 
 Post subject: Re: hi
PostPosted: Sun May 29, 2011 12:48 am 
Offline

Joined: Sat Apr 30, 2011 9:47 am
Posts: 3
wangyimang wrote:
hi guys
are u doing ass3 of co?? and if u do ... how is going so far


lol yeah. I'm pretty much done. Just got to do R4 and im done.
figured everything out before the forum could reply though.. as usual :>


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