Shop OBEX P1 Docs P2 Docs Learn Events
Put in SX/B 2.0 — Parallax Forums

Put in SX/B 2.0

UghaUgha Posts: 543
edited 2009-02-24 11:18 in General Discussion
So far I absolutely love 2.0. I just have a minor problem I can't be sure of.

I understand that this works:

temp1 var byte
temp2 var byte
temp3 var byte
array var byte(3)

temp1 = 5
temp2 = 10
temp3 = 15

put array, temp1 to temp3

But I had expected put to also work in copying arrays.

Example:
array1 var byte(10)
array2 var byte(5)
i var byte

for i = 0 to 9
array1(i) = i
next

put array2, array1(0) TO array1(4)

But it doesn't work for me... it just overwrites the first byte of array2 with $00

I think I understand that using an array's label is the same as using the first element of the array (array2 = array2(0)) in this case,
but how would I go about doing the above?

I can do a work-around with two counters and a for loop, but I love put so much that I'd like to use that if its possible.

Sorry if this is answered elsewhere or has a simple answer... I·just don't get it.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-02-24 02:01
    This is the generated code

       732  010A  0CDA        MOV FSR,#array2                ;put array2, array1(0) TO array1(4)
            010B  0024
       733  010C  0204        MOV __PARAM1,FSR              
            010D  0028
       734  010E  0CD0        MOV FSR,#array1+0             
            010F  0024
       735  0110  0204        SUB __PARAM1,FSR              
            0111  00A8
       736  0112  0C05        MOV __PARAM2,#(array1+4 - array1+0)+1
            0113  0029
       737  0114  0200        MOV __PARAM3,IND              
            0115  002A
       738  0116  0208        ADD FSR,__PARAM1              
            0117  01E4
       739  0118  020A        MOV IND,__PARAM3              
            0119  0020
       740  011A  00C8        MOV W,--__PARAM1              
       741  011B  00A4        SUB FSR,W                     
       742  011C  02E9        DJNZ __PARAM2,@$-8            
            011D  0010 0B14
       743  011F  0018        BANK $00          
    

    Looks to me it should work.

    regards peter
  • UghaUgha Posts: 543
    edited 2009-02-24 11:18
    Strange... it must be something else in my code. I thought I had eliminated everything else and when I ended up using put array1, array2 it worked fine.

    I apologize for wasting your time.
Sign In or Register to comment.