BAKR / PR



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

BAKR / PR

Postby steve-myers » Fri Jan 15, 2016 11:23 am

I've recently seen beginners writing programs like this -
XXX      CSECT
         BAKR  14,0
         ...
         PR
This is terrible practice. Why? It's very slow compared to traditional entry / exit conventions. It saves and restores 16 64 bit "general purpose" registers, 16 32 bit access registers and the PSW. Traditional entry exit saves and restores fewer 32 bit (well the low order 32 bits) "general purpose" registers, no access registers, and no part of the PSW. Years ago, when BAKR / PR were relatively new I did a performance study and was shocked about how bad its performance was. This was before z/Architecture with 32 bit registers rather than 64 bit registers. I no longer recall the exact numbers from roughly 20 years ago, but it will most likely be worse now.

This was also about the time IBM was starting to put together the XPLINK convention. A big part of XPLINK was to save and restore fewer registers in addition to other changes to improve overall program performance in an environment where small subroutines are frequently called. Clearly BAKR / PR are not used in XPLINK.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: BAKR / PR

Postby Philippe Leite » Mon May 23, 2016 9:38 pm

If your program works as a main routine, there is no problem to use linkage stack convention (BAKR/PR). The performance penalty in this case is really small.
The linkage stack mechanism in the modern machines like z196, EC12 and z13 was deeply improved. But if your program works as a subroutine an it's being called a hundred or thousand times, so in this case it's better use the traditional linkage convention.

Regards.
Regards,

Philippe Leite
z/OS System Programmer
Philippe Leite
 
Posts: 2
Joined: Mon May 23, 2016 9:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: BAKR / PR

Postby steve-myers » Tue May 24, 2016 9:24 am

I generally agree with Mr. Leite if it is limited to initial entry and exit of a "main" program rather than heavily used internal subroutines. My concern, though, is this: at least in concept a "main" program is a subroutine of the operating system, so it should use the same entry/exit convention as any other subroutine.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: BAKR / PR

Postby steve-myers » Tue May 24, 2016 6:50 pm

An exception to the no BAKR/PR rule for an internal subroutine might be for the case where the subroutine uses GETMAIN/FREEMAIN/STORAGE to obtain just a new save area and nothing else to make the function reenterable. I must admit, though, that I have trouble conceiving a function like this.

I do have functions in my own work that are very close in concept to this type of function. Like many programmers I use a save area “stack.” My function is -
FMTLINE  BASR  15,0
         SAVE  (14,1),,FMTLINE
         LA    15,72(,13)
         ST    13,72+4(,13)
         ST    15,8(,13)
         LR    13,15
*        CALL  function to format a line
*        CALL  function to write the formatted line
         L     13,4(,13)
         RETURN (14,1)


Without the save area stack the function becomes -
FMTLINE  BASR  15,0
         SAVE  (14,1),,FMTLINE
         LA    0,72
         GETMAIN RU,LV=(0)
         ST    13,4(,1)
         ST    1,8(,13)
         LR    13,15
*        CALL  function to format a line
*        CALL  function to write the formatted line
         LR    1,13
         L     13,4(,13)
         LA    0,72
         FREEMAIN RU,LV=(0),A=(1)
         RETURN (14,1)


With the linkage stack it becomes -
FMTLINE  BAKR  14,0
*        CALL  function to format a line
*        CALL  function to write the formatted line
         PR
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Assembler