Moving Bytes
JDOhio
Posts: 72
I have a few places in code where I move bytes around like this:
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:
I'd much rather prefer something like
But I'm not sure how to set up the address indirection.
Joe
FOR Index=0 to 6 There(Index)=Here(Index) NEXT
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:
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
I'd much rather prefer something like
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
But I'm not sure how to set up the address indirection.
Joe
Comments
In SX/B array names are just constants into the virtual __RAM array.
So you can do "tempbyte = __RAM(here)"
or you can assign the variable name to a byte variable and use that as an index into __RAM
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
Post Edited (Bean (Hitt Consulting)) : 8/11/2006 2:09:13 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College