Help Explain movd instruction
tdlivings
Posts: 437
I have clipped a code section out of Beau Schwabe SPI Engine which uses MOVD
It appears to me the statement movd :arg,#arg0· moves the address of arg0 to a label
which is just down a few lines in the code. This puzzels me and I am not understanding
the instruction. arg0 does exist as a storage location as I also show.
Can anyone give an explaination.
Thank's
Tom
DAT·········· org
'·
'' SPI Engine - main loop
'
loop········· rdlong· t1,par········· wz··············· ''wait for command
······· if_z· jmp···· #loop
············· movd··· :arg,#arg0······················· ''get 5 arguments ; arg0 to arg4
············· mov···· t2,t1···························· ''··· │
············· mov···· t3,#5···························· ''───┘
:arg········· rdlong· arg0,t2
············· add···· :arg,d0
············· add···· t2,#4
············· djnz··· t3,#:arg
············· mov···· address,t1······················· ''preserve address location for passing
······················································· ''variables back to Spin language.
············· wrlong· zero,par························· ''zero command to signify command received
.
.
. Futhere down in code
address················ long··· 0······················ ''···· Used to hold return address of first Argument passed
arg0··················· long··· 0······················ ''arguments passed to/from high-level Spin
arg1··················· long··· 0
arg2··················· long··· 0
arg3··················· long··· 0
arg4··················· long··· 0
·
It appears to me the statement movd :arg,#arg0· moves the address of arg0 to a label
which is just down a few lines in the code. This puzzels me and I am not understanding
the instruction. arg0 does exist as a storage location as I also show.
Can anyone give an explaination.
Thank's
Tom
DAT·········· org
'·
'' SPI Engine - main loop
'
loop········· rdlong· t1,par········· wz··············· ''wait for command
······· if_z· jmp···· #loop
············· movd··· :arg,#arg0······················· ''get 5 arguments ; arg0 to arg4
············· mov···· t2,t1···························· ''··· │
············· mov···· t3,#5···························· ''───┘
:arg········· rdlong· arg0,t2
············· add···· :arg,d0
············· add···· t2,#4
············· djnz··· t3,#:arg
············· mov···· address,t1······················· ''preserve address location for passing
······················································· ''variables back to Spin language.
············· wrlong· zero,par························· ''zero command to signify command received
.
.
. Futhere down in code
address················ long··· 0······················ ''···· Used to hold return address of first Argument passed
arg0··················· long··· 0······················ ''arguments passed to/from high-level Spin
arg1··················· long··· 0
arg2··················· long··· 0
arg3··················· long··· 0
arg4··················· long··· 0
·
Comments
This instruction is moving the 9 bit constant stored in its instruction in the source bits (which have been set to the value of arg0 by the compiler) to the destination field (9 bits) of the instruction pointed to by the instructions destination field (which is pointing to :arg). So the instruction at :arg has it's destination field modified from arg0 to arg0. Usually we show this like
:arg rdlong 0-0,t2
where 0-0 is a programmers way of saying it will be modified at run-time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
http://forums.parallax.com/forums/attach.aspx?a=16161
This is the standard (and only) way to do indirect addressing in PASM. Basically, the movd instruction changes the instruction at :arg into mov (whatever the movd wrote),#arg0.
I will have to contemplate how it is being used.
Thank's localroger I will give the doc a read.
Tom
I am beginning to understand the concept.
Cluso99 I meant to say yesterday your wording helped break
my view of the wording in the manual. I was in the mode of
viewing a polor bear in a snow storm, reading the words but
attaching no meaning to it. Thanks again everyone.
Tom
·