× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Empiricism has its advantages.

DCL DD FOO CHAR(20) AUTO INIT('00000000001234567890');
DCL SPCPTR BAR AUTO;
DCL SPCPTR BAZ AUTO INIT(FOO);
DCL DD FIRSTNZ BIN(4) AUTO;
DCL DD CONTROL CHAR(8) AUTO INIT(X'010000F000000014');
ENTRY .ENTRY EXT;
SETSPPFP BAR, BAZ;
SCANWC BAR, CONTROL, X'06000000', =+1;
: SUBSPPFO FIRSTNZ, BAR, BAZ;
ADDN(S) FIRSTNZ, 1;
RTX *;
PEND;

FOO is the string to be searched. BAR is the pointer we're going to be feeding to the SCANWC statement. BAZ is a pointer used to initialize BAR, and then subtract from BAR in order to get the character position. FIRSTNZ is where we're going to put the difference.

CONTROL is the 8-byte control word:
01: Base and comparison mode both simple, starting the scan.
00: Reserved
00F0: looking for an EBCDIC '0'
00: Reserved
000014: Base length is 20

First, we SETSPPFP to initialize BAR from BAZ.

Then, we SCANWC our string, with the control, and option word as follows:
06: Option indicators, match if greater or less
000000: Reserved.
The fourth operand is where to go if it finds something that's less than an EBCDIC space; supposedly, it will accept a Null or omitted operand, but I couldn't figure out how. Note that it's essentially a naked branch target; in this case, a naked relative branch target just going to the next instruction.

At the end of the SCANWC, the offset in BAR has been set to the offset of the first character that isn't an EBCDIC zero.

Next, we subtract BAZ from BAR, to get the character position, and add 1, so that we're working with character positions (starting with 1) rather than offsets (starting with 0).


If you then run this in the debugger, with a breakpoint on the RTX, you'll get the expected result.

--
JHHL

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.