In SX Microcontrollers, SX/B Compiler and SX-Key Tool, jdemeyer wrote: I have a few places in code where I move bytes around like this: [code] FOR Index=0 to 6 There(Index)=Here(Index) NEXT [/code] Since I have a few places, I would rather have a subroutine to call such as MoveBytes Here,There, 6 I'm not familiar with a couple things. 1) How might I pass the address of a memory location to a subroutine? 2) Once I am in the subroutine, how might I read one location and place it in another? 3) Did I make this too hard? This was my attempt: [code] temp1=4 ASM MOV __PARAM1,#Here & $FF MOV __PARAM2,#Here >> 8 MOV __PARAM3,#There & $FF MOV __PARAM4,#There >> 8 MOV FSR,#__PARAMCNT MOV IND,#4 MOV FSR,#$10 CALL @__MoveBytes ENDASM MoveBytes: temp2=__PARAM1 temp3=__PARAM2 tempA=__PARAM3 tempB=__PARAM4 FOR ACount=0 to temp1 READ temp2+temp3,temp4 ASM MOV FSR,#tempA+tempB MOV IND,temp4 INC tempB ENDASM NEXT RETURN [/code] I'd much rather prefer something like [code] MOV W,#Here ; There(Index)=Here(Index) ADD W,Index MOV FSR,W MOV __PARAM2,IND MOV FSR,#$10 MOV W,#There ADD W,Index MOV FSR,W MOV IND,__PARAM2 [/code] But I'm not sure how to set up the address indirection. Joe ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=139735 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)