22.02.2015 Views

HLASM Language Reference

HLASM Language Reference

HLASM Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 103. Substring Notation in Conditional Assembly Instructions<br />

Used in Used as Example<br />

SETC instruction<br />

operand<br />

AIF or SETB<br />

instruction operand<br />

(logical expression)<br />

Operand<br />

Part of<br />

operand<br />

Character value<br />

in comparand of<br />

character relation<br />

&C1 SETC 'ABC'(1,3)<br />

&C2 SETC '&C1'(1,2).'DEF'<br />

AIF ('&STRING'(1,4) EQ 'AREA').SEQ<br />

&B SETB ('&STRING'(1,4).'9' EQ 'FULL9')<br />

Value<br />

assigned to<br />

SETC Symbol<br />

ABC<br />

ABDEF<br />

---<br />

The substring notation must be specified as follows:<br />

'CHARACTER STRING'(e1,e2)<br />

where the CHARACTER STRING is a character expression from which the substring is<br />

to be extracted. The first subscript (e1) shows the position of the first character<br />

that is to be extracted from the character string. The second subscript (e2) shows<br />

the number of characters to be extracted from the character string, starting with the<br />

character indicated by the first subscript. Thus, the second subscript specifies the<br />

length of the resulting substring.<br />

The second subscript value of the substring notation can be specified as an<br />

asterisk (), to indicate that all the characters beginning at the position of the first<br />

expression should be used. The extracted string is equal to the length of the<br />

character expression, less the number of characters before the starting character.<br />

The character string must be a valid character expression with a length, n, in the<br />

| range 1 through 1024 characters. The length of the resulting substring must be in<br />

| the range 0 through 1024.<br />

The subscripts, e1 and e2, must be arithmetic expressions.<br />

| When you use subscripted variable symbols in combination with substring notation,<br />

| take care to distinguish variable subscripts from substring-operation subscripts.<br />

| LCLC &DVAR(1),&SVAR,&C(1)<br />

| &C(1) SETC '&DVAR(5)' Select 5th element of &DVAR<br />

| &C(2) SETC '&SVAR'(1,3) Select substring of &SVAR<br />

| &C(3) SETC '&DVAR(5)'(1,3) Select substring of &DVAR(5)<br />

| &C(4) SETC '&SYSLIST(1,3)'(1,3) Select substring of &SYSLIST(1,3)<br />

Evaluation of Substrings: The following examples show how the assembler<br />

processes substrings depending on the value of the elements n, e1, and e2.<br />

In the usual case, the assembler generates a correct substring of the specified<br />

length:<br />

Value of Variable Character Value<br />

Notation Symbol of Substring<br />

'ABCDE'(1,5)<br />

ABCDE<br />

'ABCDE'(2,3)<br />

BCD<br />

'ABCDE'(2,)<br />

BCDE<br />

'ABCDE'(4,)<br />

DE<br />

'&C'(3,3) ABCDE CDE<br />

'&PARAM'(3,3) ((A+3)1) A+3<br />

372 <strong>HLASM</strong> V1R5 <strong>Language</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!