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

arrays
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=988
Page 1 of 1

Author:  alyshaz103 [ Tue Apr 05, 2011 1:37 am ]
Post subject:  arrays

i need help with array,are there tutorial ?

Author:  profkelly [ Tue Apr 05, 2011 2:01 am ]
Post subject: 

Check out this topic:
http://www.easy68k.com/EASy68Kforum/viewtopic.php?t=633&highlight=array

Author:  alyshaz103 [ Tue Apr 05, 2011 11:42 am ]
Post subject: 

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?

Author:  alyshaz103 [ Tue Apr 05, 2011 12:33 pm ]
Post subject: 

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

Author:  clive [ Tue Apr 05, 2011 1:14 pm ]
Post subject: 

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.

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