I have got some questions on Assembler, whose answers were difficult to find in books. Can any body help me with them?
1) When any instruction is executed in Assembler, it sets a condition code, where is this condition code stored or where we can see its value?
2) How many bytes are required to store the condition code?
3) How to increment/decrement a value in a register without using A,AR,S and SR instruction?
4) DSECT is equivalent to LINKAGE SECTION in cobol. In assembler program, we can have many DSECTs but in COBOL we have only one LINKAGE SECTION, then how do we achieve the equivalent code of multiple DSECTS of Assembler in COBOL?
5) If I want to make register 11 and 12 as my base register, how can I do this apart from using "BALR and USING" directive, is there anything else I need to take care of?
6) If a variable is 500 bytes long and I want to pass some 50 or 100 bytes to it during runtime, how can we do it?
7) what is Entrant/Entry point in Assembler?
8) How do we attain the equivalent functionality as of DISPLAY of COBOL in Assembler?
from the principles of operations
( THE BIBLE FOR ASSEMBLER PROGRAMMING)
1/2 )
after any instruction setting the condition code the same is stored in the PSW
Quote:
Condition Code (CC): Bits 18 and 19 are the
two bits of the condition code. The condition code
is set to 0, 1, 2, or 3, depending on the result
obtained in executing certain instructions. Most
arithmetic and logical operations, as well as some
other operations, set the condition code.
to retrieve it
Quote:
INSERT PROGRAM MASK
The condition code and program mask from the
current PSW are inserted into bit positions 34 and
35 and 36-39, respectively, of general register R.
Bits 32 and 33 of the register are set to zeros; bits
0-31 and 40-63 are left unchanged.
Condition Code: The code remains unchanged.
Program Exceptions: None.
Used only in very SOPHISTICATED programming style were the test must
be delayed ( for example when doing some register usage optimization)
3) How to increment/decrement a value in a register without using A,AR,S and SR instruction?
4) DSECT is equivalent to LINKAGE SECTION in cobol. In assembler program, we can have many DSECTs but in COBOL we have only one LINKAGE SECTION, then how do we achieve the equivalent code of multiple DSECTS of Assembler in COBOL?
5) If I want to make register 11 and 12 as my base register, how can I do this apart from using "BALR and USING" directive, is there anything else I need to take care of?
7) what is Entrant/Entry point in Assembler?
3) look at the prociples of operations, and You will find a few alternatives,
( the add logical family )
what other instruction type would You propose ???
there is also the "LA" instructions ( not for beginners),
it has many gotcha's due to addressing mode setting
4) NOPE ...
a dsect might roughly be compared to a redefine
( but much more dynamic )..
there is no concept of automatic "LINKAGE SECTION"
all the checking for the right alignment is the programmers responsibility
5) BALR is an instruction... USING is a directive
to define a register as a base only the USING is necessary,
You might load the register at entry in any way You find useful
7) ENTRY is the right term...
like the name says it defines the label of the first instruction to be executed in the program/subroutine
note...note...
there is no difference as far as calling and register setup
between a main program and a subroutine ( as in cobol terminology )
a well behaved program expects/provides this register content
at entry
reg 14 the return address
reg 15 the first instruction address
reg 13 the address of a register save area
at exit
reg 14 the return address
reg 15 the return code
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
alokagarwaljgd wrote:
3) How to increment/decrement a value in a register without using A,AR,S and SR instruction?
BCTR is another.
Quote:
4) DSECT is equivalent to LINKAGE SECTION in cobol. In assembler program, we can have many DSECTs but in COBOL we have only one LINKAGE SECTION, then how do we achieve the equivalent code of multiple DSECTS of Assembler in COBOL?
In COBOL the equivalent to DSECTs is actually each 01 level in the LINKAGE SECTION.
Quote:
6) If a variable is 500 bytes long and I want to pass some 50 or 100 bytes to it during runtime, how can we do it?
I'm not sure what you are asking.
Quote:
8) How do we attain the equivalent functionality as of DISPLAY of COBOL in Assembler?
IIRC, not easily, but it is a wheel that has been invented many times, there are probably many macro versions laying about.....
Thanks for your reply but still there are a couple of things which are not clear to me as follows:
1) "there is no concept of automatic "LINKAGE SECTION"
all the checking for the right alignment is the programmers responsibility "
Can you please explain what you meant by above and how do we attain multiple DSECTS code in COBOL with an example?
2) "You might load the register at entry in any way You find useful " is ok, but is there any other way of making register 11 and 12 as my base register without using "USING" directive ?
3) "IIRC, not easily, but it is a wheel that has been invented many times, there are probably many macro versions laying about....."
Can you please give me an easy example or the equivalent code for types of display statements of COBOL in Assembler?
all the virtual/real storage addressing as per principle of operations
is in the form base and displacement ( see the instruction layout )
the base and diplacement are taken from the current using directive for the variable
lets make an example
Code:
someds dsect ... not to reseve any storage
var1 ds cl8
var2 ds cl8
after the directive ..
Code:
USING var1,4
Quote:
var1 will be addressed as 4,0
var2 will be addressed as 4,7
but after the directive
Code:
USING var2,5
Quote:
var2 will be addressed as 5,0
sorry but I cannot advise about cobol..
I JUST REFUSE TO USE IT
as far as point 2 the answer is NO... at least as program addressing is concerned..
unless You explicitly code for any instruction the base register and the displacement :-)
5) If I want to make register 11 and 12 as my base register, how can I do this apart from using "BALR and USING" directive, is there anything else I need to take care of?
Ans:-
PGM1 CSECT 00010000
STM R14,R12,12(R13) STORE MULTIPLE FROM R14,R12
LR R12,R15 LOAD ENTRY POINT(R15) TO R12
USING PGM1,R12
ST R13,SAVEAREA+4 STORE CALLER SAREA IN OUR S.AREA
LR R4,R13 MOVE R13 TO R4
LA R13,SAVEAREA LOAD ADDR OF S.AREA TO R13
ST R13,8(R4) STORE R13 IN THEIR SAVE AREA
then add R11 as your second base register. I hope you know that.