|
First off: it was a point of interest more than anything else. In very
simple terms, my understanding is that EVAL is roughly equivalent to MOVEL
in the same sense that EVALR is roughly equivalent to MOVE.
This is the
basis behind my question. It also turns out to lead to invalid assumptions,
but just to justify where I was coming from... in a world where eval is
strictly a left-to-right operation, and where LEN = 1:
eval %Subst(mystring: LEN) = mystring ;
would seem to imply (since it's left-to-right) that byte 1 of mystring would
be moved to byte 2 of mystring; and then byte 2 of mystring would be moved
to byte3, et cetera, propagating the leftmost value throughout the length of
string. Values of LEN that are equal to some arbitrary "array element
length" would have the same effect: Elem2 = Elem1, then Elem3 = Elem2 and so
on.
These are both things we did as common practice for efficiently clearing
and/or initializing areas of memory in Assembler.
It turns out (or appears)
that the MI is pulling some tricks under the covers.
I was really curious about this, so I tried the same thing, using MEMCPY, as
follows:
MemCpy %Addr(mystring)+1: %Addr(mystring): %Len(mystring)-1) ;
I expected this to be functionally equivalent to my old, trusty-dusty:
MVC OUTPUT,OUTPUT-1
Which is strictly a left-to-right operation. To my amazement, it didn't do
what I thought it would do... it had to switch to a Right-to-Left operation
in order to pull off what it did do, which was start with 01234567 and end
with 00123456.
To finally kill this thing off, I tried the opposite:
Memcpy %Addr(myString): %Addr(myString) + 1: %Len(myString)-1) ;
This translated to a Left-to-Right operation, since my result was 12345677.
(sigh.)
Usually I distrust a machine that tries to do what I want rather than what I
say. This is my first distrust of this particular family. So I wonder if
there's a way to do that old thing at all on AS/400, other than in a loop
where it's done by hand? I didn't try other languages, but given that
memcpy worked that way, I doubt it.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.