EPA or base register?



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

EPA or base register?

Postby bobguo » Wed Aug 21, 2013 1:21 pm

sorry, one more question :D
000000                00000 0006C     1 MAIN     CSECT                   
                 R:C  00000           2          USING *,12               
000000 90EC D00C            0000C     3          STM   14,12,12(13)       
000004 0DC0                           4          BASR  12,0               
000006 50D0 C028            00028     5          ST    13,SAVE+4         
00000A 41D0 C024            00024     6          LA    13,SAVE           
                      0000E           7 START    EQU   *                 
00000E FA00 C022 C023 00022 00023     8          AP  P1,P2               
                      00014           9 EXIT     EQU   *                 
000014 58D0 C028            00028    10          L     13,SAVE+4         
000018 98EC D00C            0000C    11          LM    14,12,12(13)       
00001C 41F0 0000            00000    12          LA    15,0               
000020 07FE                          13          BR    14                 
000022                               14 P1       DS   P                   
000023                               15 P2       DS   P   


this is one very sample SOC7 abend program, as it shows, the value of R12 = EPA(entry pointer address)+6,
i think the address of P1 should equal to 'EPA+22', not ''(R12)+22',
but computer translated it to C022

can someone explain it to me? thanks.
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: EPA or base register?

 

Re: EPA or base register?

Postby BillyBoyo » Wed Aug 21, 2013 2:23 pm

What is EPA? Is that some special register? No. It is just a descriptive phrase for a particular address value. Where is it? Unless you work hard, it is in R15.

Where is your P1? To allow it to be referenced, you kindly supplied a USING. So for the following 4096 bytes, the Assembler can reference everything using the current value of R12.

Err... or it could do. Compare your code to any working program (examples from Steve Myers here, examples at your site, search-engine, etc) and you'll see what you are missing.

The EPA is in R15 on entry to your program. What happes to it after that, and what you use it for, is entirely up to you. If you don't use it...
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: EPA or base register?

Postby bobguo » Wed Aug 21, 2013 3:13 pm

as the listing shows, any label can be referenced by using "R12(base register) + location counter's value", so just only when R12=R15(EPA), all the labels can be referenced correctly, right?
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: EPA or base register?

Postby steve-myers » Wed Aug 21, 2013 4:17 pm

Your base register setup is incorrect. Assuming the call to the entry point establishes register 15 correctly, you have two "correct" ways to establish your base register.

Option 1 - which I usually use since the displacement values in the assembled instructions will assemble to the offset value -
MAIN     CSECT
         USING *,12
         SAVE  (14,12),,*
         LR    12,15
         ...

Option 2 - This is the correct way to do what you tried -
MAIN     CSECT
         SAVE  (14,12),,*
         BASR  12,0
         USING *,12
         ...
Remember that the USING Assembler instruction is a promise to the Assembler that you will have a specific address in a specific register. BUT you have to put the address in the register.

The STM 14,12,12(13) instruction you used is perfectly OK, but the program identification in the SAVE macro has two advantages.
  1. When the system dump program formats the save area chain, it will place the identifier in the SAVE macro in its listing.
  2. It makes it easier to find your program in a storage dump. I usually use something similar to this.
    MYPGM    CSECT
             USING *,12
             SAVE  (14,12),,'MYPGM &SYSDATE &SYSTIME'
             LR    12,15
    Now I have a program identifier, and the date and time step in the identifier is a way to verify the program in the dump matches the program in the listing I'm using, which is often quite useful.
Back in the days when I did product support for a living, one version of the product used the equivalent of option 2 as it normal entry setup, which I found annoying. The other version of the product used the equivalent of option 1 as its entry setup.

A hint about using code tags here. The available width in the code tags is quite limited; assembler listings in the code tags are just too wide for it to work well.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: EPA or base register?

Postby steve-myers » Wed Aug 21, 2013 4:39 pm

EPA is Entry Point Address. As BillyBoyo noted, most of the time when a program is entered it is in register 15.

Many of my programs have small subroutines, which I usually call using BAS 14,MYSUB, or something equivalent. These routines use the addressability already established for the program, so they do not need to establish new addressability, but I do use the SAVE macro. My entry convention is
MYSUB    BASR  15,0
         SAVE  (...),,MYSUB
The SAVE macro with an identifier requires register 15 to have the address of the SAVE macro; the BASR puts it there.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post