First operand specified the address of NSI( Next sequential instruction will be loaded into 12 register and the second operand specifies that Rout -> it will branch to Rout
BALR 12,0
Here both operands are registers. Here the second operand is 0. it specifies no branching will takes place.
BAS stands for Branch and save
Unconditional branching and the possibility of returning to the branch point is performed by BAS.
The address of the next sequential instruction (NSI) is placed in the 1st-operand register. Subsequently a branch is made to the location given by a 2nd-operand label.
The instruction(s) is commonly used to branch to a subroutine with an expected return. Now to return, the help of the unconditional BR (Branch Register) instruction is needed (see the BC instruction).
The exact differences of BAL, BAS and BASSM are explained below:
BAL is used in 24bit operating system and maintained in 32 bit also to maintain compatibility.
BAL stores the return address(24 bits) and the linkage information (Condition code, program mask and ICL (cond code length))
In 32 bit environment BAL is similar to BAS.
BAS - Branch and Save instruction stores the right half of the PSW (i.e., The return address). It does not set the addressing mode bit.
It is used when there is no change in the addressing mode.
In 32 bit environment usage of BAS is preferred than BAL.
BASSM - Branch and save set mode
It stores the right half of the PSW in the target register and sets the addressing mode in the higher order bit.
This is the basic info I have it.
If anybody have some more info plz append to this info.
I dont think that the BAL and BAS instructiuons has anything to do with the 24 or 31-bit addressing mode.
In both addressing mode either of the instructions can be used unlike what vighneshs says.
The pimary function of BAL and BAS instructions is to brach to the address specified by the 2nd operand but feore branching the addresss of the next sequentioal instruction will be saved in the 1st operand register.
when BAL is used in 24-bit addressing mode, the address of NSI(Next Sequential Instruction) is saved in the first operand register
and consists of
The instruction length code (ILC) in bits 0-1,
The condition code (CC) in bits 2-3,
The program mask in bits 4-7, and
The linkage address in bits 8-32.
In 31-bit mode, a 31-bit linkage address
is loaded and bit 0 is set to 1.
The difference in the two instructions is as follows:
The BAS instruiction doesnot save the ILC, CC and program mask in the 1-7 bits hence the BAS executes faster than the BAL.
For the same reason, BAS is used to branch to programs in the same addressing mode as the caller.
Joined: 03 May 2020 Posts: 1 Location: United States
The BAL and BALR branch and link instructions were designed for the regular IBM 360 mainframe hardware models.
The BAS and BASR Branch and Store instructions worked on the much smaller IBM 360/20 (and IBM 360/10?) which were card/printer based single unit devices (and a printer). I don't remember seeing tape or disk on them. They didn't support the BAL BALR instructions as they didn't have more than 16 bits worth of addressing or require the type of task switching used in the larger machines.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
sol wrote:
... The BAS and BASR Branch and Store instructions worked on the much smaller IBM 360/20 (and IBM 360/10?) which were card/printer based single unit devices (and a printer). I don't remember seeing tape or disk on them. They didn't support the BAL BALR instructions as they didn't have more than 16 bits worth of addressing or require the type of task switching used in the larger machines.
360/10???? No such animal. And, yes, you could get both tape and disk on 360/20 machines. I saw, with my own eyes, tape, but never saw a /20 with disk.
BAS also existed on the 360/67 for use in the /67 AMODE 32 - yes, Virginia, there was such an animal. It could also be RPQed on the 370/168 to support TSS/370, another rare animal. As has been noted, it was fully resurrected for 370 "Extended architecture" (XA) machines.
As has been noted, BAL stores the instruction length code, condition code and program mask in the link register in AMODE 24; in the 360/20 there was no room for this data in the link register, as was also true for the 360/67 run in AMODE 32. I recall how disappointed I was when the original 370 virtual storage hardware only had AMODE 24.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
To illustrate the differences between Branch and Link and Branch and Save I wrote the following -
Code:
MACRO
&NAME NEWSAVE &ADDR
&NAME LR 15,13 COPY SAVE AREA ADDRESS TO REG 15
AIF ('&ADDR' EQ '').STACK
LA 13,&ADDR COMPUTE NEW SAVE AREA ADDRESS
AGO .CHAIN
.STACK LA 13,72(,13) COMPUTE NEW SAVE AREA ADDRESS
.CHAIN ST 13,8(,15) ADD NEW SAVE AREA TO THE
ST 15,4(,13) SAVE AREA CHAIN
MEND
MAIN CSECT
USING *,12
SAVE (14,12),,*
LR 12,15
NEWSAVE SAVEAREA
OPEN (PRINT,OUTPUT)
MVC AM,=C'24'
PUT PRINT,AMLINE
BAL 14,RUN
MVC AM,=C'31'
PUT PRINT,AMLINE
SAM31
BAL 14,RUN
CLOSE PRINT
L 13,4(,13)
RETURN (14,12),RC=0
CNOP 0,8
RUN BASR 15,0
SAVE (14,1),,RUN
NEWSAVE ,
MVC OPCODE,=CL4'BALR'
LA 15,LISTLINK
BALR 14,15
MVC OPCODE,=CL4'BAL'
BAL 14,LISTLINK
MVC OPCODE,=CL4'BASR'
LA 15,LISTLINK
BASR 14,15
MVC OPCODE,=CL4'BAS'
BAS 14,LISTLINK
L 13,4(,13)
RETURN (14,1)
CNOP 0,8
LISTLINK BASR 15,0
SAVE (14,1),,LISTLINK
NEWSAVE ,
L 15,4(,13)
UNPK LINKREG(9),12(5,15)
TR LINKREG,HEXTAB
PUT PRINT,LINKLINE
L 13,4(,13)
RETURN (14,1)
PRINT NOGEN
PRINT DCB DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,RECFM=VBA,LRECL=125
AMLINE DC AL2(AML,0),C' AM '
AM DC CL2' '
AML EQU *-AMLINE
LINKLINE DC AL2(LINKL,0),C' '
OPCODE DC CL4' ',C' '
LINKREG DC CL8' '
LINKL EQU *-LINKLINE
DC C' '
SAVEAREA DC (3*9)D'0'
HEXTAB EQU *-C'0'
DC C'0123456789ABCDEF'
LTORG ,
END MAIN
For those not familiar with Assembler there are three functions in this program. The MAIN function sets the AMODE, 24 or 31, and calls the RUN function (using the BAL instruction, though that does not matter here). The RUN function calls the LISTLINK function to display the link register using the BALR, BAL, BASR and BAS instructions. The output is -
Code:
AM 24
BALR 500370A0
BAL 900370AA
BASR 000370B6
BAS 000370C0
AM 31
BALR 800370A0
BAL 800370AA
BASR 800370B6
BAS 800370C0
In AMODE 24, the instruction length code, condition code and program mask are in the high order 8 bits of the link register. 50 is 01 01 0000, Instruction length code 01 means BALR is a 2 byte instruction. 90 is 10 01 0000, so BAL is a 4 byte instruction.
Branch and Save does not leave an instruction length code; this area is 00 in AMODE 24 and 10 in AMODE 31, which reflects the AMODE.
While I rather doubt anyone will respond, if an EX instruction executes a BALR instruction in AMODE 24, what will be the instruction length code, and why? Tuesday or Wednesday I'll respond with the answer.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
steve-myers wrote:
... if an EX instruction executes a BALR instruction in AMODE 24, what will be the instruction length code, and why? Tuesday or Wednesday I'll respond with the answer.
The instruction length code wil be B'10' because you get the ILC of the EX instruction, but the BALR instruction.