EASy68K  
It is currently Fri Jun 05, 2020 7:21 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: arrays
PostPosted: Tue Apr 05, 2011 1:37 am 
Offline

Joined: Sat Mar 12, 2011 2:53 am
Posts: 9
i need help with array,are there tutorial ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 2:01 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
Check out this topic:
http://www.easy68k.com/EASy68Kforum/viewtopic.php?t=633&highlight=array

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 11:42 am 
Offline

Joined: Sat Mar 12, 2011 2:53 am
Posts: 9
based on the link you sent i see that he was trying to do the same for strings but i did not see a follow up code is it the same concept?what was he doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 12:33 pm 
Offline

Joined: Sat Mar 12, 2011 2:53 am
Posts: 9
i attempted the problem but the last string is being printed 10times what am i doing wrong?
Code:
 ORG $1000
SIZE    equ     4   ; data size (4 bytes for long word)

START:              ; first instruction of program

    * read 10 numbers from keyboard and store in array
       lea array1,A0           ; pointer to array
   
    for D2 = #0 to #9*SIZE by #SIZE do.s  ; loop 10 times
        lea     prompt,A1   ; pointer to string
        move.b  #13,D0      ; display prompt
        trap    #15
       
        lea   buffer,A1
        move.b  #2,D0       ; read strings from keyboard into A1
        trap    #15
               
        move.l  A1,(A0,D2)  ; store strings to array at index D2
    endf
   
    lea     result,A1       ; pointer to string
    move.b  #13,D0          ; display result
    trap    #15
   
    * display numbers from array
    for D2 = #0 to #9*SIZE by #SIZE do.s  ; loop 10 times
        move.l  (A0,D2),A1  ; get string from array at index D0
        move.b  #14,D0       ; display string in A1
        trap    #15
       
        lea     crlf,A1     ; pointer to string
        move.b  #14,D0      ; display cr lf
        trap    #15
    endf
       
    MOVE.B  #9,D0
    TRAP    #15     ; halt simulator

* Variables and Strings
array1  ds.l    10  ; 10 long word array
buffer  ds.b    80*9
prompt  dc.b    'Enter a string: ',0    ; null terminated string
result  dc.b    'Your strings are: ',0  ; null terminated string
crlf    dc.b    $d,$a,0                 ; carriage return, line feed, null

    END START       ; last line of source


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2011 1:14 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
alyshaz103 wrote:
i attempted the problem but the last string is being printed 10times what am i doing wrong?

Well you only have one buffer, each new input overwrites the previous one, you'll need to store each in a unique buffer if you want to remember them all.


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