EASy68K
http://www.easy68k.com/EASy68Kforum/

Storing integers
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1023
Page 1 of 1

Author:  angela [ Tue May 24, 2011 11:10 am ]
Post subject:  Storing integers

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

Author:  clive [ Wed May 25, 2011 11:10 pm ]
Post subject: 

Perhaps "Trap#15,Task#4 Read Number in D1.L" would be more effective than reading characters

Author:  wangyimang [ Thu May 26, 2011 1:43 pm ]
Post subject:  hi

hi guys
are u doing ass3 of co?? and if u do ... how is going so far

Author:  lee [ Thu May 26, 2011 5:01 pm ]
Post subject: 

Task #4 will only return the first number from a space separated list.

Author:  angela [ Sun May 29, 2011 12:48 am ]
Post subject:  Re: hi

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/