More than you wanted to know?
+-------------+
| MOVW |
| |
| A:+0 |
| |
| RESET IMAGE |
| REGISTER |
| TO ZERO |
| B:V101 |
| N=16 |
+-------------+
Brian E asked...
"In the MOVW Instruction what does the N=16 reference?"
Cutting to the quick, the manual says that "N" refers to the number of words to be copied. (I hope everyone realizes that a "Move" is really a "Copy" in that it does NOT leave an empty location behind... unless of course, it was empty to begin with.)
Since "A:" is a constant ("+0"), the instruction copies "+0" to "N-consecutive" word locations starting at V101.
Here is a very simplistic (and somewhat misleading) way of looking at it...
MOVW
A: +0
B: V101
N=4
("=>" means "goes to")
"N" A: B:
(1) +0 => V101
(2) +0 => V102
(3) +0 => V103
(4) +0 => V104
If the element in "A:" is a readable word location (ex: V201), then "N" greater than 1 indicates that this will be a Table Move (copy) consisting of N-elements. This also is a simplistic (and again, somewhat misleading) way of looking at it...
MOVW
A: V201
B: V101
N=4
("=>" means "goes to")
"N" A: B:
(1) V201 => V101
(2) V202 => V102
(3) V203 => V103
(4) V204 => V104
The actual steps in the instruction are much more involved...
(This might not be exactly how it works... if not, it's damned close!)
The instruction uses an Internal Index.
The initial value of the Internal Index is "0". This value serves as an "Offset".
A: V201 is the Base Address of the Source.
The Internal Index is the offset from the Source Base Address.
B: V101 is the Base Address of the Destination.
The Internal Index is the offset from the Destination Base Address.
First Pass... N = 4, Internal Index = 0
Compare the Internal Index to "N".
If the Internal Index = "N" then the instruction is DONE. (If "N=0" then no words are copied).
COPY "Source Base Address + Index" to "Destination Base Address + Index".
That is, COPY "V201 + 0 = V201" => "V101 + 0 = V101"
Increment the Internal Index (0 +1 = 1)
Second Pass... N = 4, Internal Index = 1
Compare the Internal Index to "N".
If the Internal Index = "N" then the instruction is DONE.
COPY "Source Base Address + Index" to "Destination Base Address + Index".
That is, COPY "V201 + 1 = V202" => "V101 + 1 = V102"
Increment the Internal Index (1 +1 = 2)
The loop continues until the Internal Index = "N".
Here it is in table-form...
MOVW
A: V201
B: V101
N=4
("=>" means "goes to")
Before each pass... Compare Internal Index to "N". If GT or EQ to "N", then DONE.
If N = 0 then no passes are executed... the instruction is done before it starts.
Internal
PASS "N" Index A: + Index = Source => B: + Index = Destination INC Index
1 (4) (0) V201 + 0 = V201 => V101 + 0 = V101 0 + 1 = 1
2 (4) (1) V201 + 1 = V202 => V101 + 1 = V102 1 + 1 = 2
3 (4) (2) V201 + 2 = V203 => V101 + 2 = V103 2 + 1 = 3
4 (4) (3) V201 + 3 = V204 => V101 + 3 = V104 3 + 1 = 4
5 (4) (4) Internal Index = "N"... DONE!
Notice that "N" acts as an Index Limit. When the Internal Index is equal to "N" then the instruction is DONE.
The default value for N is "1". This causes at least one word to be copied... otherwise, what's the point? Initially, the instruction starts with an Internal Index value of "0". Before executing a move (making a pass), the instruction compares an Internal Index to "N". If the Internal Index = "N" then the instruction is DONE.
Actually, internally, there is still a bit more going on than shown...
V201 is NOT an actual address! It is only a NAME of a particular address! The specific memory address is more involved than simply "V201". But that is beyond this particular discussion.
Does that answer your question Brian? (Probably more than you needed or wanted to know...?)
BTW, "RESET IMAGE REGISTER TO ZERO" sounds like a perfectly ridiculous name for V101. It makes no sense at all.
Peter said...
"MOVW is very similar to an AB MOV only not as flexible."
This is true...
MOVW is not very flexible. That is why TI has the
MOVE (Move Element as opposed to Move Word) Instruction.
The MOVE instruction is much more powerful than the MOVW instruction. I don't think any vendor has a more powerful version of this instruction. Equal, maybe, more powerful... I doubt it.
Peter also said...
"Only the Control Logix can now challenge the TI505 back plane."
As in... AB is
finally coming up to speed. I can't argue with that. In fact, they have gone a few steps further by implementing tag-oriented element names. This kind of programming goes back to the early 80's when DEC introduced VMS (Virtual Memory System). No longer did a programmer have to keep track of all of the memory locations by address... now the system did it automatically through virtual naming.
For those that aren't aware of it... "C"-type programming in PLCs is slipping in right under your noses! Control Logix is very much like "C".
But I gotta say... I absolutely hate their programming interface display and their program print-outs. They still have a ways to go in that respect.
And yes, I certainly know that Peter has depended on TI-505 business for quite a while. I have a couple of his motion control cards installed (although I'm replacing those with a pair of standard analog output cards).
I know that Peter has much respect for the TI-505 line.
BTW, Brian...
Do you, or have you used CVU?