Query on USING instruction



High Level Assembler(HLASM) for MVS & VM & VSE

Query on USING instruction

Postby huxianjun » Sat Nov 12, 2016 8:39 pm

Hello

Can anyone help on this compilation error(related to USING instruction)?

Here's my sample program:
ASMTEST  CSECT
         STM   14,12,12(13)
         BALR  12,0
         USING *,12
         OPEN (VSAMACB)
         CH    15,=H'4'
         GET   RPL=VSAMRPL
         WTO 'GET A VSAM RECORD!'
         LM    14,12,12(13)
         XR    15,15
         CLOSE (VSAMACB)
         BR    14
VSAMACB  ACB   AM=VSAM,                                              
               DDNAME=VSAMFILE,                                        
               MACRF=(SEQ,IN)
VSAMRPL  RPL   AM=VSAM,                                              
               ACB=VSAMACB,                                              
               AREA=IOAREA,                                                
               AREALEN=7500
         SPACE 1
IOAREA   DS    CL7500
         END


Here's the error message in the compilation listing:
000012 0000 0000 00000 12 CH 15,=H'4'
** ASMA034E Operand =H'4' beyond active USING range by 3643 bytes

I know the USING instruction is to establish the addressability, but can anyone explain in detail by USING *,12 what
addressability established from the above program? and how the 3643 bytes beyond the USING range was calculated?

Also, what the '=' in the literal =H'4' mean? is it a MUST to have the '=' to specify a literal constant?

Thanks, Roy
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query on USING instruction

Postby Robert Sample » Sat Nov 12, 2016 9:09 pm

First, learn to use the Code tags to preserve spaces. I Code'd your post for you this time.

USING establishes a base address and one or more base registers for relative offsets. A base register only can address 4096 bytes, so if you attempt to define a 7500-byte area then you need a second base register to access all bytes past offset 4095. You could code USING *,12,11 to use the current location as the base address and registers 12 and 11 as your base registers.

The = sign indicates you are specifying a literal constant. There are a few instances when it is not required (MVI, CLI for example) but in general if you specify a literal constant, you must use the = in front of it.
Robert Sample
Global moderator
 
Posts: 3657
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 270 times

Re: Query on USING instruction

Postby steve-myers » Sat Nov 12, 2016 10:25 pm

Another technique you can use is to use the LTORG Assembler instruction to persuade the Assembler to insert a literal pool at some location other than the default location. In other words, if you insert your literal pool before the IOAREA, the program will assemble just fine.

Unrelated to your query, this program will fail as written.

After your STM instruction, the storage in the register save area is used to contain registers. Many I/O instructions, like your GET RPL instruction, use the register save area for their processing. If you do not provide a new register save area, the registers stored in the save area are replaced by the registers used by the GET RPL code.

Many programmers structure their programs like this -
APROGRAM CSECT
         STM   14,12,12(13)
         BALR  12,0
         USING *,12
         LA    15,SAVEAREA
         ST    13,4(,15)
         ST    15,8(,13)
         LR    13,15
         ...
         L     13,4(,13)
         LM    14,12,12(13)
         SR    15,15
         BR    14
SAVEAREA DC    18F'0'
The save areas are supposed to be in a chain of save areas. Offset 4 in a save area points to the higher save area; offset 8 points to a lower save area. This is what

ST 13,4(,15)
ST 15,8(,13)

is doing.

A wise programmer assumes all IBM macros, like the OPEN, CLOSE, GET and WTO macros in your program, will alter registers 14, 15, 0 and 1. These registers are often called the "link registers."

Manuals like the MVS Programming: Assembler Services series for your z/OS release will discuss this in more detail, but it is usually safer to assume the link registers are trashed by all IBM macros. On the other hand, IBM macros generally do not alter registers 2 through 13, though some, like the GET macro, in your program, use the register save area to preserve registers they do use for their processing.
steve-myers
Global moderator
 
Posts: 2092
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 235 times

Re: Query on USING instruction

Postby huxianjun » Sun Nov 13, 2016 1:03 am

Thanks Robert!

Since =H'4' is a literal value (my understanding is the program needs not go to anywhere in the memory to fetch the value '4'), I still could not understand why following error is raised against it:
** ASMA034E Operand =H'4' beyond active USING range by 3643 bytes

I would understand such error raised if my program tries to access somewhere in the IOAREA which is defined as 7500 bytes hence beyond the addressability of 4096 bytes in the case...

Guess if I could understand what I'm asking the above, I would then understand how the USING instruction works

Thanks, Roy
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query on USING instruction

Postby enrico-sorichetti » Sun Nov 13, 2016 1:31 am

my understanding is the program needs not go to anywhere in the memory to fetch the value '4'),


unfortunately the memory is accessed for everything that is done ...
the instruction are fetched to executed :mrgreen:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2963
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 160 times

Re: Query on USING instruction

Postby huxianjun » Sun Nov 13, 2016 1:54 am

Okay, I think I figured it out now...

Though a literal, when the program is assembled, the =H'4' will be assembled at where immediately followed the end of the CSECT section, hence it'll be beyond the range of 4096 when the program fetches the literal value!

Learnt a lot from your guys :D
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query on USING instruction

Postby steve-myers » Sun Nov 13, 2016 5:39 am

Here are a few lines from the Assembler listing -
 Loc  Object Code    Addr1 Addr2  Stmt   Source Statement

000004 05C0                           3          BALR  12,0
                 R:C  00006           4          USING *,12

000012 0000 0000            00000    11          CH    15,=H'4'  
** ASMA034E Operand =H'4' beyond active USING range by 3643 bytes

                                     19          WTO 'GET A VSAM RECORD!'  
000028                               21+         CNOP  0,4                  
000028 4510 C03C            00042    22+         BAL   1,IHB0003A          
00002C 0016                          23+         DC    AL2(22)              
00002E 0000                          24+         DC    B'0000000000000000'  
000030 C7C5E340C140E5E2              25+         DC    C'GET A VSAM RECORD!'
000042                               26+IHB0003A DS    0H                  
000042 0A23                          27+         SVC   35

0000F0                              149 IOAREA   DS    CL7500
                                    150          END        
001E40 0004                         151                =H'4'


The R:C 00006 on the USING line us the Assembler telling you it is using register C, and the addressability starts at location 6.

An instruction can access storage by using a register and a positive offset from the register. For example, in the WTO macro we see -

BAL 1,IHB0003A

IHB0003A is a storage address. The C03C in the 4510 C03C (the machine code for the BAL instruction) tells the machine to add 03C to the contents of register C to compute the address where the instruction branches. The Assembler calculated the 03C by taking 042 (the address assigned to IHB0003A and subtracting 6 (the address assigned to the location counter specified in the USING instruction). There are just 12 bits in the 03C; the maximum value in 12 bits is FFF, or 4095 in decimal.

Getting an address in IOAREA is somewhat more complicated. Obviously, it is very easy to get the address of IOAREA: C0EA. F0 - 6. Accessing the data in the record is more complicated and depends on how the data in the record is stored. That's really all I can say since I have no idea about that. In the last few years I have written several programs to analyze SMF data. Some of the records are much longer than your 7500 byte record.

... the =H'4' will be assembled at where immediately followed the end of the CSECT section
The rule for where the Assembler will place the literal pool is actually more complex than your simplified rule.
steve-myers
Global moderator
 
Posts: 2092
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 235 times

Re: Query on USING instruction

Postby huxianjun » Sun Nov 13, 2016 9:19 am

Thanks Steve for such detailed explanation!!
huxianjun
 
Posts: 23
Joined: Thu Jul 21, 2016 10:10 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query on USING instruction

Postby BillyBoyo » Sun Nov 13, 2016 1:11 pm

Literals are not "global" in any way. In the case of the "immediate" instructions, with a one-byte (or two-byte with the more recent instructions) the literal is embedded in the instruction. Otherwise, the literals have to live somewhere in the program, and, where there are multiple CSECTs, being within the CSECT where referenced is "good".

Yes, this means you have have the same literal defined in multiple places, and yes this means if you trash a literal pool your "literal" can suddenly obtain a different value. A "literal" is just a convenient way to define a value without you having to establish a field yourself. The Assembler defines the field for you and provides no direct way to change the field, but otherwise it is just a field. Two different programs referencing the "same" literal will get the literal value from two different locations (the value will be the same, unless you've trashed it in error).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Query on USING instruction

Postby steve-myers » Thu Nov 17, 2016 2:18 am

BillyBoyo wrote: ... In the case of the "immediate" instructions, with a one-byte (or two-byte with the more recent instructions) the literal is embedded in the instruction. ...

More precisely, the data is embedded in the instruction. There are a few instructions in z/Architecture where you can embed 32 bits of data in the instruction! This is called the extended immediate facility. As an example,

AFI register,data (Add Fullword Immediate)

Unlike literals, which can potentially be modified, it is somewhat more difficult to modify data embedded in an instruction.
steve-myers
Global moderator
 
Posts: 2092
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 235 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post